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

From Tom Lane
Subject Re: Large CASE-statement is pretty slow?
Date
Msg-id 25013.1079298580@sss.pgh.pa.us
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:
> Anyway, I was looking into the usefullness of a INSERT INTO newtable
> SELECT field, field, CASE pkey WHEN x1 THEN y1 WHEN x2 THEN y2 etc END
> FROM oldtable

> The resulting select was about 1.7MB of query-text, mostly composed of
> the CASE-statement.

Hm, you mean one single SELECT, one single CASE?  How many WHEN clauses
exactly?  Exactly what did a typical clause of the CASE look like?

I wouldn't be too surprised to find some bit of code that's O(N^2) in
the number of arms of the CASE, or something like that; it's not an area
that we've ever felt the need to optimize.  But I'd like a fairly
specific test case before trying to look into it.

            regards, tom lane

pgsql-performance by date:

Previous
From: Arjen van der Meijden
Date:
Subject: Large CASE-statement is pretty slow?
Next
From: "Aaron Werman"
Date:
Subject: Re: Scaling further up