pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mike Biamonte <mike@dbeat.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Huge Data sets, simple queries
Date: Sat, 28 Jan 2006 10:55:02 -0500
Message-ID: <11814.1138463702@sss.pgh.pa.us> (raw)
In-Reply-To: <007101c623a9$82207c10$0200a8c0@videobox>
References: <007101c623a9$82207c10$0200a8c0@videobox>

"Mike Biamonte" <mike@dbeat.com> writes:
> The queries I need to run on my 200 million transactions are relatively
> simple:

>    select month, count(distinct(cardnum)) count(*), sum(amount) from
> transactions group by month;

count(distinct) is not "relatively simple", and the current
implementation isn't especially efficient.  Can you avoid that
construct?

Assuming that "month" means what it sounds like, the above would result
in running twelve parallel sort/uniq operations, one for each month
grouping, to eliminate duplicates before counting.  You've got sortmem
set high enough to blow out RAM in that scenario ...

			regards, tom lane



view thread (41+ messages)  latest in thread

Message-ID: <11814.1138463702@sss.pgh.pa.us>
Permalink:  ../11814.1138463702@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/11814.1138463702@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, mike@dbeat.com
  Subject: Re: Huge Data sets, simple queries
  In-Reply-To: <11814.1138463702@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