Union Query Improvement

From: Ray Bannon <bannonr(at)comcast(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Union Query Improvement
Date: 2007-02-13 13:46:32
Message-ID: C1F70138.25C%bannonr@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 = 1
UNION
Select ID, plan_name from table/view
Where plan_name = 'C'
And rownum = 1
UNION

Ad infinitum for about 100 iterations.

Any way to write this more efficiently?

Thanks!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Cristiano Panvel 2007-02-13 13:49:54 Re: PostgreSQL and OpenLdap
Previous Message Dmitriy Chumack 2007-02-13 13:46:19 Function, that returns set of 2 tables columns