Re: Function to either return one or all records

From: KÖPFERL Robert <robert(dot)koepferl(at)sonorys(dot)at>
To:
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Function to either return one or all records
Date: 2005-04-21 06:43:03
Message-ID: ED4E30DD9C43D5118DFB00508BBBA76EB166C8@neptun.sonorys.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hmmm, you're right.
Is there any way to do a

explain select * from id_val_tbl where false

while explain doesn't tell SEQ_SCAN?

I have to admit that I didn't performance tested this. I just saw explain
writing SEQ_SCAN.

|-----Original Message-----
|From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
|Sent: Mittwoch, 20. April 2005 23:06
|To: Tambet Matiisen
|Cc: KÖPFERL Robert; pgsql-sql(at)postgresql(dot)org
|Subject: Re: [SQL] Function to either return one or all records
|
|
|"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
|

Browse pgsql-sql by date

  From Date Subject
Next Message Tambet Matiisen 2005-04-21 07:34:33 Re: Function to either return one or all records
Previous Message Michael Fuhr 2005-04-21 03:39:40 Re: checking pgsql functions