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 1lyFNb-0005ll-6C for pgsql-general@arkaria.postgresql.org; Tue, 29 Jun 2021 15:10:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lyFNa-0006h6-20 for pgsql-general@arkaria.postgresql.org; Tue, 29 Jun 2021 15:10:26 +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 1lyFNZ-0006gy-PU for pgsql-general@lists.postgresql.org; Tue, 29 Jun 2021 15:10:25 +0000 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lyFNY-0000g3-3n for pgsql-general@lists.postgresql.org; Tue, 29 Jun 2021 15:10:25 +0000 Received: by mail-oi1-x22d.google.com with SMTP id w127so26608253oig.12 for ; Tue, 29 Jun 2021 08:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=DE6aBcNiPs9PYoBuhqoNr5CPVIvuPNumsm66MZGuj+8=; b=LYFZ9DPnPevCJVAY5d7VdEJuQ/Kx2GlvupJBARlOUj3/zKg/CAS7hN8XE9GWJehvUT jR9Y9AcFBSTzOkfTm7wDyBPceWlORIF4B01NAkMaBNQYz3JudriME/+0kzRMl63aFNPa /nzyTCF9tTgiuCZOzx6gU1VmpgehrGb/F4ExFDjVd1LcmIXuihxxYjoSl7PGl6RJTIt/ 0rPhVy7cj2tgsnRoTCXuN7blpwn/Nlu1qlLMhGW76sb3h62ypIx8sGvmWhd6WGSTshiU puj8yGffdy0hHaSQ1Tw3Z3xjfm7bFe4ReMw2cb9W/D8LsK4yI3sTFneSdi53H8GaOLvB 34pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=DE6aBcNiPs9PYoBuhqoNr5CPVIvuPNumsm66MZGuj+8=; b=nVBw9gXvTd2QJqjm9y/KeAYD6nmvT4Sih+54X74bN4oWhAxA0N5jfzH/VUJDcHNcp0 HTuvCbqB6DL+pjjwobBnTg15Mwueux2Po7kTjsK/xUkP/Tk1etiCQZWGf71B4x7D9LrM ZAT/aNxROOE9O4xw30+OOUW+zHGXy1BvAT9oKoHsJmJALN+llyPh1fZvA6C+pFlEJMqQ xhLk7lLymWG6uOCIOAwde/JvYxqkvkyStKw+6ngd0ojByljaECXIRxfBjg1aVvB/HQDt NA9OYBNUk7cOkEw+Vco7lbENvnncXgZ91zRFdgSCMNSrhEGIZrRxaEH8sy+YAXqD4OGt itQg== X-Gm-Message-State: AOAM531DlwyGz664Ns8F1moSmeD2EF4GOtDO0ukI7OR1G+5+ksIo8M8Q TyYxKKM8+XXmIZNxhtfgm9XjGcd55oAJXQ== X-Google-Smtp-Source: ABdhPJyhAZGL1tKhSZkeHqAG8ucHoQiJfrC2RFJdQk8AQ6Ob/nn6iRAAiQRxIt6QJA4XFiQBBRiACw== X-Received: by 2002:a05:6808:f10:: with SMTP id m16mr25059949oiw.72.1624979422354; Tue, 29 Jun 2021 08:10:22 -0700 (PDT) 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 w8sm757282ott.56.2021.06.29.08.10.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 29 Jun 2021 08:10:21 -0700 (PDT) To: PostgreSQL General From: Ron Subject: Do table-level CHECK constraints affect the query optimizer? Message-ID: <5f718120-a286-71ca-3d31-7bad70f0194e@gmail.com> Date: Tue, 29 Jun 2021 10:10:21 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 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: Archived-At: Precedence: bulk Postgresql 12.5 I've got a big (about 50M rows, but 1.4TB because of xml attachments) partitioned table full of data that we're seeing sequential scans on, even though there are supporting indices. Will adding CHECK constraints on the children, which match the partition ranges influence the query optimizer? (We'd try this on the test system -- which has just a few weeks less data than prod -- but queries on it use the proper indices, and thus perform as expected.  Both "test" and "prod" have identical IO systems, and postgresql.conf files.) Partitions: request_xml_p2015_07 FOR VALUES FROM ('2015-07-01 00:00:00') TO ('2015-08-01 00:00:00'),             request_xml_p2015_08 FOR VALUES FROM ('2015-08-01 00:00:00') TO ('2015-09-01 00:00:00'),             request_xml_p2015_09 FOR VALUES FROM ('2015-09-01 00:00:00') TO ('2015-10-01 00:00:00'),             request_xml_p2015_10 FOR VALUES FROM ('2015-10-01 00:00:00') TO ('2015-11-01 00:00:00'), [snip]             request_xml_p2021_06 FOR VALUES FROM ('2021-06-01 00:00:00') TO ('2021-07-01 00:00:00'),             request_xml_p2021_07 FOR VALUES FROM ('2021-07-01 00:00:00') TO ('2021-08-01 00:00:00'),             request_xml_p2021_08 FOR VALUES FROM ('2021-08-01 00:00:00') TO ('2021-09-01 00:00:00') -- Angular momentum makes the world go 'round.