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 1tx7bp-003C6n-SK for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Mar 2025 16:58:37 +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 1tx7bo-0072qV-IW for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Mar 2025 16:58:36 +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 1tx7bo-0072qM-9N for pgsql-hackers@lists.postgresql.org; Tue, 25 Mar 2025 16:58:36 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tx7bm-0014ut-2b for pgsql-hackers@lists.postgresql.org; Tue, 25 Mar 2025 16:58:35 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-3061513d353so62911961fa.2 for ; Tue, 25 Mar 2025 09:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742921913; x=1743526713; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Jz+ZQQRB4wb/SK2T6R5PDHzUcVBYGMOVdIPN1ZymToo=; b=QaQLKAws349zfWmBURgjS5WStxahIlwJJ5DRVKUag5chxy2YiqFd+IlAUpoAAPKnWk lLOodB5lkzGAXCkj5kF3tjrSymzbf6F28GVQ1dVl7X+LRfaouuRmjhJP9CCxnFtPbN6N AzYqA0U265BXOem+PiQJgT9CaAU6JwGtxJbFugN2DjpkFZUYZOU4urAN8siGvm76uy+N YOCxeuQRc7PGoggcWF6rNkLqZJsoO2D3uW8tMwP6s17vmwbspMDMAOze2j2KQCIeCa8L 9hGpwm1YD8K4sEihyU8UP7QyXnjCsLtTwxBMTAa2fsAVg6gRdVAtVz6x5iKBA1b/okKu L0Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742921913; x=1743526713; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Jz+ZQQRB4wb/SK2T6R5PDHzUcVBYGMOVdIPN1ZymToo=; b=f26db+Qcqips47RN4vW1OBS9r9Rai+sCeMU3FM78M6yhLe6ezo3XDr7c/ss+UkZQ/0 QLDINH5kcXzlZBSSk6nHYXh+vkUtd2rKI/XVEcIY9Y6gqA5E0qYXkuZyrLyQjxFQE5wY Cqmzuz+qRxmAEsN+TaR6BnBXzGZe6iHQCs/bPqXIV2yRhsq+deEV590g9nScWGQ8oXTh 6YyDqc6Qu81ApFAmLdCXarwhzzK+L1CB/nAsoYYelUWmo84v2wbxPoa2GEb9UvufLvAS 6IHCCwR7+ta3srsWRHRMx8DPnWSr4fhvFdUfmnUalduZ6xs9PtgOrDmGV3eE8QlhBn+r DtPA== X-Forwarded-Encrypted: i=1; AJvYcCU3nUGY/oIVECRUyw911mofCJoQvQ4eiwKff0p5/63spJhd5JScUeSK/YrP1cowE8ed1oZwxxo1sUxFXtI/@lists.postgresql.org X-Gm-Message-State: AOJu0YxyqJuw9mFclP5x8xfMde72IaI4cHzF6hPUZhKxfN9cY1kAw20S mQHSR6Y7dxPXhmidByRVLrYPNZ2grq1otK6jxNpWJSSV6aal/nrgheq0O9DJyqhg7AwHXRQqINL Eu89Jche+ode8IKZZ7HgW97Ne8GkRUYRArzp7rg== X-Gm-Gg: ASbGncvBSIxdA0lBu6EdRTyh8zRjJri4VJenDW4mrTMiOjOcCzlPCAM4Z9moMk/o5JM Ae9OL5IRgQDEEYc1G2lQWEbqqsY4iAAsuKcooLaYYla3jS4/GpDT14RKw0TvwPDUzTmXjmQewMP 4DfkHJGvQ3TvkrdLWOvxdkZ7cq X-Google-Smtp-Source: AGHT+IGS4vJ/RmQ8bP7M2+KKPgKodLDrV+h/89Yn+usEzu+27TZTJ8KsVkcVtf66EmzpN6se5K/0LFgVf2bLRbEUPIg= X-Received: by 2002:a2e:be8b:0:b0:308:ec50:e841 with SMTP id 38308e7fff4ca-30d7e313eedmr85216911fa.25.1742921912605; Tue, 25 Mar 2025 09:58:32 -0700 (PDT) MIME-Version: 1.0 References: <80506.1742660683@sss.pgh.pa.us> <461405.1742691859@sss.pgh.pa.us> <1189112.1742869660@sss.pgh.pa.us> In-Reply-To: From: Sami Imseih Date: Tue, 25 Mar 2025 11:58:21 -0500 X-Gm-Features: AQ5f1JrMZDejQqklRlDUm5daK0YyP6DaY-8S5TPrzg5RvyA5da8bTlvf4WA2J9c Message-ID: Subject: Re: query_id: jumble names of temp tables for better pg_stat_statement UX To: Christoph Berg Cc: Michael Paquier , Lukas Fittl , Tom Lane , PostgreSQL Hackers , ma lz Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > > Attached is the second one, with more tests coverage with attribute > > aliases (these being ignored exists in stable branches, but why not > > while on it) and table aliases, and the fixes for the issues pointed > > out by Christoph. I'll double-check all that again tomorrow. Please > > find an updated version attached for now. There are several parts of the doc that may no longer hold true. 1/ "Since the queryid hash value is computed on the post-parse-analysis representation of the queries, the opposite is also possible: queries with identical texts might appear as separate entries, if they have different meanings as a result of factors such as different search_path settings." I think this text could remain as is, because search_path still matters for things like functions, etc. """ postgres=# SET SEARCH_PATH=a; SET postgres=# explain verbose select * from test(); QUERY PLAN ------------------------------------------ Result (cost=0.00..0.01 rows=1 width=4) Output: 1 Query Identifier: -1813735303617154554 (3 rows) postgres=# SET SEARCH_PATH=b; SET postgres=# explain verbose select * from test(); QUERY PLAN ------------------------------------------ Result (cost=0.00..0.01 rows=1 width=4) Output: 1 Query Identifier: -3896107319863686763 (3 rows) """ 2/ "For example, pg_stat_statements will consider two apparently-identical queries to be distinct, if they reference a table that was dropped and recreated between the executions of the two queries." This is no longer true for relations, but is still true for functions. I think we should mention the caveats in a bit more detail as this change will have impact on the most common case. What about something like this? "For example, pg_stat_statements will consider two apparently-identical queries to be distinct, if they reference a function that was dropped and recreated between the executions of the two queries. Conversely, if a table is dropped and recreated between the executions of queries, two apparently-identical queries will be considered the same. However, if the alias for a table is different for semantically similar queries, these queries will be considered distinct" -- Sami Imseih Amazon Web Services (AWS)