| From: | hubert depesz lubaczewski <depesz(at)depesz(dot)com> |
|---|---|
| To: | Lefteris <lsidir(at)gmail(dot)com> |
| Cc: | pgsql-performance(at)postgresql(dot)org |
| Subject: | Re: Air-traffic benchmark |
| Date: | 2010-01-07 23:39:33 |
| Message-ID: | 20100107233933.GA19526@depesz.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-performance |
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(at)depesz(dot)com / aim:depeszhdl / skype:depesz_hdl / gg:6749007
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Kevin Grittner | 2010-01-08 00:18:11 | Re: Massive table (500M rows) update nightmare |
| Previous Message | Lefteris | 2010-01-07 23:08:57 | Re: Air-traffic benchmark |