pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alan Hodgson <ahodgson@simkin.ca>
To: pgsql-performance@postgresql.org
Subject: Re: Performance question 83 GB Table 150 million rows, distinct select
Date: Wed, 16 Nov 2011 15:27:57 -0800
Message-ID: <201111161527.57443.ahodgson@simkin.ca> (raw)
In-Reply-To: <CAEaSS0b7D4eyDi4kt-Dt8u-yGq+akD=5PZwMk_TUHP-zujAnCQ@mail.gmail.com>
References: <CAEaSS0b7D4eyDi4kt-Dt8u-yGq+akD=5PZwMk_TUHP-zujAnCQ@mail.gmail.com>

On November 16, 2011 02:53:17 PM Tory M Blue wrote:
> We now have about 180mill records in that table. The database size is
> about 580GB and the userstats table which is the biggest one and the
> one we query the most is 83GB.
> 
> Just a basic query takes 4 minutes:
> 
> For e.g. select count(distinct uid) from userstats where log_date
> >'11/7/2011'
>
> Just not sure if this is what to expect, however there are many other
> DB's out there bigger than ours, so I'm curious what can I do?

That query should use an index on log_date if one exists. Unless the planner 
thinks it would need to look at too much of the table.

Also, the normal approach to making large statistics tables more manageable is 
to partition them by date range.



view thread (21+ messages)  latest in thread

Message-ID: <201111161527.57443.ahodgson@simkin.ca>
Permalink:  ../201111161527.57443.ahodgson@simkin.ca/
Also on:    postgresql.org/message-id/201111161527.57443.ahodgson@simkin.ca

 · 

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: ahodgson@simkin.ca
  Subject: Re: Performance question 83 GB Table 150 million rows, distinct select
  In-Reply-To: <201111161527.57443.ahodgson@simkin.ca>

* 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