Re: Evaluation of secondary sort key.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Evaluation of secondary sort key.
Дата
Msg-id 4066.1302368049@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Evaluation of secondary sort key.  (Martijn van Oosterhout <kleptog@svana.org>)
Ответы Re: Evaluation of secondary sort key.  (Jesper Krogh <jesper@krogh.cc>)
Re: Evaluation of secondary sort key.  (Jesper Krogh <jesper@krogh.cc>)
Список pgsql-hackers
Martijn van Oosterhout <kleptog@svana.org> writes:
> On Sat, Apr 09, 2011 at 09:17:10AM -0700, David Fetter wrote:
>>> It seems strange that there is a need to evaluate testsort(id) at
>>> all in this case.

>> How would PostgreSQL know that sorting by id leaves no ambiguity for
>> the next key to address?

> Well, it doesn't know that, but I guess the point is it could wait with
> evaluating the second key until it needs it.

I think that would be a positive disimprovement.  The current design
guarantees that volatile sort expressions are evaluated exactly once,
in the order the rows are read from the data source.  There would be no
guarantees at all, either as to the number of evaluations or the order
in which they happen, if we tried to do evaluation only during the
actual sort.

Another small problem is that any such thing would require carrying
along some kind of closure (ie, the expression and all its input
values), not just the final sort key value, in tuples being sorted.
The ensuing complexity, speed penalty, and increase in data volume
to be sorted would be paid by everybody, making this probably a net
performance loss when considered across all applications.
        regards, tom lane


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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: Evaluation of secondary sort key.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: using a lot of maintenance_work_mem