pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marc Cousin <mcousin@sigma.fr>
Cc: pgsql-performance@postgresql.org
Subject: Re: Problem with large query
Date: Wed, 08 Sep 2004 10:56:17 -0400
Message-ID: <20325.1094655377@sss.pgh.pa.us> (raw)
In-Reply-To: <200409081650.00228.mcousin@sigma.fr>
References: <200409081549.49537.mcousin@sigma.fr>
	<20149.1094654443@sss.pgh.pa.us>
	<200409081650.00228.mcousin@sigma.fr>

Marc Cousin <mcousin@sigma.fr> writes:
> The query has been generated by business objects ... i'ill try to suggest to the developpers to remove this constant (if they can)...
> The fields used by the sort are of type numeric(6,0) or (10,0) ...
> Could it be better if the fields were integer or anything else ?

integer or bigint would be a WHOLE lot faster.  I'd venture that
comparing two numerics is order of a hundred times slower than
comparing two integers.

Even if you don't want to change the fields on-disk, you might think
about casting them all to int/bigint in the query.

Another thing that might or might not be easy is to change the order of
the GROUP BY items so that the fields with the largest number of
distinct values are listed first.  If two rows are distinct at the first
column, the sorting comparison doesn't even have to look at the
remaining columns ...

			regards, tom lane



view thread (6+ messages)  latest in thread

Message-ID: <20325.1094655377@sss.pgh.pa.us>
Permalink:  ../20325.1094655377@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20325.1094655377@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, mcousin@sigma.fr
  Subject: Re: Problem with large query
  In-Reply-To: <20325.1094655377@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