Re: Large CASE-statement is pretty slow? - Mailing list pgsql-performance

From Greg Stark
Subject Re: Large CASE-statement is pretty slow?
Date
Msg-id 87y8q22fr2.fsf@stark.xeocode.com
Whole thread Raw
In response to Large CASE-statement is pretty slow?  (Arjen van der Meijden <acmmailing@vulcanus.its.tudelft.nl>)
Responses Re: Large CASE-statement is pretty slow?
List pgsql-performance
Arjen van der Meijden <acmmailing@vulcanus.its.tudelft.nl> writes:

>
> Of course I wanted to know how long it'd take on postgresql, selecting the
> pkey-field only (without the case) took also some 0.7 seconds (the entire table
> may have been more).
> But the CASE-version took 9026139.201 ms, i.e. over 9000 seconds about 8 times
> slower than MySQL.

Was this the select with the CASE, or the update?

If you did the update and have lots of foreign key references to the table
then every record that's updated forces a check to make sure there are no
references to that record (or an update if it's ON UPDATE CASCADE). If there
are no indexes on the referencing table columns that will be very slow.

--
greg

pgsql-performance by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: [ADMIN] syslog slowing the database?
Next
From: Greg Stark
Date:
Subject: Re: Large CASE-statement is pretty slow?