Re: A slow query - Help please?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: A slow query - Help please?
Дата
Msg-id 20060621100522.GA7859@svana.org
обсуждение исходный текст
Ответ на Re: A slow query - Help please?  (Alban Hertroys <alban@magproductions.nl>)
Ответы Re: A slow query - Help please?  (Alban Hertroys <alban@magproductions.nl>)
Список pgsql-general
On Wed, Jun 21, 2006 at 11:56:27AM +0200, Alban Hertroys wrote:
> Say we take the query I posted:
>     "SELECT * FROM mm_posrel ORDER BY number DESC LIMIT 25;"
> and the knowledge that this table is inherited by two other tables, with
> number being unique across them (though PostgreSQL probably doesn't know
> about this).
> Can constraint exclusion determine that the last 25 number values do not
> occur in some of the tables?

ISTM that what would really work well is some kind of "Merge Sort" node
that would work by having multiple subnodes which are already sorted
and merging them into one sorted list.

The planner would use this whenever it saw a query of the form:

SELECT * FROM a
UNION ALL
SELECT * FROM b
ORDER BY c;

It would push the ORDER BY down to the subqueries and then merge the
results. If the subqueries can be read efficiently sorted (via an index
for example) then you would get very quick output, especially if you
have a LIMIT clause.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

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

Предыдущее
От: "Oleg Golovanov"
Дата:
Сообщение: Re: DocBook 4.2 detecting at configure time
Следующее
От: simon
Дата:
Сообщение: Re: merge result sets