Re: [PERFORM] Estimation question...

2013-02-28 Thread Matt Daw
I get it now... project_id=115 has a frequency of 0.09241 in pg_stats. So if ((project_id = 115) AND (project_id = 115)) is considered as two independent conditions, the row estimate ends up being 0.09241 * 0.09241 * 1.20163e+07 (reltuples from pg_class) = 102614. http://www.postgresql.org/docs/9.

Re: [PERFORM] Estimation question...

2013-02-27 Thread Matt Daw
Quick follow up... I've found that the row estimate in: explain select count(id) from versions where project_id IN (80,115) AND project_id=115; QUERY PLAN

[PERFORM] Estimation question...

2013-02-26 Thread Matt Daw
Howdy, the query generator in my app sometimes creates redundant filters of the form: project_id IN ( ) AND project_id = ... and this is leading to a bad estimate (and thus a bad plan) on a few complex queries. I've included simplified examples below. This server is running 9.0.10 and the stati