Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tAyiQ-001Fdq-HZ for pgsql-performance@arkaria.postgresql.org; Tue, 12 Nov 2024 21:46:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tAyiN-009ikw-4H for pgsql-performance@arkaria.postgresql.org; Tue, 12 Nov 2024 21:46:23 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tAyiL-009iko-Ur for pgsql-performance@lists.postgresql.org; Tue, 12 Nov 2024 21:46:23 +0000 Received: from relay9-d.mail.gandi.net ([217.70.183.199]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tAyiI-001bZc-BP for pgsql-performance@lists.postgresql.org; Tue, 12 Nov 2024 21:46:21 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 9BCAAFF804; Tue, 12 Nov 2024 21:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1731447976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QZH90zFGCo7HqrwAyZ4NRDbEs5m373o6mQao7rXmSvw=; b=ZfklPlaZHCYEn+ecaVBEE517VqhKPclm3b2YyzfRPF1u8LkVZwwL5Txmb+K1Prt6zotuLD UQ6lTdE0EDHA6RlwqmBOERk5YZxMEi3eUh36a/isD9vt4ncRR2XWgAjA4erb8kTaC/3sIU GIZKTDHS4kpB3lsUyCzlGQmgXiENTJQRPfl3kDm70nfPiQiZGRbpnJTTDN4OQrZs1DvRO+ Zfpi+Y6tqAVAUo++EzWEQrTnTyoNNnVrEXNeqjx1GWeoK31wh7JbT94OOT9zPDHPG0DQZO fg3Fxdi+OtYB14eLv3S7JCqNjDAvA0tM4W6mHVVLp1gYCBRaV6F9C10wgF3Y1Q== Message-ID: Date: Tue, 12 Nov 2024 22:46:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: tds_fdw : Severe performance degradation from postgresql 10.23 to 16.4 To: Tom Lane , Achilleas Mantzios Cc: pgsql-performance@lists.postgresql.org, "P.Groidis" References: <75b1aafc-bf5f-48fe-a495-fba11d8f0b05@vondra.me> <9640ce5b-3128-4c3c-b901-65747bc67b83@cloud.gatewaynet.com> <6797bc15-486b-48c3-9e89-cf85ae9a4043@vondra.me> <14f7d64f-d864-4429-9cf2-7ef92d6a90fb@vondra.me> <50da382b-1d47-4332-9279-8af0996f8088@cloud.gatewaynet.com> <1224347.1731440256@sss.pgh.pa.us> Content-Language: en-US From: Tomas Vondra In-Reply-To: <1224347.1731440256@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-GND-Sasl: tomas@vondra.me List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/12/24 20:37, Tom Lane wrote: > Achilleas Mantzios writes: >> Our sysadm created the system debian Debian GNU/Linux 12 (bookworm)with >> postgres as user 1000. Now at some point we realized that whenever we >> run a pgsql cluster with another user (I found that after spending two >> good days testing), the above query runs in about 1 second. With user >> postgres 1000 in 30 seconds. As you saw the perf output are completely >> different. > > Don't recall details offhand, but in some situations where the calling > SQL user doesn't have permissions to read particular columns, the > planner will not consult statistics for those columns. That can lead > to a different, less optimal plan being used. Maybe something like > that is happening here? > I don't know, the query is pretty trivial, and the estimates seemed exactly the same in both cases. And it shouldn't affect how the query gets planned on the MSSQL side. But this seems really strange: Planning Time: 14029.724 ms ... Execution Time: 15102.803 ms It's not about the execution, it's about the planning. I have no idea why should the planning take this long, except maybe for waiting for a lock, or something like that. But that's not really consistent with the profile ... it's weird. I'm not familiar with tds_fdw, but I see there are a bunch of table options [1] that might affect this, namely: * use_remote_estimate * local_tuple_estimate * row_estimate_method (defaults to 'execute') Are you sure these are set to the same value on both machines? Wild random guesses: 1) Could you try running the query with jit=off? 2) Did you run ANALYZE on the foreign table? Could matter when not using remote estimates (use_remote_estimate=false). 3) Could it be some sort of memory pressure/swapping? But that would look different in the profile, AFAIK. regards [1] https://github.com/tds-fdw/tds_fdw/blob/master/ForeignTableCreation.md -- Tomas Vondra