Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 643589FBD4F for ; Thu, 15 Mar 2007 12:58:37 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 41744-01 for ; Thu, 15 Mar 2007 12:58:31 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from m.wordtothewise.com (fruitbat.wordtothewise.com [208.187.80.135]) by postgresql.org (Postfix) with ESMTP id 494C09FBCBF for ; Thu, 15 Mar 2007 12:58:32 -0300 (ADT) Received: from [10.3.2.25] (184.word-to-the-wise.com [208.187.80.184]) by m.wordtothewise.com (Postfix) with ESMTP id 3657080045 for ; Thu, 15 Mar 2007 08:58:30 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.3) In-Reply-To: References: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <69B895EB-1265-490A-90AC-BA80724BFCC4@blighty.com> Content-Transfer-Encoding: 7bit From: Steve Atkins Subject: Re: Dispatch-Merge pattern Date: Thu, 15 Mar 2007 08:58:25 -0700 To: pgsql-performance@postgresql.org X-Mailer: Apple Mail (2.752.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.093 tagged_above=0 required=5 tests=AWL, BAYES_00, DNS_FROM_RFC_POST X-Spam-Level: X-Archive-Number: 200703/249 X-Sequence-Number: 23654 On Mar 13, 2007, at 6:36 AM, James Riordan wrote: > Howdy- > > I am currently using PostgreSQL to store and process a high-bandwidth > event stream. I do not need old events but the delete and vacuum does > not terminate due to the large number of events being inserted (it > just pushes me over the tipping point of where the machine can keep up > with the events). > > I ended up implementing a scheme where a trigger is used to redirect > the events (round robin based on time) to a series of identically > structured tables. I can then use TRUNCATE older tables rather than > DELETE and VACUUM (which is a significant speed up). > > It worked out pretty well so thought post the idea to find out if > > - it is stupid way of doing things and there is a correct database > abstraction for doing this > > or > > - it is a reasonable way of solving this problem and might be of use > to other folks using rdbs as event processing > > I then use a view to merge the tables. Obviously update would be a > problem for my purposes, and I suppose a lot of event processing, it > isn't an issue. > > Either way, details are at: > http://unsyntax.net/james/blog/tools+and+programming/2007/03/08/ > Dispatch-Merge-Database-Pattern I can't reach that URL, but from what you say it sounds like you've re-invented table partitioning. http://www.postgresql.org/docs/8.2/static/ddl-partitioning.html If you do it the postgresql way you can also take advantage of constraint exclusion, to speed up some selects on the set of partitioned tables, and inheritance means you don't have to maintain the union view yourself. Cheers, Steve