Lists: | pgsql-performance |
---|
From: | "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com> |
---|---|
To: | "Scott Marlowe" <smarlowe(at)g2switchworks(dot)com> |
Cc: | <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: 8.x index insert performance |
Date: | 2005-10-31 21:10:57 |
Message-ID: | 6EE64EF3AB31D5448D0007DD34EEB3417DD732@Herge.rcsinc.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
> select * from sometable where somefield IS NULL won't work because IS
is
> not a nomally indexible operator.
Ah, I didn't know that. So there is no real reason not to exclude null
values from all your indexes :). Reading Tom's recent comments
everything is clear now.
Instead of using your two index approach I prefer to:
create function nullidx(anyelement) returns boolean as $$ select $1 is
null; $$ language
sql immutable;
create index on t(nullidx(f)); -- etc
Merlin
From: | Greg Stark <gsstark(at)mit(dot)edu> |
---|---|
To: | "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com> |
Cc: | "Scott Marlowe" <smarlowe(at)g2switchworks(dot)com>, <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: 8.x index insert performance |
Date: | 2005-11-02 17:26:25 |
Message-ID: | 87oe53hsfy.fsf@stark.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-performance |
"Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com> writes:
> > select * from sometable where somefield IS NULL won't work because IS
> is
> > not a nomally indexible operator.
>
> Ah, I didn't know that. So there is no real reason not to exclude null
> values from all your indexes :). Reading Tom's recent comments
> everything is clear now.
There are other reasons. If you want a query like
SELECT * FROM tab ORDER BY col LIMIT 10
to use an index on col then it can't exclude NULLs or else it wouldn't be
useful. (Oracle actually has this problem, you frequently have to add WHERE
col IS NOT NULL" in order to let it use an index.)
--
greg