From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrus <eetasoft@online.ee>
Cc: pgsql-performance@postgresql.org
Subject: Re: why group expressions cause query to run forever
Date: Thu, 22 Jun 2006 15:30:24 -0400
Message-ID: <2851.1151004624@sss.pgh.pa.us> (raw)
In-Reply-To: <e7en5r$gm1$1@news.hub.org>
References: <e7en5r$gm1$1@news.hub.org>
"Andrus" <eetasoft@online.ee> writes:
> How to speed the following query? It seems to run forever.
> explain SELECT
> bilkaib.DB,
> CASE WHEN dbkonto.objekt1='+' THEN bilkaib.DBOBJEKT ELSE '' END AS dbobjekt,
> CASE WHEN dbkonto.objekt2='+' THEN bilkaib.DB2OBJEKT ELSE '' END AS
> db2objekt,
> CASE WHEN dbkonto.objekt3='+' THEN bilkaib.DB3OBJEKT ELSE '' END AS
> db3objekt,
> ...
> GROUP BY
> 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
I think the problem is probably that you're sorting two dozen CHAR
columns, and that in many of the rows all these entries are '' forcing
the sort code to compare all two dozen columns (not so)? So the sort
ends up doing lots and lots and lots of CHAR comparisons. Which can
be slow, especially in non-C locales. What's your locale setting?
regards, tom lane
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, eetasoft@online.ee
Subject: Re: why group expressions cause query to run forever
In-Reply-To: <2851.1151004624@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