is it possible to for the planner to optimize this form?

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема is it possible to for the planner to optimize this form?
Дата
Msg-id 6EE64EF3AB31D5448D0007DD34EEB34101AE56@Herge.rcsinc.local
обсуждение исходный текст
Ответы Re: is it possible to for the planner to optimize this form?
Список pgsql-performance
Right now, I am having trouble getting the planner to optimize queries
in the form of

select t.key, t.field from t a
    where
    (
        select count(*) from t b
        where b.field > a.field
    ) = k

The subplan (either index or seq. scan) executes once for each row in t,
which of course takes forever.

This query is a way of achieving LIMIT type results (substitute n-1
desired rows for k) using standard SQL, which is desirable in some
circumstances.  Is it theoretically possible for this to be optimized?

Merlin


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

Предыдущее
От: "SZŰCS Gábor"
Дата:
Сообщение: Re: Relation of cpu_*_costs?
Следующее
От: Steve Wampler
Дата:
Сообщение: Re: [JDBC] Using a COPY...FROM through JDBC?