Re: [PERFORM] avoiding seq scans when two columns are very correlated

2011-11-15 Thread Ruslan Zakirov
On Tue, Nov 15, 2011 at 11:08 AM, Stuart Bishop wrote: > On Fri, Nov 11, 2011 at 10:01 PM, Ruslan Zakirov > wrote: >> Hello, [snip] >> In application such wrong estimation result in seq scan of this table >> winning leading position in execution plans over other t

Re: [PERFORM] avoiding seq scans when two columns are very correlated

2011-11-11 Thread Ruslan Zakirov
On Fri, Nov 11, 2011 at 7:36 PM, Tom Lane wrote: > Ruslan Zakirov writes: >> A table has two columns id and EffectiveId. First is primary key. >> EffectiveId is almost always equal to id (95%) unless records are >> merged. Many queries have id = EffectiveId condition. Bot

[PERFORM] avoiding seq scans when two columns are very correlated

2011-11-11 Thread Ruslan Zakirov
Hello, A table has two columns id and EffectiveId. First is primary key. EffectiveId is almost always equal to id (95%) unless records are merged. Many queries have id = EffectiveId condition. Both columns are very distinct and Pg reasonably decides that condition has very low selectivity and pick