Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEbWn-0003zH-86 for pgsql-admin@arkaria.postgresql.org; Mon, 22 Oct 2018 14:49:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gEbWi-0002xz-U8 for pgsql-admin@arkaria.postgresql.org; Mon, 22 Oct 2018 14:49:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gEbWi-0002xs-Ir for pgsql-admin@lists.postgresql.org; Mon, 22 Oct 2018 14:49:52 +0000 Received: from mail-qk1-x729.google.com ([2607:f8b0:4864:20::729]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gEbWb-0003r7-Hw for pgsql-admin@postgresql.org; Mon, 22 Oct 2018 14:49:52 +0000 Received: by mail-qk1-x729.google.com with SMTP id u20-v6so10904656qkk.9 for ; Mon, 22 Oct 2018 07:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=UpTNwB1m7jYgjQZxH6EYfKkGgLqamI2Ub6gIiNj/LZ0=; b=qralGvemvNKv8jZ42/IMni6lgZcftTje6j8J0YBF51os9ttOh10TNkwJtPvoKjnqjv iU3hy7sJQ+c/jmkWh8rI7SKX2kCb4mbFIVwUCYi2ItfAlaD+9em/c44q/GovfyBGceRw Z5aNmIApP7DKeIPwVFwpEZ/bV/a0FIadEKltM+I1E4rVv6UCqEG5mk7nmclJwU9r7pLV 2NxDw28Hu0BzikmsrAIqb4iU3jJDJEtOWlg5uvabRQoHtMQRvHsMKPCgbsFVLdmulLId zlLOVb/Sn8l1SGWPoPdLNoaEVIbBdKXcUrbhkFvX+fcBgkasT6SvYi7MOC27TfITBnww zAiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=UpTNwB1m7jYgjQZxH6EYfKkGgLqamI2Ub6gIiNj/LZ0=; b=LER62+JVRrO2z92rDx1rnmjDgXaTOA5Vb1GjDnPCWtY7lGMhqIg0zz+p+udWfP5ApD nanvCcRtsgyF02wMPcPG0xRj0yoaLtE66rV2OV3QhPicXyjefhZ3yOkUQAcOLtttTGoW NLfK+rM2VKpUZq/zLOwxVx4HzKViPvLNk7TDYuWFJ0rX3dGWZFAOHXSxRnGnQ3tLk8Tq wotGfWJfTYHqdERG+vWwUSjR8wjlZGBuU9wWq5te7xHO7yx1P99qEQHhIeAfU1KsKHNt pMpCc1ziAmtlOff5qKy+mIERxLVW/8pWrntKwXfdI90xNLtYzlq8oL//UNWjTpSUHP0U iVdQ== X-Gm-Message-State: ABuFfog6U1f9FUMKP9Lwe7jsmaxvC3j6+B1jySDhqdaId3KAcxO/yxte soA/bXPjDZW0BT0utgT3nzpSWg== X-Google-Smtp-Source: ACcGV62ppY0VtOjdhJIYWupDMAhFWNRF33GU+sjYZrTW4WgkcGRhtCwzuZBHJXeqVGui4UgJc1UEIA== X-Received: by 2002:a37:b683:: with SMTP id g125-v6mr42850123qkf.179.1540219783636; Mon, 22 Oct 2018 07:49:43 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id q3sm1250702qkq.79.2018.10.22.07.49.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Oct 2018 07:49:43 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id C69C1656; Mon, 22 Oct 2018 11:49:39 -0300 (-03) Date: Mon, 22 Oct 2018 11:49:39 -0300 From: Alvaro Herrera To: Jorge Torralba Cc: pgsql-admin@postgresql.org Subject: Re: Auto create partition with declarative partitioning Message-ID: <20181022144939.hpy7zhojvos7j4cr@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Oct-19, Jorge Torralba wrote: > In the past I have had a before insert trigger which I would send to a > create partition function. Extract the info from NEW.createdate, and use > some logic to create the partition if it did not exists for the create date. > > However, now, with the partition by range, I get the error : > > Partitioned tables cannot have BEFORE / FOR EACH ROW triggers. Interesting. I don't think this was ever mentioned as a possible use case for BEFORE triggers on partitioned tables, during the pg11 development. Basically we forbade BEFORE triggers on partitioned tables. (You can find the reasons for that in the thread that discussed row trigger development). > Other than creating a bunch of partitions in advance, what are my options? Create *one* partition in advance? Another option would be to contribute the feature of automatically creating the partitions for Postgres 12 :-) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services