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 1l86KK-00020S-20 for pgsql-admin@arkaria.postgresql.org; Fri, 05 Feb 2021 18:59:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l86KI-0006xH-VP for pgsql-admin@arkaria.postgresql.org; Fri, 05 Feb 2021 18:59:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l86KI-0006xA-Lg for pgsql-admin@lists.postgresql.org; Fri, 05 Feb 2021 18:59:30 +0000 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l86KF-0003fr-OC for pgsql-admin@lists.postgresql.org; Fri, 05 Feb 2021 18:59:29 +0000 Received: by mail-ot1-x333.google.com with SMTP id f6so7876986ots.9 for ; Fri, 05 Feb 2021 10:59:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=tRKe4gjq0HAa9z0V+a3/khZ+BqHfIRVSWiJOGW61ItE=; b=qcsr0msifNn4tP3RBpqzz3Hf4D/kGKYAOE+cumhbh8ATOFH+dvD97KOt8nOzwqA+e8 Rik6O1OArmtogxtzrQZRep3ol1OincgqTyykI9KNJbnrpoeC3QKMW+KFtjd3EFzIXeQV VOUAHPBhAUjoSdXSms1YiU7DF6Tg8etUb4rVSK8sIwU3mXqw5g/3heQuQlKTJyNI4wh1 4l+/ZG0JHrwJ/3UfrOEgnZXRDu6r6vQyqo8dLVzgu7v3UWHcU1MdRQz9ROc0SI2Uu9EL S6AZ2tPfxHJWdytl9W0Zxb7DIpWw758YCspJemdsUXfPwCTGWR9S50Bx+lc0x8cMbzNY uJ3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=tRKe4gjq0HAa9z0V+a3/khZ+BqHfIRVSWiJOGW61ItE=; b=DNwTLEgt6Tb+GlldmFoyj9XMTKsLAtxR8cC4Tcl2pn4XDAxqthFDw02+VHkk1zlcX7 Lv2lfvGJZ5U3jRRYYayylGe5wa2kxdPoq/TWdFshuCxLEAgW8OeLBj3vi9HiU6aSA1bw kWshZsK3sBzQ6Tc5Aa+9X3A4HEk3jDNMOs9/DIqfNyqFMKkY1+nBHXKdiBr/Uc3lq9lh EiuUDrBAWoo6yoM7euBjPWqZPz1vmvi0DfKeH6TQF6Xf8ljYVV4vJp3DgSA46LCFc8NP yGKGysLhMMpbSDdgAuGGmVZ5AkGfRWo6UUhASD/EaFTCNAgg1pj41JJrQyZJrX/0LBdZ Fm5g== X-Gm-Message-State: AOAM53254KA5VQpQHzXyLmmw+znkKmWDUAJbe6HsM2lHpgqu3YnKpQtW kyRVxQHZ71Lb8/H5dubtVLnvIxA7qKY= X-Google-Smtp-Source: ABdhPJzqxNmaJjjPKtkNJfYuq/IFZGOPOkjAa5UUPlgpX2sIKS1gxHG5PtQwvBCv+5nGtC2fXiKBVQ== X-Received: by 2002:a9d:74cb:: with SMTP id a11mr4460084otl.154.1612551565648; Fri, 05 Feb 2021 10:59:25 -0800 (PST) Received: from [192.168.88.10] (ip174-67-141-204.no.no.cox.net. [174.67.141.204]) by smtp.googlemail.com with ESMTPSA id z20sm1951939oth.55.2021.02.05.10.59.24 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Feb 2021 10:59:24 -0800 (PST) Subject: Re: Partitioning Tables To: pgsql-admin@lists.postgresql.org References: <248F0103-EA30-4536-963B-73BD7477AF08@illinois.edu> From: Ron Message-ID: <48402931-ad7a-7cf8-b30a-4d1a86408927@gmail.com> Date: Fri, 5 Feb 2021 12:59:24 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2/5/21 12:42 PM, Scott Ribe wrote: >> On Feb 5, 2021, at 11:27 AM, Campbell, Lance wrote: >> >> So if I do a query like the below it would ideally pull from partition group_member_a rather than group_member_other. However, how would PostgreSQL know on insert a group_member into the proper partition? >> >> Select group_member.* from group, group_member WHERE group.type=’A’ and group.id=group_member.user=’bob smith’; > When you define the partition, you declare what values go into it. With PG 12, you can insert into the parent and the row will get redirected into the right place. Some older versions (I don't remember how old) required you to insert into the right table, or some voodoo with rewrite rules or triggers. > > In other words, smarts about which partitions to scan in your example pre-dates smarts about inserting. > > I don't remember for sure, but I think maybe PG 13 adds the feature where if you update the group type, the row gets moved. Prior, you'd have to delete and re-insert. Someone correct me? I don't know about v13, but v12 (and below) error on updating the partition key.  (That's a common limitation which helps the optimizer /know/ what's in a partition.) -- Angular momentum makes the world go 'round.