Re: optimizing impossible matches

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: optimizing impossible matches
Дата
Msg-id 6701.1078932076@sss.pgh.pa.us
обсуждение исходный текст
Ответ на optimizing impossible matches  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
Список pgsql-hackers
"Merlin Moncure" <merlin.moncure@rcsonline.com> writes:
> Is this really as simple as it seems?

No.

The optimizer has no knowledge of specific operators except what it
finds in the system catalogs.  It has no way in general to determine
that a comparison involving nonconstant values must always fail.
Even if we could do it, I am dubious that it would be worth expending
the cycles on every query to determine whether the situation holds.
AFAICS those would be wasted cycles on the huge majority of queries.

BTW, your claim here is simply false:

> also, for the typical case for indexed field f,
>     select * from t where f = f' or false
> generates an index scan
> but 
>     select * from t where f = f' or f = f''
> generates a seq. scan with default settings.

Depending on the statistics of the column f, the optimizer might think
that a seqscan is better than a double indexscan, but it's not some kind
of hardwired behavior.  I don't even think it's "typical" behavior.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: PITR Functional Design v2 for 7.5
Следующее
От: Fabien COELHO
Дата:
Сообщение: Re: question about char/wchar/mb utils