pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Arjen van der Meijden <acmmailing@vulcanus.its.tudelft.nl>
Cc: pgsql-performance@postgresql.org
Subject: Re: Large CASE-statement is pretty slow?
Date: Sun, 14 Mar 2004 16:09:40 -0500
Message-ID: <25013.1079298580@sss.pgh.pa.us> (raw)
In-Reply-To: <4054B36C.8030306@vulcanus.its.tudelft.nl>
References: <4054B36C.8030306@vulcanus.its.tudelft.nl>

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



view thread (7+ messages)  latest in thread

Message-ID: <25013.1079298580@sss.pgh.pa.us>
Permalink:  ../25013.1079298580@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/25013.1079298580@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, acmmailing@vulcanus.its.tudelft.nl
  Subject: Re: Large CASE-statement is pretty slow?
  In-Reply-To: <25013.1079298580@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox