pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Berkus <josh@agliodbs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Wierd query behaviour
Date: Fri, 26 Apr 2002 18:43:41 -0400
Message-ID: <12113.1019861021@sss.pgh.pa.us> (raw)
In-Reply-To: <web-1385952@davinci.ethosmedia.com>
References: <web-1385952@davinci.ethosmedia.com>
"Josh Berkus" <josh@agliodbs.com> writes:
> UPDATE cases SET status = 99
> WHERE status = 1 AND NOT EXISTS(
> SELECT case_id FROM case_clients
> WHERE date_resolved IS NULL OR
> date_resolved > ((current_date - "interval"('1 year'))::DATE)
> and case_clients.case_id = cases.case_id);
It says here that OR binds at lower priority than AND. Did you really
mean
... WHERE (date_resolved IS NULL OR
date_resolved > ((current_date - "interval"('1 year'))::DATE))
and case_clients.case_id = cases.case_id);
Since IS NULL isn't indexable, the first version cannot be indexscanned
at all. The second version gives you a shot at using the
case_clients.case_id index.
regards, tom lane
view thread (2+ messages)
Message-ID: <12113.1019861021@sss.pgh.pa.us> Permalink: ../12113.1019861021@sss.pgh.pa.us/ Also on: postgresql.org/message-id/12113.1019861021@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, josh@agliodbs.com Subject: Re: Wierd query behaviour In-Reply-To: <12113.1019861021@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