From: hubert depesz lubaczewski <depesz@depesz.com>
To: Lefteris <lsidir@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Air-traffic benchmark
Date: Fri, 8 Jan 2010 00:39:33 +0100
Message-ID: <20100107233933.GA19526@depesz.com> (raw)
In-Reply-To: <852badbc1001070438j36eb10d3qa22398ffcbef405f@mail.gmail.com>
References: <852badbc1001070438j36eb10d3qa22398ffcbef405f@mail.gmail.com>
On Thu, Jan 07, 2010 at 01:38:41PM +0100, Lefteris wrote:
> airtraffic=# EXPLAIN ANALYZE SELECT "DayOfWeek", count(*) AS c FROM
> ontime WHERE "Year" BETWEEN 2000 AND 2008 GROUP BY "DayOfWeek" ORDER
> BY c DESC;
Well, this query basically has to be slow. Correct approach to this
problem is to add precalculated aggregates - either with triggers or
with some cronjob.
Afterwards query speed depends only on how good are your aggregates,
and/or how detailed.
Of course calculating them is not free, but is done on write (or
periodically), and not on user-request, which makes user-requests *much*
faster.
depesz
--
Linkedin: http://www.linkedin.com/in/depesz / blog: http://www.depesz.com/
jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007
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: depesz@depesz.com, lsidir@gmail.com
Subject: Re: Air-traffic benchmark
In-Reply-To: <20100107233933.GA19526@depesz.com>
* 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