Re: Sorted union

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Sorted union
Дата
Msg-id 6EE64EF3AB31D5448D0007DD34EEB3417DD78D@Herge.rcsinc.local
обсуждение исходный текст
Ответ на Sorted union  (Scott Lamb <slamb@slamb.org>)
Ответы Re: Sorted union
Список pgsql-performance
>      select    when_stopped as when_happened,
>                1 as order_hint
>      from      transaction t
>      where     '2005-10-25 15:00:00' <= when_stopped
>        and     when_stopped <= '2005-10-26 10:00:00'
>      union all
>      select    when_stopped as when_happened,
>                2 as order_hint
>      from      transaction t
>      where     '2005-10-25 15:00:00' <= when_stopped
>        and     when_stopped <= '2005-10-26 10:00:00'
>      order by  when_happened, order_hint;

hmm, try pushing the union into a subquery...this is better style
because it's kind of ambiguous if the ordering will apply before/after
the union.

select q.when from
(
 select 1 as hint, start_time as when [...]
 union all
 select 2 as hint, end_time as when [...]
) q order by q.seq, when

question: why do you want to flatten the table...is it not easier to
work with as records?

Merlin


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

Предыдущее
От: Qingqing Zhou
Дата:
Сообщение: Re: insert performance for win32
Следующее
От: Sven Willenberger
Дата:
Сообщение: Function with table%ROWTYPE globbing