Re: [PERFORM] switchover between index and sequential scans

2008-07-03 Thread Abhijit Menon-Sen
Hi Greg. At 2008-07-03 11:05:46 +0100, [EMAIL PROTECTED] wrote: > > And increase the statistics target on header_fields and re-analyze? Aha! Thanks for the tip. I just changed the default_statistics_target to 100 (from 10) and ANALYSEd header_fields and mailbox_messages, and now it ALWAYS uses th

Re: [PERFORM] switchover between index and sequential scans

2008-07-03 Thread Gregory Stark
"Abhijit Menon-Sen" <[EMAIL PROTECTED]> writes: > -> Index Scan using header_fields_message_key on header_fields > (cost=0.00..1126.73 rows=325 width=4) (actual time=9.003..12.330 rows=17 > loops=75) >Index Cond: (header_fields.message = "outer".message) > > -

[PERFORM] switchover between index and sequential scans

2008-07-03 Thread Abhijit Menon-Sen
Hi. I have a table with 1.8M rows on a Postgres 8.1.4 server, and I'm executing a query which looks like: select count(*) from header_fields where message in (select message from mailbox_messages limit N); I've found that when N==75, the query uses a fast index scan, but when N==100, it