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 1lyGpC-0008El-0k for pgsql-general@arkaria.postgresql.org; Tue, 29 Jun 2021 16:43:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lyGpA-0000OQ-Tk for pgsql-general@arkaria.postgresql.org; Tue, 29 Jun 2021 16:43:00 +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 1lyGpA-0000OH-L4 for pgsql-general@lists.postgresql.org; Tue, 29 Jun 2021 16:43:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lyGp8-0007SJ-Eh for pgsql-general@lists.postgresql.org; Tue, 29 Jun 2021 16:42:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 15TGgupW449567; Tue, 29 Jun 2021 12:42:56 -0400 From: Tom Lane To: Ron cc: PostgreSQL General Subject: Re: Do table-level CHECK constraints affect the query optimizer? In-reply-to: <374d530d-ec98-f1ea-8d41-21e661aa9ab4@gmail.com> References: <5f718120-a286-71ca-3d31-7bad70f0194e@gmail.com> <374d530d-ec98-f1ea-8d41-21e661aa9ab4@gmail.com> Comments: In-reply-to Ron message dated "Tue, 29 Jun 2021 11:13:03 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <449565.1624984976.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 29 Jun 2021 12:42:56 -0400 Message-ID: <449566.1624984976@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ron writes: > On 6/29/21 10:41 AM, Michael Lewis wrote: >> What's an example query that uses indexes on test and does not on live? > SELECT COUNT(*) FROM sep_info_report_extract; > On prod, there's a list of "Parallel Seq Scan on xxxx_partname" records = in = > the EXPLAIN output, while the test system has a list of "Parallel Index = Only = > Scan using ..._idx" records. It'd be worth checking pg_class.relallvisible page counts for the partitions on both systems. If an IOS is possible, the main thing that might push the planner to do a seqscan instead is if it thinks that too little of the table is all-visible, which would tend to inflate the index-only scan towards the same cost as a regular index scan (which'll almost always be considered slower than seqscan). If there's a significant difference in relallvisible fractions, that would point to something different in your VACUUM housekeeping on the two systems. regards, tom lane