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 1ohio1-0001Dc-5b for pgsql-general@arkaria.postgresql.org; Mon, 10 Oct 2022 02:46: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 1ohinz-0001bd-Tf for pgsql-general@arkaria.postgresql.org; Mon, 10 Oct 2022 02:46:11 +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 1ohinz-0001bU-J9 for pgsql-general@lists.postgresql.org; Mon, 10 Oct 2022 02:46:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ohinw-0005oi-6A for pgsql-general@lists.postgresql.org; Mon, 10 Oct 2022 02:46: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 29A2jsbT3977623; Sun, 9 Oct 2022 22:45:54 -0400 From: Tom Lane To: gzh cc: pgsql-general@lists.postgresql.org Subject: Re: Different execution plan between PostgreSQL 8.4 and 12.11 In-reply-to: <3bb0d13f.1d81.183bfbcf7e4.Coremail.gzhcoder@126.com> References: <23fe7e4b.5866.183bc03584f.Coremail.gzhcoder@126.com> <3810464.1665331329@sss.pgh.pa.us> <3bb0d13f.1d81.183bfbcf7e4.Coremail.gzhcoder@126.com> Comments: In-reply-to gzh message dated "Mon, 10 Oct 2022 10:32:56 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3977621.1665369954.1@sss.pgh.pa.us> Date: Sun, 09 Oct 2022 22:45:54 -0400 Message-ID: <3977622.1665369954@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk gzh writes: > I've run analyze(not vacuum analyze), but it doesn't seem to work. When you're asking for help, please don't give us vague statements like "doesn't seem to work". Did the plan (including rowcount estimates) change at all? To what? How far off is that rowcount estimate, anyway --- that is, how many rows actually have cseid = 94? If the estimate is far off, then increasing the table's statistics target might help. Another thing that would be worth checking is whether "set enable_seqscan = off" prods it to choose the plan you want. If not, then there's something else going on besides poor estimates. regards, tom lane