Re: [PERFORM] index of only not null, use function index?

2017-06-08 Thread Merlin Moncure
On Thu, Jun 8, 2017 at 11:05 AM, Jeremy Finzel wrote: > On Thu, Jun 8, 2017 at 9:58 AM, Tom Lane wrote: >> Merlin Moncure writes: >> > Having said that, what I typically do in such >> > cases (this comes a lot in database driven work queues) something like >> > this: >> > CREATE INDEX ON table (

Re: [PERFORM] index of only not null, use function index?

2017-06-08 Thread Jeremy Finzel
Normally, I find that in these situations, it makes sense to index the primary key of the table WHERE col is not null, because it will usually cover the largest number of cases, and is much better than a two-value boolean index, for example. On Thu, Jun 8, 2017 at 9:58 AM, Tom Lane wrote: > Merl

Re: [PERFORM] Re: join under-estimates with ineq conditions

2017-06-08 Thread Justin Pryzby
On Mon, Jun 05, 2017 at 05:02:32PM -0400, Tom Lane wrote: > Justin Pryzby writes: > > diff --git a/src/backend/utils/adt/selfuncs.c > > b/src/backend/utils/adt/selfuncs.c > > + if (nd1>vardata1->rel->rows) nd1=vardata1->rel->rows; > > + if (nd2>vardata1->rel->rows) nd2=vardata2->rel->

Re: [PERFORM] index of only not null, use function index?

2017-06-08 Thread Tom Lane
Merlin Moncure writes: > On Mon, May 22, 2017 at 10:17 AM, Ariel wrote: >> Should I do: >> >> CREATE INDEX ON table ((col IS NOT NULL)) WHERE col IS NOT NULL >> >> or: >> >> CREATE INDEX ON table (col) WHERE col IS NOT NULL >> >> I'm thinking the first index will make a smaller, simpler, inde

Re: [PERFORM] index of only not null, use function index?

2017-06-08 Thread Merlin Moncure
On Mon, May 22, 2017 at 10:17 AM, Ariel wrote: > > I need to be able to quickly find rows where a column is not null (only a > small percent of the rows will have that column not null). > > Should I do: > > CREATE INDEX ON table ((col IS NOT NULL)) WHERE col IS NOT NULL > > or: > > CREATE INDEX ON