Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 241152E00D3 for ; Fri, 30 Nov 2007 05:54:17 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 51652-03 for ; Fri, 30 Nov 2007 05:53:58 -0400 (AST) Received: from outmail137081.authsmtp.net (outmail137081.authsmtp.net [62.13.137.81]) by postgresql.org (Postfix) with ESMTP id 9FE5F2E0278 for ; Fri, 30 Nov 2007 05:54:01 -0400 (AST) Received: from outmail128177.authsmtp.com (outmail128177.authsmtp.com [62.13.128.177]) by punt4.authsmtp.com (8.14.1/8.14.1/Kp) with ESMTP id lAU9s0X8013014; Fri, 30 Nov 2007 09:54:00 GMT Received: from [192.168.0.3] (85-211-24-246.dyn.gotadsl.co.uk [85.211.24.246]) (authenticated bits=0) by mail.authsmtp.com (8.13.8/8.13.8/Kp) with ESMTP id lAU9rxdp039780; Fri, 30 Nov 2007 09:53:59 GMT Subject: Re: [PATCHES] Partition: use triggers instead of rules From: Simon Riggs To: "Joshua D. Drake" Cc: Gregory Stark , Tom Lane , Michael Paesold , NikhilS , David Fetter , "Jonah H. Harris" , PostgreSQL Docs , PostgreSQL Patches In-Reply-To: <20071129095233.67f2b913@commandprompt.com> References: <20071128202615.GG24146@fetter.org> <21686.1196283184@sss.pgh.pa.us> <36e682920711281858x9a37039sa104036bf025de41@mail.gmail.com> <20071129031702.GU24146@fetter.org> <2854.1196315753@sss.pgh.pa.us> <20071128224154.06f950c9@commandprompt.com> <474EDAE2.3010705@gmx.at> <474EE25E.3080304@commandprompt.com> <14455.1196353045@sss.pgh.pa.us> <474EE992.2050209@commandprompt.com> <87zlwxj7xu.fsf@oxford.xeocode.com> <20071129091359.206fd8f2@commandprompt.com> <87ve7lj6y8.fsf@oxford.xeocode.com> <20071129095233.67f2b913@commandprompt.com> Content-Type: text/plain Date: Fri, 30 Nov 2007 09:54:19 +0000 Message-Id: <1196416459.4246.1514.camel@ebony.site> Mime-Version: 1.0 X-Mailer: Evolution 2.8.2 Content-Transfer-Encoding: 7bit X-Server-Quench: 2c94341a-9f2a-11dc-814e-001185d377ca X-AuthRoute: OCdxZQATClZOTQEd DAteCiNZVAwpPBRK HVkIKg5MJUcNSQVJ NksafxtFawVbY1ZH HGQLW1NEUFR7XGB/ bgMfZQBDYEtPQQdu TkpNRE1QERpoT0Bw YxdcGk0ydwZPf3Zw K0ViW3MVXhdzcUV5 Qx9JHDsENHphaTRM TUhZc1ZJcANLfxdA PlN4UyBcLwdSbGoL JyYPFBAcBgAXGwhy aTo4ZWobW1oKAj87 QUJKAC4iVVEfRio8 IgY9Yl8aB1ocO0l6 NlVpQ08cPgR6 X-Authentic-SMTP: 61633235383639.squirrel.dmpriest.net.uk:787/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system! X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/135 X-Sequence-Number: 4668 On Thu, 2007-11-29 at 09:52 -0800, Joshua D. Drake wrote: > In any of the above cases a trigger is going to work better than a > rule with the exceptions of what TGL pointed out and in simpler > partitioning environments where the number of partitions are very low. Agreed to this and in general to JD's points. Tom's point about Rules being statement-level is valid only when all rows from an INSERT SELECT go into one partition. If that were the case then it seems strange to spend lots of time designing a rules infrastructure anyway. If you try to do lots of partitions and RULEs then it sucks. I spoke against their inclusion originally and do so again now. My point then was you don't need this for most partitioning applications. What nobody has mentioned is that Triggers suck as well, so neither Triggers nor Rules should be given centre stage. COPY only makes sense running into the table you are loading and if you're trying to load large amounts of data using INSERTs + anything then you need a whack. Rob did a beautiful de-construction of all of this in Montreal, BTW, with humour too. Current PostgreSQL partitioning is not the same as Oracle's and papering over the cracks doesn't help anybody much. ISTM we should say to people to use COPY into a named partition for high speed, plus these other suggestions if you want some fancy logic, but go careful, cos they're slow. It would be nice to have an example of using CREATE TABLE LIKE + COPY in same transaction, then ALTER TABLE ... INHERITS to add the partition onto the main table. That is now the fastest way in 8.3. I'll leave it to y'all from here though. -- Simon Riggs 2ndQuadrant http://www.2ndQuadrant.com