Re: Function to either return one or all records

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tambet Matiisen" <t(dot)matiisen(at)aprote(dot)ee>
Cc: KÖPFERL Robert <robert(dot)koepferl(at)sonorys(dot)at>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Function to either return one or all records
Date: 2005-04-20 21:06:16
Message-ID: 4710.1114031176@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Tambet Matiisen" <t(dot)matiisen(at)aprote(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Enrico Weigelt 2005-04-21 02:35:37 checking pgsql functions
Previous Message Tambet Matiisen 2005-04-20 20:02:53 Re: Function to either return one or all records