Re: partial index on varchar-coloumn in 7.4.1

Поиск
Список
Период
Сортировка
От Martin Hampl
Тема Re: partial index on varchar-coloumn in 7.4.1
Дата
Msg-id 59CA42C0-41C5-11D8-B2CE-000393674318@gmx.de
обсуждение исходный текст
Ответ на Re: partial index on varchar-coloumn in 7.4.1  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Cool :)

Martin.

Am 07.01.2004 um 23:35 schrieb Tom Lane:

> I wrote:
>> Martin Hampl <Martin.Hampl@gmx.de> writes:
>>> Do partial indexes not work for varchar?
>
>> You know and I know that "word = 'abc'" implies "not (word = 'the')",
>> but the planner cannot make that deduction.  The pred_test() routine
>> doesn't really have any intelligence about conditions involving NOT.
>
> Actually, this was easier to fix than I thought.  As of CVS tip:
>
> regression=# create table token(word varchar(30));
> CREATE TABLE
> regression=#  CREATE INDEX word_idx on token (word) where not (word =
> 'the');
> CREATE INDEX
> regression=# explain select * from token where word = 'abc' ;
>                                QUERY PLAN
> -----------------------------------------------------------------------
> -
>  Index Scan using word_idx on token  (cost=0.00..17.07 rows=5 width=33)
>    Index Cond: ((word)::text = 'abc'::text)
> (2 rows)
>
> regression=#
>
> There's still no intelligence about NOT in the theorem prover, but it
> turns out that it's not seeing NOT.  By the time the expressions get to
> the point of being compared, NOT (a=b) has been folded to a<>b, and it
> turned out to be fairly straightforward to extend the existing logic to
> reason about such cases.  The above example requires a process like
> "a = x implies a <> y if x <> y" (where x and y are constants, so the
> "if" part can be checked).  This fits right in with what the code could
> do already, which was cases like "a > x implies a > y if x > y".
> So it'll work more naturally in 7.5.
>
>             regards, tom lane
>


В списке pgsql-novice по дате отправления:

Предыдущее
От: Marcin Gil
Дата:
Сообщение: pgsql 7.0 recovery to 7.4
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pgsql 7.0 recovery to 7.4