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 1ohx3m-0001t8-JX for pgsql-general@arkaria.postgresql.org; Mon, 10 Oct 2022 17:59:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ohx3l-0006Tz-Fy for pgsql-general@arkaria.postgresql.org; Mon, 10 Oct 2022 17:59:25 +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 1ohx3j-0006Tq-Th for pgsql-general@lists.postgresql.org; Mon, 10 Oct 2022 17:59:25 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ohx3f-0008H2-Jv for pgsql-general@lists.postgresql.org; Mon, 10 Oct 2022 17:59:23 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id CA6945C0185; Mon, 10 Oct 2022 13:59:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 10 Oct 2022 13:59:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1665424754; x= 1665511154; bh=4CMMRnbXNfNmK+ERPV7J0YavH6hSP5+8MFFJucPrC4w=; b=i EOa91wh19V+LlzDCbgeLZ0KgrP9BmsuffPdxXogRmGFXp5XbV98n0oVz4jYxT/ln C4lv9w0aEyIMNQW+YpkElu0CCjK5bTQ7GjgGUvB/SJVA1z9dxkn31iZRiFsVl0qE 1POiw0Dq9zxckXwlrMBiei7ItzmqOzjvwO/OCDmOlPjq/zRSqhtAkwYAJWc2eDkl 4Px858s22pkvhU87GMGcvIJGyLZGyM7/cn7MggadKla0Md6rrRuYWg2tRP2RCDXr CiP1Ob2HeXcAY+E+RNYh8UoaJLnuXtSBe8utU+BV6o29fTFos4yrsrGjViWrwyVh 9AiG5zT/ZRAlJlVNrDYkw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1665424754; x= 1665511154; bh=4CMMRnbXNfNmK+ERPV7J0YavH6hSP5+8MFFJucPrC4w=; b=e hHWUjdxNN07VimoLFwXI0oWDtUr+nqIS/dOQteFMiv+I1UZwNw+L7Ho7e2PpUvDm BOgvdsrv0gCyZS+MJH7CqGndSR8EHh9cBH5GnJAWqVAKN/GyhPBfS5WJhJ25+GPo Aw29HgeA4F8PnSloRnjjvgRvKfxL//TbRUUFaGzbR2BKhxgWct/RGXoFu1hQ6t25 xRYWllMLYsx6fdoLSNEarvn8VgdnzmCE/QN0tRnz8/0mEsq2hHXWosPYh2j/Az5w 02sh4XMYzFiecS5vmKZP10xuRvbrU0dQRMb8ynAZL4aYIoOOHMpMd2oThru7lI4K NBxzt7YGDYeC9qRcXvBOA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeejgedguddugecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfevfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegu rhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrd gtohhmqeenucggtffrrghtthgvrhhnpeeghfehheetlefgffekudekleekheffiedutddt gfejffdugfegfedvjeejfeeuudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Oct 2022 13:59:13 -0400 (EDT) Subject: Re: Same query, same data different plan To: Kostas Papadopoulos , Tom Lane Cc: Pavel Stehule , Daevor The Devoted , pgsql-general@lists.postgresql.org, Julien Rouhaud References: <20b3e283-3107-cd18-6e7f-90ed58e7ddf8@methodosit.com.cy> <8da58bc7-a01a-0168-3d49-062258ac82ec@methodosit.com.cy> <20221010131217.7kzur6b63cl2we7y@jrouhaud> <4073393.1665413623@sss.pgh.pa.us> <37fcbc79-c9c9-979d-f7ad-43771e7923c5@methodosit.com.cy> From: Adrian Klaver Message-ID: Date: Mon, 10 Oct 2022 10:59:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <37fcbc79-c9c9-979d-f7ad-43771e7923c5@methodosit.com.cy> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/10/22 8:12 AM, Kostas Papadopoulos wrote: > > On 10/10/2022 17:53, Tom Lane wrote: >> Kostas Papadopoulos writes: >>> I cannot see how it can be configuration since the two databases are >>> in the same >>> Postgres instance. >> >> There is such a thing as ALTER DATABASE ... SET to install different >> settings at the per-database level. > > I understand, but I created the databases to be the same. Our original > problem was that developers' workstations (Debian and Windows) were > running a specific query different from a test db (Ubuntu). After > eliminating everything we thought of (data, versions, configurations, > OS, etc) we ended up with the scenario I described here. So there is more to the story. Information needed: 1) The query and its EXPLAIN ANALYZE for both slow/fast cases. 2) Postgres version. 3) What database are the developers workstation pointing at? 4) What is the test db and is it the same as 3)? 5) What clients are you using to run the query? >> >> In general, the answer to your question is that the databases are >> *not* identical.  You just haven't figured out how yet.  I'm wondering >> if it has something to do with the dump/reload having compacted out >> bloat in the tables or indexes, causing cost estimates to change. > > I will look into that and a couple of other ideas I got from this list. > >> >>             regards, tom lane > > Thanks > kostas > > -- Adrian Klaver adrian.klaver@aklaver.com