Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pc8rD-00088j-Mq for pgsql-performance@arkaria.postgresql.org; Tue, 14 Mar 2023 17:54:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pc8rC-0008EG-L4 for pgsql-performance@arkaria.postgresql.org; Tue, 14 Mar 2023 17:54:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pc8rC-0008E7-5R for pgsql-performance@lists.postgresql.org; Tue, 14 Mar 2023 17:54:42 +0000 Received: from mail-il1-x12a.google.com ([2607:f8b0:4864:20::12a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pc8r8-0003XM-S2 for pgsql-performance@postgresql.org; Tue, 14 Mar 2023 17:54:40 +0000 Received: by mail-il1-x12a.google.com with SMTP id h5so5013792ile.13 for ; Tue, 14 Mar 2023 10:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; t=1678816478; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=c9/Ns1wAe0xLo75BJDdJ8nUa6/ByXxlG+blXI27RIAc=; b=CW2Znu3q48tj/djnrY5Jh3IakmcEX+yATtSFsI6+eUFHaNfI4a68Bb8UIBxvNh2Ml2 3sLcg74LbRoa9pS3O914rrl49q2PP50Fr0Si6vkJnimzIYo7XII8I5JKpHNvgfJRU0oF Ve3INcLSP5fNiJNvP3YfEYCRlOBNQRez6tSzpuNlBxyIsxT+hHHdwhwGPChKrAUdT6mp mnIIlBp7ztsYA2P2CV6gpH+x0s9rdAapAeaaZ08Si0OjEPJmAHJP77Du+3nbefmySO0R Q/mIsAMoi5mvWANA9MDa1BGQUq9kF/F4hZfSk+HDL1Sd6aqsE+o7R+p+FcgKr9Nwv7fJ sytg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678816478; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=c9/Ns1wAe0xLo75BJDdJ8nUa6/ByXxlG+blXI27RIAc=; b=wsC1QI83Bsrnmj53HDIw7r2gj0Foc4DMpUr9dHAYcb3boglsM4J/Qc8EL3yAgmji07 qHrTJXGJEzAc1jnsBvWgDbir2R7Q/b/3V1FZd5ZeoSzTyvW297dpwZbibLjd1yyzg6XW H8mMtydfyPG8L6loKASUYk/K8wZQaSPNwNnJx3BKmVHVyjInQps6AGRLLh2ejFeqZCfb ejtetBXuAHizsEM3WddXI/o3hGKuJqLq9T1P6f7E9XM2NaspolVyhVni+rtbMgMcUxNj sDkK5szDN5MFay16mAhNJuInKZxSwOLevnsM4d5t5Ei0I47rvKZRVLj/FFzermVAoCl1 KWKw== X-Gm-Message-State: AO0yUKURwAFVvF0D5v5q6fXRdUWaYcyo4sL7LMx2TiDiNVdoj243dCOt RTj9kBTOqC6K2ofN9ve2Nb1ynQ== X-Google-Smtp-Source: AK7set/CyMGaC4IVwD5fp9B4s3nu5Hn99wqiLboM9F7qPB9PWqMkcUGZ/b3MDdNa0lhKDQxQcTqVPg== X-Received: by 2002:a92:da44:0:b0:317:9768:fbc0 with SMTP id p4-20020a92da44000000b003179768fbc0mr2687908ilq.19.1678816477979; Tue, 14 Mar 2023 10:54:37 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id q1-20020a056e02096100b00314201bcbdfsm995846ilt.3.2023.03.14.10.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 10:54:37 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 4F442800121; Tue, 14 Mar 2023 12:54:36 -0500 (CDT) Date: Tue, 14 Mar 2023 12:54:35 -0500 From: Justin Pryzby To: James Robertson Cc: pgsql-performance@postgresql.org Subject: Re: multicolumn partitioning help Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Mar 12, 2023 at 01:59:32PM -0400, James Robertson wrote: > Hey folks, > I am having issues with multicolumn partitioning. For reference I am using > the following link as my guide: > https://www.postgresql.org/docs/devel/sql-createtable.html > > Reading the documentation: "When creating a range partition, the lower > bound specified with FROM is an inclusive bound, whereas the upper bound > specified with TO is an exclusive bound". > > However I can't insert any of the following after the first one, because it > says it overlaps. Do I need to do anything different when defining > multi-column partitions? The bounds are compared like rows: When creating a range partition, the lower bound specified with FROM is an inclusive bound, whereas the upper bound specified with TO is an exclusive bound. That is, the values specified in the FROM list are valid values of the corresponding partition key columns for this partition, whereas those in the TO list are not. Note that this statement must be understood according to the rules of row-wise comparison (Section 9.24.5). For example, given PARTITION BY RANGE (x,y), a partition bound FROM (1, 2) TO (3, 4) allows x=1 with any y>=2, x=2 with any non-null y, and x=3 with any y<4. https://www.postgresql.org/docs/current/functions-comparisons.html#ROW-WISE-COMPARISON > This works: > CREATE TABLE humans_1968_0 PARTITION OF humans FOR VALUES FROM (1968, '0') > TO (1969, '1'); This table is everything from 1968 (starting with '0') to 1969 > These fail: > CREATE TABLE humans_1968_1 PARTITION OF humans FOR VALUES FROM (1968, '1') > TO (1969, '2'); Which is why these are overlapping. > CREATE TABLE humans_1969_1 PARTITION OF humans FOR VALUES FROM (1969, '1') > TO (1970, '2'); This one doesn't fail, but it "occupies" / subjugates all of 1969 starting with 1. -- Justin