Requête n'utilisant pas l'index malgré les conditions dans where
Bonjours les amis, voilà j'ai 2 tables assez importantes
table1 contient 23000000 d'enregistreement et table2 continent 63 000 000 d'enregistrement, voici la requête
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| select
ss.id_d,
ss.id_w,
ss.t,
sg.o
from (
select
s.id_d,
s.id_w,
s.t
from
table1 s where not exists(
select
id_d,
id_w
from
table1_updated
where
s.id_d = id_d
and s.id_w = id_w
) limit 1000000
) as ss,
table2 sg
where
ss.id_d = sg.id_d
and ss.id_w = sg.id_w
and ss.t = sg.t |
la table table1_updated est une table que je remplisse après que mon programme parcours cette query
ces 3 tables ont un PK sur les deux colonnes id_d et id_w (id_d, id_w) et j'ai un index mono-colonne sur les 3 colonnes qui sont id_d, id_w et t sur les table1 et table2 pourtant quand j'exécute la requête, elle n'utilise aucun index, elle fait un Seq Scan sur toutes ces 3 tables
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| Merge Join (cost=11963108.56..12601006.26 rows=36036 width=36)
Merge Cond: ((sg.id_word = s.id_word) AND ((sg.id_document)::text = (s.id_document)::text) AND ((sg.texte)::text = (s.texte)::text))
-> Sort (cost=11565940.41..11723238.27 rows=62919144 width=37)
Sort Key: sg.id_word, sg.id_document, sg.texte
-> Seq Scan on sugg sg (cost=0.00..1695264.44 rows=62919144 width=37)
-> Sort (cost=397167.22..399667.22 rows=1000000 width=32)
Sort Key: s.id_word, s.id_document, s.texte
-> Limit (cost=41.75..287509.37 rows=1000000 width=32)
-> Hash Anti Join (cost=41.75..3926263.33 rows=13657961 width=32)
Hash Cond: (((s.id_document)::text = (string_updated.id_document)::text) AND (s.id_word = string_updated.id_word))
-> Seq Scan on string s (cost=0.00..3576742.28 rows=14453428 width=32)
-> Hash (cost=22.70..22.70 rows=1270 width=34)
-> Seq Scan on string_updated (cost=0.00..22.70 rows=1270 width=34) |
Ma question c'est pourquoi cette requête n'utilise-elle aucun index?
Merci déjà pour votre réponse