pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Cristian Prieto <cristian@clickdiario.com>
To: pgsql-performance@postgresql.org
Subject: Any way to optimize GROUP BY queries?
Date: Mon, 19 Dec 2005 11:30:25 -0600
Message-ID: <00d701c604c1$e6945d80$6500a8c0@gt.ClickDiario.local> (raw)

I have the following table:

 

CREATE TABLE mytmp (

            Adv integer,

            Pub integer,

            Web integer,

            Tiempo timestamp,

            Num integer,

            Country varchar(2)

);

 

CREATE INDEX idx_mytmp ON mytmp(adv, pub, web);

 

And with 16M rows this query:

 

SELECT adv, pub, web, country, date_trunc('hour', tiempo), sum(num)

FROM mytmp GROUP BY adv, pub, web, country, date_trunc('hour', tiempo)

 

I've tried to create index in different columns but it seems that the group
by clause doesn't use the index in any way.

 

Is around there any stuff to accelerate the group by kind of clauses?

 

Thanks a lot.

 

 

 

Attachments:

image001.gif (image/gif, 7.1K) download view image

view thread (4+ messages)  latest in thread

Message-ID: <00d701c604c1$e6945d80$6500a8c0@gt.ClickDiario.local>
Permalink:  ../00d701c604c1$e6945d80$6500a8c0@gt.ClickDiario.local/
Also on:    postgresql.org/message-id/00d701c604c1$e6945d80$6500a8c0@gt.ClickDiario.local

 · 

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: cristian@clickdiario.com
  Subject: Re: Any way to optimize GROUP BY queries?
  In-Reply-To: <00d701c604c1$e6945d80$6500a8c0@gt.ClickDiario.local>

* 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