Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 405952E3B1A for ; Fri, 4 Jan 2008 12:54:58 -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 50065-02 for ; Fri, 4 Jan 2008 12:54:33 -0400 (AST) Received: from momjian.us (momjian.us [70.90.9.53]) by postgresql.org (Postfix) with ESMTP id 234DC2E3AF8 for ; Fri, 4 Jan 2008 12:54:51 -0400 (AST) Received: (from bruce@localhost) by momjian.us (8.11.6/8.11.6) id m04GsmD17385; Fri, 4 Jan 2008 11:54:48 -0500 (EST) From: Bruce Momjian Message-Id: <200801041654.m04GsmD17385@momjian.us> Subject: Re: Partitioning documentation example In-Reply-To: <1199463350.18598.121.camel@ebony.site> To: Simon Riggs Date: Fri, 4 Jan 2008 11:54:48 -0500 (EST) CC: PostgreSQL-documentation X-Mailer: ELM [version 2.4ME+ PL124 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200801/3 X-Sequence-Number: 4732 Simon Riggs wrote: > On Fri, 2008-01-04 at 10:27 -0500, Bruce Momjian wrote: > > > It seems to me it would be much clearer if we added a second example > > that used to_char() to create the INSERT statement dynamically based on > > NEW.logdate: > > > > CREATE OR REPLACE FUNCTION measurement_insert_trigger() > > RETURNS TRIGGER AS $$ > > BEGIN > > EXECUTE 'INSERT INTO measurement_y' || to_char(NEW.logdate,'YYYY_mMM') || ' VALUES (NEW.*)'; > > END; > > $$ > > LANGUAGE plpgsql; > > > > It will of course fail if the table does not exist, which I think is > > what we want. This trigger function would not have to be modified when > > new tables are added. > > I like your new trigger better than the old, but I am still > uncomfortable with recommending we use triggers with COPY for > performance reasons and we should add a caveat. OK, I will add this example in addition to the examples already present. -- Bruce Momjian http://momjian.us EnterpriseDB http://postgres.enterprisedb.com + If your life is a hard drive, Christ can be your backup. +