pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Garamond <lists@zara.6.isreserved.com>
To: Greg Stark <gsstark@mit.edu>
Cc: pgsql-general@postgresql.org
Subject: Re: how many record versions
Date: Mon, 24 May 2004 13:03:54 +0700
Message-ID: <40B1904A.3090307@zara.6.isreserved.com> (raw)
In-Reply-To: <87vfimq114.fsf@stark.xeocode.com>
References: <40AFAD9F.6000104@zara.6.isreserved.com>
	<gpd1b0t6m33cpv0c95o7nqros9rpf5gvk7@email.aon.at>
	<40B0D230.6030803@zara.6.isreserved.com>
	<87vfimq114.fsf@stark.xeocode.com>

Greg Stark wrote:
>>Actually, each record will be incremented probably only thousands of times a
>>day. But there are many banners. Each record has a (bannerid, campaignid,
>>websiteid, date, countrycode) "dimensions" and (impression, click) "measures".
> 
> In the past when I had a very similar situation we kept the raw impression and
> click event data. Ie, one record per impression in the impression table and
> one record per click in the click data. 

> That makes the tables insert-only which is efficient and not prone to locking
> contention. They would never have to be vacuumed except after purging old data.

Assuming there are 10 millions of impressions per day, the impression 
table will grow at least 200-400MB per day, is that correct? What do you 
do and how often do you purge old data? Do you do a mass DELETE on the 
impression table itself or do you switch to another table? I've found 
that deleting tens/hundreds of thousands of row, at least in InnoDB, 
takes long, long time (plus it sucks CPU and slows other queries).

> Then to accelerate queries we had denormalized aggregate tables with a cron
> job that did the equivalent of
> 
> insert into agg_clicks (
>   select count(*),bannerid 
>     from clicks 
>    where date between ? and ?
>    group by bannerid
>   )

-- 
dave




view thread (14+ messages)  latest in thread

Message-ID: <40B1904A.3090307@zara.6.isreserved.com>
Permalink:  ../40B1904A.3090307@zara.6.isreserved.com/
Also on:    postgresql.org/message-id/40B1904A.3090307@zara.6.isreserved.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: lists@zara.6.isreserved.com, gsstark@mit.edu
  Subject: Re: how many record versions
  In-Reply-To: <40B1904A.3090307@zara.6.isreserved.com>
  References: <40AFAD9F.6000104@zara.6.isreserved.com> <gpd1b0t6m33cpv0c95o7nqros9rpf5gvk7@email.aon.at> <40B0D230.6030803@zara.6.isreserved.com> <87vfimq114.fsf@stark.xeocode.com> <40B1904A.3090307@zara.6.isreserved.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