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 1ti2Qy-00ANms-KL for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Feb 2025 02:25:04 +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 1ti2Qw-002sfV-LD for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Feb 2025 02:25:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ti2P0-002nVb-ED for pgsql-hackers@lists.postgresql.org; Wed, 12 Feb 2025 02:23:03 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ti2Oz-000KR4-10 for pgsql-hackers@lists.postgresql.org; Wed, 12 Feb 2025 02:23:02 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-21f4a4fbb35so5487425ad.0 for ; Tue, 11 Feb 2025 18:23:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739326980; x=1739931780; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=RIqnSMC4lMSsZdG3ZzQmEIRgJYx/TFx7Xj9F85hwDPA=; b=AlYVqkd6+u190vZbqGfakiuIQ3S3UuN1JHD6ZfQ5VfT+8rRhhITLzMkZFnW2g8YDqC VDqDO6zL+ZItkk5LjzwX59qEqDBflu+s7KweKpjc+RM8jS23cTJyXeROfoPFVYwQAfvK sOgHKGc9mXICnNquzxJprfC8IAod30wj0iFTyb5BxdmKngYN6FqlKLrCZ5R7qvZvZP8+ mEDMG2ooD5A6+9AsKdSHuE+AyWO0Xqdp9M2Eq4YIg4MhHpttDP84+Pf7U6vBcNgG0rxH FXKV08F6ScTl1RQNf8JnJ2csCtGn6NpcmBxzYcKipwI2pV/kRfbDb5CgXkFKKprIiLpc gaaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739326980; x=1739931780; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=RIqnSMC4lMSsZdG3ZzQmEIRgJYx/TFx7Xj9F85hwDPA=; b=vAM6Stmt6CGcTIhpjg9hjwXz//5g6/ESheaFmkpCcw+KWd+oR8EAQlJsZNDrxaiObw o2XfaCjWF4AL97qwYYaiPK5+ocWd6x8QLaGppzHe4wk1yTgsCEcv9YmfdKRA2aZdCK6w Yv7xjLXdGNMkZvZvQdANJiISUkGio+n0VGA9mPBA75RG1Lz/Yv2ul6DzlbiKa8umvdWL VeUIp7UlFo98FJ81DL5XnHNL7E3sU5ep9rYQgQCd2+H585uCwL3G8MmtA1HcBpTRje9B 4rOrO54LZry5utWN6RtG0yM01wLW9WNLT3DDHRDa142TDRppv5leyEHs3pKEMGvLPZIF HLXQ== X-Forwarded-Encrypted: i=1; AJvYcCWw2o0XRpWPrgjjwsGf1GuMolcuV/T90pHXUoGj2M+U3vdCzOTTzb0rmnjuLO8X3XMsN/3LeJmt0yBphlze@lists.postgresql.org X-Gm-Message-State: AOJu0YxEJMV4/HigfGFHCHFIGDiWhDeExSqsTtM0Kq2zTiP8X/pfxASl 32CNW9VVy+qsOX+NfnpimFuqGFQIqFrxnqJOhFzgqPRqwO7VLydz X-Gm-Gg: ASbGncu7jvdfjtIpWxLCvZTWYLe9uneEe7Rau1XMx9vuzOyHasQ08debI8vku71xKgE Qz1HXGO7nCyT6A6fbFhD7l88QkKNAdGH0D0s1mzUF783waHAHDQh2iOsicVCrZ3P8wHuqcuQkWp aWInFJVwmtrxpi2LCUu9iXChrzTRT1QnTOk78xbnEzAoxRphJ9tD+Htyid6IIZPwSDxHJJFbIXN rdlDBoh0rWAaP0H4EP8vFWZwd9mQ6u4MLi/11d2DzCsAAARjH97+DtoQ6b1SBz10n5AVC4Xd2bU x1yR4ao= X-Google-Smtp-Source: AGHT+IE1awT3K8i5I+LRE1gJLx/JOM0cFmKi1yb81gCQV4l+OXq5qT2anRec5aujbi5NDkZBLH3AEQ== X-Received: by 2002:a17:903:247:b0:215:44fe:163d with SMTP id d9443c01a7336-220bc262a14mr23141525ad.17.1739326980176; Tue, 11 Feb 2025 18:23:00 -0800 (PST) Received: from jrouhaud ([115.43.41.38]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21f365616dcsm102986105ad.101.2025.02.11.18.22.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 18:22:59 -0800 (PST) Date: Wed, 12 Feb 2025 10:22:53 +0800 From: Julien Rouhaud To: Michael Paquier Cc: Sami Imseih , Lukas Fittl , PostgreSQL Hackers , Marko M , Alvaro Herrera Subject: Re: [PATCH] Optionally record Plan IDs to track plan changes for a query Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Feb 12, 2025 at 10:59:04AM +0900, Michael Paquier wrote: > On Wed, Feb 12, 2025 at 09:20:53AM +0800, Julien Rouhaud wrote: > > > > FTR my main motivation was to be able to deal with queries referencing > > temporary relations, as if your application creates a lot of those it basically > > means that you cannot use pg_stat_statements anymore. > > Do you have an issue more details about your problem? If we can > improve the situation in core without impacting the existing cases > that we need to support in pgss, that may be worth looking at. I thought this was a well known limitation. The basic is that if you rely on temp tables, you usually end up with a virtually infinite number of queryids since all temp tables get a different oid and that oid is used in the queryid computation. And in that case the overhead of pg_stat_statements is insanely high. The last figures I saw was by Andres many years ago, with a mention 40% overhead, and I don't think it's hard to get way worse overhead than that if you have lengthier query texts. As a prototype in my extension I think I just entirely ignored such queries, but another (and probably friendlier for the actual pg_stat_statements statistics) approach would be to use the relation name to compute the queryid rather than its oid. This would add some overhead, but I think it would have very limited impact especially compared to the current situation. Of course some people may want to keep the current behavior, if they have limited number of temp tables or similar, so I had a GUC for that. I don't think that the community would really welcome such GUC for core-postgres, especially since it wouldn't be pg_stat_statements specific.