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 1oOWGz-0000fG-44 for pgsql-general@arkaria.postgresql.org; Thu, 18 Aug 2022 03:32:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oOWGy-0002EM-0E for pgsql-general@arkaria.postgresql.org; Thu, 18 Aug 2022 03:32:44 +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 1oOWGx-0002ED-M7 for pgsql-general@lists.postgresql.org; Thu, 18 Aug 2022 03:32:43 +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 1oOWGv-0003o0-7H for pgsql-general@lists.postgresql.org; Thu, 18 Aug 2022 03:32:42 +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 27I3WM1r2228589; Wed, 17 Aug 2022 23:32:22 -0400 From: Tom Lane To: gzh cc: pgsql-general@lists.postgresql.org Subject: Re: Different execution plan between PostgreSQL 8.2 and 12.5 In-reply-to: <6614e60.204d.182aee5aff0.Coremail.gzhcoder@126.com> References: <6614e60.204d.182aee5aff0.Coremail.gzhcoder@126.com> Comments: In-reply-to gzh message dated "Thu, 18 Aug 2022 11:01:04 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2228587.1660793542.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 17 Aug 2022 23:32:22 -0400 Message-ID: <2228588.1660793542@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.2 and PostgreSQL 12.5, it returns di= fferent execution plan. 8.2 is ... well, not stone age maybe, but pretty durn ancient. You really ought to update a bit more often than that. (And maybe pay more attention to staying up to date with minor releases? Whatever was your reasoning for choosing 12.5, when the latest 12.x release is 12.12?) The 12.5 plan looks like it thinks that the join condition is not hashable --- and probably not mergeable as well, else it would have done a mergejoin. This is odd if we assume that the lower() outputs are just text. But you haven't said anything about the data types involved, nor what locale setting you're using, nor what nondefault settings or extensions you might be using, so speculation about the cause would just be speculation. There is some advice here about how to ask this sort of question in a way that would obtain useful answers: https://wiki.postgresql.org/wiki/Slow_Query_Questions regards, tom lane