From: Christoph Haller <ch@rodos.fzk.de>
To: pgsql-sql@postgresql.org
Subject: Speeding up SELECT MAX(),... GROUP BY ... ?
Date: Wed, 22 May 2002 17:25:50 METDST
Message-ID: <200205221525.RAA26917@rodos> (raw)
Hi,
I am having select statements which are running too slow.
It's PostgreSQL 7.2.1 and a VACUUM ANALYZE was done.
There are various where clauses restricting the output
to timepoints and/or ids related to sources,locations,...
One statement looks like:
EXPLAIN
select max(timepoint),lid,mid,sid from onfvalue
where timepoint <= '2002-05-01 08:00:00' and sid in (1,3,5,7) group by sid,lid,mid;
NOTICE: QUERY PLAN:
Aggregate (cost=21044.07..22383.53 rows=13395 width=20)
-> Group (cost=21044.07..22048.66 rows=133946 width=20)
-> Sort (cost=21044.07..21044.07 rows=133946 width=20)
-> Seq Scan on onfvalue (cost=0.00..5530.24 rows=133946 width=20)
Any ideas/alternatives to speed this up?
The table 'onfvalue' is supposed to keep some million rows.
Regards, Christoph
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-sql@postgresql.org
Cc: ch@rodos.fzk.de
Subject: Re: Speeding up SELECT MAX(),... GROUP BY ... ?
In-Reply-To: <200205221525.RAA26917@rodos>
* 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