I had a query which was dog slow. Explain showed the following:
QUERY PLAN
----------------------------------------------------------------------------------------------------------------
Aggregate (cost=7878.67..7878.67 rows=1 width=24)
-> Nested Loop (cost=0.00..7878.66 rows=1 width=24)
-> Seq Scan on trans (cost=0.00..7875.63 rows=1 width=20)
Filter: ((firsttimei = 2) AND (sourcepeeraddress = '192.168.0.1'::inet) AND (flowindex = 2))
-> Index Scan using stats_pkey on stats (cost=0.00..3.02 rows=1 width=4)
Index Cond: (stats.id = "outer".stats_id)
Filter: (timeslice < 'Thu 13 Mar 00:00:00 2003'::timestamp without time zone)
(7 rows)
I created an index on firsttimei, vacuum full analysed, and explain showed me
*exactly* the same thing(!) The difference being that the query is now
lightning fast :-) So, what is explain actually telling me? The diffence
is the Filter: returns true|false more quickly because of the index?
Cheers,
Patrick