L Saadi
L Saadi

Reputation: 1

Slow SQL statement on db2 table with 11 000 000 posts

My problem is when I run this statement:

select * from ADMIN.TABLE WHERE NOM="" AND PRENOM =""

It takes more than 5 minutes because NOM and PRENOM are not primary keys. How can I improve the performance?

Upvotes: 0

Views: 46

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269513

You can speed up this query using an index:

select *
from admin.table
where nom = '' and prenom = '';

The appropriate index is admin.table(nom, prenom):

create index idx_table_nom_prenom on admin.table(nom, prenom);

Upvotes: 1

Related Questions