X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 75918D1D1D5 for ; Sun, 14 Mar 2004 21:09:35 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 59443-10 for ; Sun, 14 Mar 2004 17:09:41 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 9C8C0D1CCCF for ; Sun, 14 Mar 2004 17:09:33 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2EL9ejT025014; Sun, 14 Mar 2004 16:09:40 -0500 (EST) To: Arjen van der Meijden Cc: pgsql-performance@postgresql.org Subject: Re: Large CASE-statement is pretty slow? In-reply-to: <4054B36C.8030306@vulcanus.its.tudelft.nl> References: <4054B36C.8030306@vulcanus.its.tudelft.nl> Comments: In-reply-to Arjen van der Meijden message dated "Sun, 14 Mar 2004 20:33:00 +0100" Date: Sun, 14 Mar 2004 16:09:40 -0500 Message-ID: <25013.1079298580@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/187 X-Sequence-Number: 6043 Arjen van der Meijden 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