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 1lIwPO-0000Vy-Ix for pgsql-performance@arkaria.postgresql.org; Sun, 07 Mar 2021 16:37:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lIwPN-0004S0-De for pgsql-performance@arkaria.postgresql.org; Sun, 07 Mar 2021 16:37:33 +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 1lIwPN-0004Rt-6k for pgsql-performance@lists.postgresql.org; Sun, 07 Mar 2021 16:37:33 +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 1lIwPG-0006nY-Dz for pgsql-performance@lists.postgresql.org; Sun, 07 Mar 2021 16:37: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 127GbMpl1623346; Sun, 7 Mar 2021 11:37:22 -0500 From: Tom Lane To: Julien Rouhaud cc: Michel SALAIS , "'Francesco De Angelis'" , pgsql-performance@lists.postgresql.org Subject: Re: different execution time for the same query (and same DB status) In-reply-to: <20210307150818.hiqv26pmrovi3ced@nol> References: <00ce01d71361$4dd83750$e988a5f0$@msym.fr> <20210307150818.hiqv26pmrovi3ced@nol> Comments: In-reply-to Julien Rouhaud message dated "Sun, 07 Mar 2021 23:08:18 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1623344.1615135042.1@sss.pgh.pa.us> Date: Sun, 07 Mar 2021 11:37:22 -0500 Message-ID: <1623345.1615135042@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Julien Rouhaud writes: > +1, and more generally please follow > https://wiki.postgresql.org/wiki/Slow_Query_Questions. Yeah. FWIW, the most likely explanation for the change in behavior is that by the time of the second execution, auto-analyze has managed to update the table's statistics, and that for some reason that's changing the plan for the worse. But then the next question is why and what can be done about that. See the wiki entry for info that would be helpful in diagnosing this. regards, tom lane