From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Josh Berkus" <josh(at)agliodbs(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Wierd query behaviour |
Date: | 2002-04-26 22:43:41 |
Message-ID: | 12113.1019861021@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
"Josh Berkus" <josh(at)agliodbs(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-04-26 22:54:26 | Re: Function won't complete |
Previous Message | Josh Berkus | 2002-04-26 21:57:20 | Function won't complete |