From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Jake Stride <nsuk(at)users(dot)sourceforge(dot)net> |
Cc: | Peter Wilson <petew(at)yellowhawk(dot)co(dot)uk>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Indexes |
Date: | 2005-08-02 14:53:15 |
Message-ID: | 9729.1122994395@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Jake Stride <nsuk(at)users(dot)sourceforge(dot)net> writes:
> Does saying 'main' not mean where main=true as it is a boolean
It means the same, but that doesn't make it an indexable condition.
In Postgres, the index machinery is built around operators; if you
don't have a WHERE clause like "indexvar operator something" then
you don't have an indexable condition.
PG 8.1 will recognize that it can convert a boolean "main" to
"main = true" and then use an index on main, but no existing release
will do so. Here's the CVS log entry about it:
2005-03-26 18:29 tgl
* src/: backend/optimizer/path/indxpath.c,
backend/optimizer/path/orindxpath.c,
backend/optimizer/util/pathnode.c, include/catalog/pg_opclass.h,
include/optimizer/paths.h: Expand the 'special index operator'
machinery to handle special cases for boolean indexes. Previously
we would only use such an index with WHERE clauses like 'indexkey =
true' or 'indexkey = false'. The new code transforms the cases
'indexkey', 'NOT indexkey', 'indexkey IS TRUE', and 'indexkey IS
FALSE' into one of these. While this is only marginally useful in
itself, I intend soon to change constant-expression simplification
so that 'foo = true' and 'foo = false' are reduced to just 'foo'
and 'NOT foo' ... which would lose the ability to use boolean
indexes for such queries at all, if the indexscan machinery
couldn't make the reverse transformation.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2005-08-02 15:01:15 | Re: Problem with dropping a tablespace |
Previous Message | Joshua D. Drake | 2005-08-02 14:42:37 | Re: Slow Inserts on 1 table? |