X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 39E6753CC6 for ; Thu, 21 Apr 2005 03:43:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 81414-01 for ; Thu, 21 Apr 2005 06:43:10 +0000 (GMT) Received: from mx-00.sil.at (mx-00.sil.at [62.116.68.196]) by svr1.postgresql.org (Postfix) with ESMTP id 3135A53500 for ; Thu, 21 Apr 2005 03:43:08 -0300 (ADT) Received: (qmail-ldap/ctrl 78382 invoked from network); 21 Apr 2005 06:43:06 -0000 Received: from unknown (HELO jupiter.sonorys.at) ([213.235.243.42]) (envelope-sender ) by mx-00.sil.at (qmail-ldap-1.03) with SMTP for ; 21 Apr 2005 06:43:06 -0000 Received: from neptun.sonorys.at (neptun.sonorys.at [172.24.1.17]) by jupiter.sonorys.at (8.11.7+Sun/8.11.7) with ESMTP id j3L6h5108002 for ; Thu, 21 Apr 2005 08:43:05 +0200 (MEST) Received: by neptun.sonorys.at with Internet Mail Service (5.5.2653.19) id <2JD5WJSK>; Thu, 21 Apr 2005 08:43:04 +0200 Message-ID: From: =?ISO-8859-1?Q?K=D6PFERL_Robert?= To: Cc: pgsql-sql@postgresql.org Subject: Re: Function to either return one or all records Date: Thu, 21 Apr 2005 08:43:03 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200504/312 X-Sequence-Number: 21205 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@sss.pgh.pa.us] |Sent: Mittwoch, 20. April 2005 23:06 |To: Tambet Matiisen |Cc: K=D6PFERL Robert; pgsql-sql@postgresql.org |Subject: Re: [SQL] Function to either return one or all records=20 | | |"Tambet Matiisen" writes: |> Standard technique is to rewrite OR queries to UNION=20 |queries. I believe PostgreSQL optimizer does not do that=20 |automatically. So you could try instead: | |> select * from id_bal_tbl where $1 is null |> union all |> select * from id_bal_tbl where id =3D $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 |