From: | "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com> |
---|---|
To: | "Scott Lamb" <slamb(at)slamb(dot)org> |
Cc: | <pgsql-performance(at)postgresql(dot)org>, "Dustin Sallings" <dustin(at)spy(dot)net> |
Subject: | Re: Sorted union |
Date: | 2005-11-03 13:53:00 |
Message-ID: | 6EE64EF3AB31D5448D0007DD34EEB3417DD78D@Herge.rcsinc.local |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2005-11-03 14:01:52 | Re: [PERFORM] improvise callbacks in plpgsql |
Previous Message | Qingqing Zhou | 2005-11-03 07:11:43 | Re: insert performance for win32 |