X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id DD298D1C95B for ; Mon, 24 May 2004 03:04:08 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 73452-09 for ; Mon, 24 May 2004 03:03:50 -0300 (ADT) Received: from builder.localdomain (unknown [61.94.124.64]) by svr1.postgresql.org (Postfix) with SMTP id 56ADBD1B8F2 for ; Mon, 24 May 2004 03:03:46 -0300 (ADT) Received: (qmail 5408 invoked from network); 24 May 2004 06:03:54 -0000 Received: from localhost (HELO localhost.localdomain) (127.0.0.1) by builder.localdomain with SMTP; 24 May 2004 06:03:54 -0000 Received: from 192.168.0.103 by builder.localdomain (MWN SMTPD 0.0.8-pre/20040508) id 91f969359a662a6efaa90fce068cf2cd with SMTP; 24 May 2004 06:03:54 +0000 Message-ID: <40B1904A.3090307@zara.6.isreserved.com> Date: Mon, 24 May 2004 13:03:54 +0700 From: David Garamond User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Greg Stark Cc: pgsql-general@postgresql.org Subject: Re: how many record versions References: <40AFAD9F.6000104@zara.6.isreserved.com> <40B0D230.6030803@zara.6.isreserved.com> <87vfimq114.fsf@stark.xeocode.com> In-Reply-To: <87vfimq114.fsf@stark.xeocode.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/721 X-Sequence-Number: 61155 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