Re: Function to either return one or all records - Mailing list pgsql-sql

From Tom Lane
Subject Re: Function to either return one or all records
Date
Msg-id 4710.1114031176@sss.pgh.pa.us
Whole thread Raw
In response to Re: Function to either return one or all records  ("Tambet Matiisen" <t.matiisen@aprote.ee>)
List pgsql-sql
"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


pgsql-sql by date:

Previous
From: "Tambet Matiisen"
Date:
Subject: Re: Function to either return one or all records
Next
From: Enrico Weigelt
Date:
Subject: checking pgsql functions