pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tambet Matiisen <t.matiisen@aprote.ee>
Cc: KÖPFERL Robert <robert.koepferl@sonorys.at>
Cc: pgsql-sql@postgresql.org
Subject: Re: Function to either return one or all records
Date: Wed, 20 Apr 2005 17:06:16 -0400
Message-ID: <4710.1114031176@sss.pgh.pa.us> (raw)
In-Reply-To: <A66A11DBF5525341AEF6B8DE39CDE770088073@black.aprote.com>
References: <A66A11DBF5525341AEF6B8DE39CDE770088073@black.aprote.com>

"Tambet Matiisen" <t.matiisen@aprote.ee> writes:
> Standard technique is to rewrite OR queries to UNION queries. I believe PostgreSQL optimizer does not do that automatically. So you could try instead:

> select * from id_bal_tbl where $1 is null
> union all
> select * from id_bal_tbl where id = $1;

... but that won't do anything to solve the performance problem.
Doesn't help for the second select to use an index, if the first
one grovels over the whole table anyway ...

			regards, tom lane



view thread (5+ messages)  latest in thread

Message-ID: <4710.1114031176@sss.pgh.pa.us>
Permalink:  ../4710.1114031176@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4710.1114031176@sss.pgh.pa.us

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, t.matiisen@aprote.ee, robert.koepferl@sonorys.at
  Subject: Re: Function to either return one or all records
  In-Reply-To: <4710.1114031176@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