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)