
> > test=# create index myindex on accounts(aid) where bid <> 0;
> 
> > Hmm ? Am I reading correctly ? a restriction that is on a field,
that 
> > is not in the index ? Does that make sense ?
> 
> Yes it does, and in fact it's one of the more important applications
of
> partial indexes.  It's the only way that a partial index can be
cheaper
> to scan than a full index.

Ok, yes, sounds great, but then back to Tatsuo's question:
Why is the index atestpartial not used (instead DEBUG) ?

	create table atest (aid int, bid int);
	create index atestpartial on atest (aid) where bid <> 0;
	select * from atest where aid=1 and bid <> 0;

and instead seq scan for 1 mio rows 2 rows where bid <> 0

Since bid is not in an index the evaluation of usability obviously 
should not be based on index ops ?

Andreas

Mon, 6 Aug 2001 17:05:13 +0200
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at>
RE: AW: partial index 
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at> writes:
> Since bid is not in an index the evaluation of usability obviously 
> should not be based on index ops ?

Feel free to reimplement the theorem-prover, taking special care to
be able to prove things about operators that you have zero information
about the semantics of.

The reason the prover works with btree-indexable operators is that
it can infer a lot of semantics from the index opclass relationships.
This has nothing to do with whether the index itself is btree or not,
let alone whether the variables used in the predicate are in the index.
It's just a way to do something useful within a reasonable amount of
code.

			regards, tom lane

Mon, 06 Aug 2001 11:25:58 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: AW: partial index 
"Zeugswetter Andreas SB SD" <ZeugswetterA@spardat.at> writes:
>> Since bid is not in an index the evaluation of usability obviously 
>> should not be based on index ops ?

Actually, now that I think about it, there's no reason that the prover
couldn't try a simple equal() on a WHERE clause and predicate clause
before moving on to the btree-semantics-based tests.  If the clauses
are statically identical then one implies the other, no?  This would
work nicely for clauses like IS [NOT] NULL, and would give us at least a
little bit of ability to deal with non-btree operator clauses.

			regards, tom lane

Mon, 06 Aug 2001 12:16:05 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: AW: partial index 