Re: setting the where clause - Mailing list pgsql-sql

From Jasen Betts
Subject Re: setting the where clause
Date
Msg-id h0thuo$38v$1@reversiblemaps.ath.cx
Whole thread Raw
In response to setting the where clause  (johnf <jfabiani@yolo.com>)
List pgsql-sql
On 2009-06-10, johnf <jfabiani@yolo.com> wrote:
> Hi,
> I'm am programming in python using the Dabo modules.  www.dabodev.com if your 
> interested.  Dabo is a framework that provides an easy way to build desktop 
> app's.  To clear a data entry form. I have been setting the where clause 
> to "where 1=0".  This of course retrieves 0 records and my form will display 
> nothing.  It has been suggested that it might be better to set the where 
> clause to a primary key value that does not exist in the table  "where PK 
>= -9999999".   

"where PK=NULL" is better as anything=NULL is never true. PK=-9999999
may be true sometimes.

As Tom says  PK=-9999999  causes postgres to look for a record that
matches, PK=NULL doesn't cause needless search.

that said if -9999999 is outside of the valid range for PK then the
search will finish very quickly as at worst only a sigle btree page
will need to be loaded.

in order of preference.
 no query at all where FALSE where PK=NULL where PK=-9999999 (note that this one may not work) 


pgsql-sql by date:

Previous
From: Rob Sargent
Date:
Subject: Re: polymorphic function in 7.4 vs. 8.3
Next
From: Mario Splivalo
Date:
Subject: Find periods for a given... action set?