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 1kJNq0-00032R-Cd for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Sep 2020 21:22:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kJNpy-0001jF-KH for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Sep 2020 21:22:34 +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 1kJNpx-0001j7-RC for pgsql-bugs@lists.postgresql.org; Fri, 18 Sep 2020 21:22:33 +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 1kJNpv-0001Qu-Lc for pgsql-bugs@lists.postgresql.org; Fri, 18 Sep 2020 21:22:32 +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 08ILMUOR544019; Fri, 18 Sep 2020 17:22:30 -0400 From: Tom Lane To: XINYULIU@UMICH.EDU cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16624: Query Optimizer - Performance bug related to predicate simplification In-reply-to: <16624-1375434d97659203@postgresql.org> References: <16624-1375434d97659203@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Fri, 18 Sep 2020 16:14:17 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <544017.1600464150.1@sss.pgh.pa.us> Date: Fri, 18 Sep 2020 17:22:30 -0400 Message-ID: <544018.1600464150@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > We are developing a tool for automatically finding performance bugs in > PostgreSQL. Our key insight is that given a pair of semantic equivalent > queries, a robust DBMS should return the same result within a similar > execution time. Significant time difference suggests a potential performance > bug in the DBMS. Unfortunately, that's a viewpoint that is not going to win you a lot of converts. > First query: > SELECT "ps_suppkey" > FROM "partsupp" > WHERE "ps_partkey" = 1486; > Second query: > SELECT "ps_suppkey" > FROM "partsupp" > WHERE "ps_partkey" + 1486 = 2972; Sure, in theory the optimizer could rearrange that to "WHERE ps_partkey = 2972 - 1486" and thus still have an indexable condition. In practice, we have essentially no interest in doing so. It would require vastly more semantic knowledge than the optimizer has got, and looking for such cases would consume lots of planner cycles that would be better spent elsewhere. If you want to complain that that makes Postgres' optimizer "not robust", you're entitled to that opinion. But it's very unlikely to change in the foreseeable future. We expect that if a user cares about the performance of a particular query, they'll be willing to write it in a form that the optimizer can deal with. regards, tom lane