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 1ohYl6-0003JE-0E for pgsql-general@arkaria.postgresql.org; Sun, 09 Oct 2022 16:02: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 1ohYl3-0001rK-3g for pgsql-general@arkaria.postgresql.org; Sun, 09 Oct 2022 16:02:29 +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 1ohYl2-0001rA-Pq for pgsql-general@lists.postgresql.org; Sun, 09 Oct 2022 16:02:28 +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 1ohYkz-0007i8-FE for pgsql-general@lists.postgresql.org; Sun, 09 Oct 2022 16:02:28 +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 299G29db3810465; Sun, 9 Oct 2022 12:02:10 -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: <23fe7e4b.5866.183bc03584f.Coremail.gzhcoder@126.com> References: <23fe7e4b.5866.183bc03584f.Coremail.gzhcoder@126.com> Comments: In-reply-to gzh message dated "Sun, 09 Oct 2022 17:11:19 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3810463.1665331329.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 09 Oct 2022 12:02:09 -0400 Message-ID: <3810464.1665331329@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk gzh writes: > I run following sql in PostgreSQL 8.4 and PostgreSQL 12.11, it returns d= ifferent execution plan. Have you done an ANALYZE in the new database? The rowcount estimates seem a lot different, leading me to guess that the newer installation doesn't have good statistics yet. regards, tom lane