From: | Alban Hertroys <alban(at)magproductions(dot)nl> |
---|---|
To: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
Cc: | Jim Nasby <jnasby(at)pervasive(dot)com>, hubert depesz lubaczewski <depesz(at)gmail(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: A slow query - Help please? |
Date: | 2006-06-21 14:12:08 |
Message-ID: | 449953B8.7040705@magproductions.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Martijn van Oosterhout wrote:
> 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.
Would... So this isn't available yet?
> 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.
I just realized that OFFSET kind of complicates the problem.
If PostgreSQL would handle this (for inheritance as well, I hope), it'd
need to keep track of how many records came from which tables to set the
offsets in the subqueries appropriately, which of course depends on the
previous query... Well, I said it complicates things...
--
Alban Hertroys
alban(at)magproductions(dot)nl
magproductions b.v.
T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede
// Integrate Your World //
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2006-06-21 14:45:57 | Re: A slow query - Help please? |
Previous Message | Wes | 2006-06-21 13:38:35 | Re: Adding foreign key constraints without integrity |