Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 18BADBB5DD4 for ; Tue, 1 May 2012 16:36:48 -0300 (ADT) Received: from 30.55.colo.spiretech.net ([69.168.55.30] helo=lists.commandprompt.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SPIsP-00047p-1s for pgsql-bugs@postgresql.org; Tue, 01 May 2012 19:36:47 +0000 Received: from perhan.alvh.no-ip.org (spinlock.commandprompt.com [69.168.55.30]) by lists.commandprompt.com (Postfix) with ESMTPA id 1E56F22D; Tue, 1 May 2012 12:36:45 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.10.164] helo=perhan.alvh.no-ip.org) by assp.commandprompt.com with ESMTPS(AES256-SHA) (2.1.1); 1 May 2012 12:36:43 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 12AC46E52E; Tue, 1 May 2012 15:36:25 -0400 (CLT) Content-Type: text/plain; charset=UTF-8 Cc: Pg Bugs Subject: Re: Errors on CREATE TABLE IF NOT EXISTS From: Alvaro Herrera To: Matteo Beccati In-reply-to: <4F9541D3.1000202@beccati.com> References: <4F9541D3.1000202@beccati.com> Date: Tue, 01 May 2012 15:36:24 -0400 Message-Id: <1335900770-sup-854@alvh.no-ip.org> User-Agent: Sup/git X-Assp-Version: 2.1.1(11364) on assp.commandprompt.com X-Assp-Client-TLS: yes X-Assp-ID: assp.commandprompt.com m1-01005-13721 X-Assp-Envelope-From: alvherre@alvh.no-ip.org X-Assp-Intended-For: php@beccati.com X-Assp-Original-Subject: Re: [BUGS] Errors on CREATE TABLE IF NOT EXISTS Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201205/4 X-Sequence-Number: 32975 Excerpts from Matteo Beccati's message of lun abr 23 08:49:39 -0300 2012: > Hi, >=20 > I've recently seen a few errors on our continuous integration system=20 > during a test using a badly written partitioning trigger. The function=20 > was basically checking for the existence of the partition table at ever= y=20 > insert and was running a CREATE TABLE IF NOT EXISTS statement in case i= t=20 > was needed. What baffled me was that the function was exiting with an=20 > ERROR, rather than succeeding with a NOTICE, e.g.: The question you were asking has already been answered, but I think it's worth pointing out that a partitioned-insert trigger that has to check whether the partition exist beforehand is a lot slower than one that doesn't have to. Our usual suggestion is to create the partitions by some other means, e.g. create a couple months worth of weekly partitions, a couple of months ahead of time, via cron. The insert trigger is then assured that the partition exists, and it can become faster by not having to check. --=20 =C3=81lvaro Herrera The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting, Custom Development, 24x7 support