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 1pcTpN-00053E-7h for pgsql-general@arkaria.postgresql.org; Wed, 15 Mar 2023 16:18:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pcTpL-0006XV-O5 for pgsql-general@arkaria.postgresql.org; Wed, 15 Mar 2023 16:18:11 +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 1pcTpL-0006XM-Di for pgsql-general@lists.postgresql.org; Wed, 15 Mar 2023 16:18:11 +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 1pcTpJ-0007NG-7m for pgsql-general@postgresql.org; Wed, 15 Mar 2023 16:18:10 +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 32FGI7JQ3340033; Wed, 15 Mar 2023 12:18:07 -0400 From: Tom Lane To: Arthur Ramsey cc: pgsql-general@postgresql.org Subject: Re: Table scan on 15.2 In-reply-to: References: <3337979.1678896202@sss.pgh.pa.us> Comments: In-reply-to Arthur Ramsey message dated "Wed, 15 Mar 2023 11:10:59 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3340031.1678897087.1@sss.pgh.pa.us> Date: Wed, 15 Mar 2023 12:18:07 -0400 Message-ID: <3340032.1678897087@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Arthur Ramsey writes: > After a restart and seq disabled for session with no other load (same for > plan with seq enabled). > Bitmap Heap Scan on t_user user0_ (cost=19567.17..58623.03 rows=800678 > width=761) (actual time=0.370..0.702 rows=36 loops=1) So the problem is that awful rowcount estimate. (I see that v12's estimate wasn't exactly spot-on either, but it wasn't so bad as to push the planner to use a seqscan.) Hard to form an opinion on the cause of that when you've redacted all the details of the index condition, unfortunately. It could be that increasing the table's statistics target and re-ANALYZEing would help. regards, tom lane