Re: Wierd query behaviour
| От | Tom Lane |
|---|---|
| Тема | Re: Wierd query behaviour |
| Дата | |
| Msg-id | 12113.1019861021@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Wierd query behaviour ("Josh Berkus" <josh@agliodbs.com>) |
| Список | pgsql-sql |
"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
В списке pgsql-sql по дате отправления: