Re: Not using index

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Not using index
Дата
Msg-id 17068.957939503@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Not using index  (Daniele Orlandi <daniele@orlandi.com>)
Список pgsql-hackers
Daniele Orlandi <daniele@orlandi.com> writes:
> [ example snipped ]
> It seems like the index is used only if * appears in the target list.

There is certainly not a dependence on * as such.  However, the
estimated row width does affect the cost estimate for operations like
SORT, where we have to guess how many rows will fit in memory.  It looks
to me like your example case is right near the boundary where the system
thinks that index scan and sort are of roughly equal cost, so relatively
small changes will push the choice in one direction or the other.
This should not be taken as an indication that someone actually
considered the specific examples and decided it should act that way!
It just falls out of the behavior of the cost-estimate-driven planner
structure.  Ideally, the hope is not that this sort of choice is
perfectly right all the time; my ambition only extends to the hope that
if the system thinks index scan and sort are of roughly equal cost,
then indeed they are, and so it wouldn't matter a whole lot which one
gets picked.

Of course we aren't all that close to meeting the ideal goal :-(.
I'm assuming that you are complaining because one or the other of
these plans is actually much cheaper than the other in your example.
You have, however, carefully refrained from giving us any hint which.
Care to fess up with more details?
        regards, tom lane


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

Предыдущее
От: Thomas Lockhart
Дата:
Сообщение: Re: misc questions
Следующее
От: Michael Meskes
Дата:
Сообщение: Comparison PostgreSQL 7.0 vs. Interbase2000