Wednesday, August 27, 2008

[BUGS] BUG #4382: there is an exagerate increase of execution times putting a 'case' condition in this update

The following bug has been logged online:

Bug reference: 4382
Logged by: Gianluca Buttarelli
Email address: gianluca.buttarelli@business-partner.it
PostgreSQL version: 8.1.11
Operating system: linux
Description: there is an exagerate increase of execution times
putting a 'case' condition in this update
Details:

update accounts_changing set closed_sc_nowcurrent_nbr = (select count (*)
from crm_shopping_carts ,qab_wf_states
where accounts_changing.account_id=crm_shopping_carts.agency_id
and qab_wf_states.state_code in ('SC-FAT1','SC-FAT2') and
crm_shopping_carts.state_id = qab_wf_states.state_id and
(case when ( CURRENT_DATE > date(EXTRACT(YEAR FROM
CURRENT_DATE)||'-10-31') and CURRENT_DATE < date(EXTRACT(YEAR FROM
CURRENT_DATE)||'-12-31'))
then (crm_shopping_carts.creation_date between date((EXTRACT(YEAR FROM
CURRENT_DATE))||'-11-01') and CURRENT_DATE)
else (crm_shopping_carts.creation_date between date((EXTRACT(YEAR FROM
CURRENT_DATE)-1)||'-11-01')and CURRENT_DATE) end ))
where active_indcr='1'

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

No comments: