From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: setting the where clause |
Date: | 2009-06-12 12:33:28 |
Message-ID: | h0thuo$38v$1@reversiblemaps.ath.cx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 2009-06-10, johnf <jfabiani(at)yolo(dot)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)
From | Date | Subject | |
---|---|---|---|
Next Message | Mario Splivalo | 2009-06-12 12:54:29 | Find periods for a given... action set? |
Previous Message | Rob Sargent | 2009-06-11 23:16:30 | Re: polymorphic function in 7.4 vs. 8.3 |