pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: johnf <jfabiani@yolo.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: setting the where clause
Date: Wed, 10 Jun 2009 10:19:14 -0400
Message-ID: <347.1244643554@sss.pgh.pa.us> (raw)
In-Reply-To: <200906100519.34171.jfabiani@yolo.com>
References: <200906100519.34171.jfabiani@yolo.com>

johnf <jfabiani@yolo.com> writes:
> 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".   

Whoever said that doesn't know what they're talking about.  It's not
faster (because it forces an actual index probe to happen) and it's not
safer (what if one day that PK value exists?).

I'd personally go with "where false"; why not say what you mean rather
than forcing humans and computers to deduce that the condition is
constant false?

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <347.1244643554@sss.pgh.pa.us>
Permalink:  ../347.1244643554@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/347.1244643554@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jfabiani@yolo.com
  Subject: Re: setting the where clause
  In-Reply-To: <347.1244643554@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox