Hi,
I'm wondering whether I need to do something to further optimize
a query. My query looks like this:
select price, date FROM foo
WHERE date < '2000-07-01 00:29:00+10' and code='UCL'
ORDER by date DESC, stock DESC
LIMIT 100;
I've got over 7 million rows in the table, and a btree
index(date, code). According to "explain", the query will be
executed as follows:
Limit (cost=0.00..393.45 rows=100 width=32)
-> Index Scan Backward using foo_date_code on trades
(cost=0.00..12309.13 rows=3128 width=32)
When I run the query, it takes a really long time (10 seconds)
the first time I execute it, and then returns instantly the
second time.
Is there something I need to do in order to get these running
faster, the *first* time? I've run "VACUUM ANALYZE" on the
table after all the rows were inserted.
Thanks.
-Ken