Re: [GENERAL] Union Query Improvement

2007-02-15 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/14/07 06:43, Ray Bannon wrote: > There is only one table/view, it's getting one record for each of the Clarity in question-asking always helps. > hundred or so plan ID's that I'm looking for. One table, huh? Then why all the references to "RO

Re: [GENERAL] Union Query Improvement

2007-02-15 Thread Demian Lessa
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ever considered using a materialized view? If you do, you could write the code to load/sync your materialized view using a FOR loop. Note that PostgreSQL does not support materialized views out of the box, so you'd need to play around with some trigger

Re: [GENERAL] Union Query Improvement

2007-02-15 Thread Ray Bannon
There is only one table/view, it's getting one record for each of the hundred or so plan ID's that I'm looking for. On 2/13/07 11:29 PM, in article [EMAIL PROTECTED], "Ron Johnson" <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 02/13/07 07:46, Ray Bannon wro

Re: [GENERAL] Union Query Improvement

2007-02-14 Thread Reece Hart
On Tue, 2007-02-13 at 05:46 -0800, Ray Bannon wrote: > Select ID, plan_name from table/view > Where plan_name = 'A' > And rownum = 1 > UNION ... > > Ad infinitum for about 100 iterations. > > Any way to write this more efficiently? I assume that "table/view" in your OP really refers to diffe

Re: [GENERAL] Union Query Improvement

2007-02-14 Thread Tom Lane
Ray Bannon <[EMAIL PROTECTED]> writes: > Any way to write this more efficiently? UNION -> UNION ALL, perhaps? Do you really need UNION's duplicate-row- elimination behavior? regards, tom lane ---(end of broadcast)--- TIP 3:

Re: [GENERAL] Union Query Improvement

2007-02-13 Thread Ron Johnson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/13/07 07:46, Ray Bannon wrote: > I have a query which is running a bit slowly, and I'm wondering if anyone > has a design improvement. Basically it's a series of unions as follows: > > Select ID, plan_name from table/view > Where plan_name = 'A'

Re: [GENERAL] Union Query Improvement

2007-02-13 Thread Chris
Ray Bannon wrote: I have a query which is running a bit slowly, and I'm wondering if anyone has a design improvement. Basically it's a series of unions as follows: Select ID, plan_name from table/view Where plan_name = 'A' And rownum = 1 UNION Select ID, plan_name from table/view Where plan_name

[GENERAL] Union Query Improvement

2007-02-13 Thread Ray Bannon
I have a query which is running a bit slowly, and I'm wondering if anyone has a design improvement. Basically it's a series of unions as follows: Select ID, plan_name from table/view Where plan_name = 'A' And rownum = 1 UNION Select ID, plan_name from table/view Where plan_name = 'B' And rownum =