From: Tom Lane <tgl@sss.pgh.pa.us>
To: juerg.rietmann@pup.ch
Cc: pgsql-sql@postgresql.org
Subject: Re: monster query, how to make it smaller
Date: Tue, 23 Jan 2001 11:31:05 -0500
Message-ID: <6477.980267465@sss.pgh.pa.us> (raw)
In-Reply-To: <OF81AB8B38.22ACC82B-ONC12569DD.00504C90@pup.ch>
References: <OF81AB8B38.22ACC82B-ONC12569DD.00504C90@pup.ch>
Can't you skip the UNIONing and do this with something like
where (Z_A_nr is NULL
AND Z_umfang = '900' AND Z_blaenge = '2340' AND
Z_durch_soll IN ('286.1', '286.15', '286.20', ...)
AND Z_status = 'zcu'
AND (((Z_durch_soll+0.25)-Z_durch_ist) / 2) >= 0.085
AND (((Z_durch_soll+0.25)-Z_durch_ist) / 2) > 0.12)
?
I'm not sure whether the difference in the last output expression
(Z_durch_soll+0.25 in the first UNION'd select, Z_durch_soll+0.2
in the rest) is intentional or a typo. If it's intentional, you
could write it as something like
CASE WHEN Z_durch_soll = '286.45' THEN Z_durch_soll+0.25
ELSE Z_durch_soll+0.2 END
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, juerg.rietmann@pup.ch
Subject: Re: monster query, how to make it smaller
In-Reply-To: <6477.980267465@sss.pgh.pa.us>
References: <OF81AB8B38.22ACC82B-ONC12569DD.00504C90@pup.ch> <6477.980267465@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox