Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hZKm6-0002WW-QH for pgsql-general@arkaria.postgresql.org; Fri, 07 Jun 2019 19:43:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hZKm4-00006Z-Ut for pgsql-general@arkaria.postgresql.org; Fri, 07 Jun 2019 19:43:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hZKm4-00006O-ET for pgsql-general@lists.postgresql.org; Fri, 07 Jun 2019 19:43:40 +0000 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hZKm1-0008Oy-FM for pgsql-general@lists.postgresql.org; Fri, 07 Jun 2019 19:43:38 +0000 Received: by mail-qt1-x843.google.com with SMTP id n11so1550787qtl.5 for ; Fri, 07 Jun 2019 12:43:37 -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=1QNaHvN2YmzBpAwaRlcn9NxqH508OKoQAxMFZNqtIQ8=; b=DvgUGSIwegzd4th4fRYy0ChPNjKhZemHy6DrMlN2VtfG243jdCctCJ3QxX/0SPhKVF 2l921UHdzIPmYvZKbMKChlC8Xi8K4neH4SwEl7ppOJyI5qoEkKiME9x1ic4EDCdqDmSX lnNq7YlQBdwEplDSh8Vefly5FtRq2u2yhSpsKBeOzZPbWAhNoKT7F2+ad8uixwk3J/ji rGcc2cW1WIaIhbenakiVYvwW+RKIj/0cm3Bwz+jwxi+FlvaE4EZ/Ced8veFk/fRdTmKr UaVLCe1uPRMBOuOWZsfpHmUvB+PkeuZoSvTZnbdCJAePwF5n2Zq8mv7MVOyATmvwyr4O QjRg== 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=1QNaHvN2YmzBpAwaRlcn9NxqH508OKoQAxMFZNqtIQ8=; b=rVnnIgT27jD5ecp8NTqw3KqTuVfMTFuSdRQGGvinEUmk3J/tq9m7OL0IBSWFT3cZHl SkNEbS86njQpTbZ94vosbJXbpUZIsSMYjfXPtNFGBFoRps8+I7nQlPEUvWovi4lUa6ts yZMBtV+nwRp98pymvEmgDScXD8qnaKKalGeGzOgiXQUCyuRYFA6AfclUi7lm+0pidufe mmNbJMu0GLYWnlNQB2rQzal6Z3czp1OxmOC8GyQeFM5Sb3cLQ35MyhozkU7IhM/iSjDn KHQHnBtOxLxQjajxFgAHcofCs3ZGleOnTAde9m1kxDWC704zg3ShhyPF7VZMmP5HdCMM zMDg== X-Gm-Message-State: APjAAAWAT9QVua7J4d8SWJdnZ3+g0XFe4rFnNNR7i2hnJUMe9gVVmYYa q74vWZJ8Y/+MQIeEsG49Li31Zg== X-Google-Smtp-Source: APXvYqyv5vJHM4CO6NipWrWC6WKPHXzNXieDqqIgfNZjR5vXPw6SmXKImTczKNSydeTwN33yrzEvuA== X-Received: by 2002:ac8:2d81:: with SMTP id p1mr47005529qta.279.1559936616543; Fri, 07 Jun 2019 12:43:36 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([177.154.145.98]) by smtp.gmail.com with ESMTPSA id p62sm1396018qkc.42.2019.06.07.12.43.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Jun 2019 12:43:36 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 7E78D12097D; Fri, 7 Jun 2019 15:43:32 -0400 (-04) Date: Fri, 7 Jun 2019 15:43:32 -0400 From: Alvaro Herrera To: Peter Geoghegan Cc: David Rowley , "Alex V." , pgsql-general , tgl Subject: Re: Table partition with primary key in 11.3 Message-ID: <20190607194332.GA23667@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: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Jun-07, Peter Geoghegan wrote: > On Fri, Jun 7, 2019 at 12:18 PM Alvaro Herrera wrote: > > I was thinking of asynchonously cleaning it up rather than blocking > > DROP/DETACH ... which means you need to keep state somewhere. I don't > > think blocking DROP/DETACH is valuable -- a global index that blocks > > DROP/DETACH until the index is clean serves no useful purpose. (You > > could think of a multi-step approach with internal transaction commits, > > similar to CIC, but you still need a plan to clean that up in case the > > server crashes during that operation.) > > The advantage of synchronous clean-up of global indexes when DROP'ing > a partition are that you can recycle the partition number (or whatever > we end up calling it) immediately and predictably, and you can reuse > the space in indexes occupied by keys from the dropped partition > immediately and predictably. That seems less useful than asynchronous > processing on average, certainly, but those are still real advantages. > You seemed to be particularly concerned about quickly recycling > partition numbers when we drop a partition. Well, "quickly" might mean within a week. If it takes that long to fully remove a monthly partition to make that partition ID available to some future month's partition, that seems acceptable. Blocking DROP/DETACH for one hour is certainly not acceptable. If this scheme means that you can keep the partition identifiers stored in the index to, for instance, 10 bits (allowing for 1024 partitions to exist at any one time, including those in the process of being cleaned up) instead of having to expand to (say) 24 because that covers a couple of years of operation before having to recreate the index, it seems worthwhile. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services