Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ixr0E-0000zi-Ey for pgsql-hackers@arkaria.postgresql.org; Sat, 01 Feb 2020 11:31:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ixqzF-0003Ss-4E for pgsql-hackers@arkaria.postgresql.org; Sat, 01 Feb 2020 11:30:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ixqzE-0003Sl-OG for pgsql-hackers@lists.postgresql.org; Sat, 01 Feb 2020 11:30:52 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ixqzB-0005SL-SR for pgsql-hackers@lists.postgresql.org; Sat, 01 Feb 2020 11:30:51 +0000 Received: by mail-wm1-x341.google.com with SMTP id f129so11668786wmf.2 for ; Sat, 01 Feb 2020 03:30:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=RctfdniauLiOyNhGFhZBNxTqQDq0SYul0NscRFtt4Jo=; b=FB3ZT+zsatT1YsuTvvF791oTP/4I9Gb75+Aiv+A0pxJZxonlimN5RPrFitjK8keEnG eatL78/TTgbYG8fkeYeuWzufyBHizX/CYTO2FoVwkicsdl4NtFr6R3GweXNxqeiSF5RF x8CsLg6Yr+T33iMCVPjweowqtZ4+vstS1NXHAxoi2vSt1e1PZZ2+CMe7rEt6GGo6yR6G BowI5B0h965XAVeJ75Bp66Y+f9oUyH4VBjbuoW1LFzA+2rnqaJE66l6CYU0+ULljikLp yHMvK9IAB+uHM1veWW+SxwcEiLrVjYSKa4MdQ326gUMzpR9eYLyzI97AtshZeHzfEpQ/ CDIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RctfdniauLiOyNhGFhZBNxTqQDq0SYul0NscRFtt4Jo=; b=QrON5yzcD7v91oChbWCADOFwOc9cQGWTgU5Ho/EVWhCg5Vlo5OLJ3RxlPGvnXK6WKr MRuCvllstGdtRZ4bwcUm2FG7zBqXpAZa9fmbhSIm/g11jCtO56EQRvdFXDnpfSbunkTR ZIrPkE4JG/NW7BdAkS9xm7HF+4tu/DndAsM+OusPPylGdLqmnkuMuqE6KIuR6elXatgl 4bDDyODMfIrka2y035bIi/YbPN1JVa5zDI9h+UEwh5SpYHBUGG8myw8A4GghPzlaZOtj 7YwQt0jWhYo9mfUOHqsfPbdVNrsHfE62pNvwFzMVTHCz5QJ+i2j5Fs2pTywXByZ2OjVc mQ1Q== X-Gm-Message-State: APjAAAVpOAhz32mSNtu00/kwX2UnNcTtNIYeWorzrJHxYDPhQYvQ4brR 3I6c9gtlMMyglaLnsEwDhbxmJQ== X-Google-Smtp-Source: APXvYqzPTSvdL4XrrfKQL2BtvHN/XixcjdOL/oy1pCOXyfXLR0hHoB7F3sNvytjX+cB0HATFNXkx8A== X-Received: by 2002:a7b:cb46:: with SMTP id v6mr19195838wmj.117.1580556648372; Sat, 01 Feb 2020 03:30:48 -0800 (PST) Received: from localhost ([212.76.253.171]) by smtp.gmail.com with ESMTPSA id k8sm8487336wrq.67.2020.02.01.03.30.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Feb 2020 03:30:47 -0800 (PST) Date: Sat, 1 Feb 2020 12:30:45 +0100 From: Tomas Vondra To: Julien Rouhaud Cc: Michael Paquier , Bruce Momjian , Evgeny Efimkin , PostgreSQL Hackers Subject: Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view? Message-ID: <20200201113045.x4qj36uvt34ymwiy@development> References: <1565026229657-0.post@n3.nabble.com> <156516860141.18864.14200401842491641374.pgcf@coridan.postgresql.org> <20190911044523.GF1953@paquier.xyz> <20191111083730.GD1418@paquier.xyz> <20191113031523.GD14545@momjian.us> <20191129061949.GJ2505@paquier.xyz> <20191129062058.GK2505@paquier.xyz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Nov 29, 2019 at 09:39:09AM +0100, Julien Rouhaud wrote: >On Fri, Nov 29, 2019 at 7:21 AM Michael Paquier wrote: >> >> On Fri, Nov 29, 2019 at 03:19:49PM +0900, Michael Paquier wrote: >> > On Wed, Nov 13, 2019 at 12:53:09PM +0100, Julien Rouhaud wrote: >> >> I'd really like to have the queryid function available through SQL, >> >> but I think that this specific case wouldn't work very well for >> >> pg_stat_statements' approach as it's working with oid. The query >> >> string in pg_stat_activity is the user provided one rather than a >> >> fully-qualified version, so in order to get that query's queryid, you >> >> need to know the exact search_path in use in that backend, and that's >> >> not something available. >> > >> > Yeah.. So, we have a patch marked as ready for committer here, and it >> > seems to me that we have a couple of issues to discuss more about >> > first particularly this query ID of 0. Again, do others have more >> > any input to offer? > >I just realized that with current infrastructure it's not possible to >display a utility queryid. We need to recognize utility to not >process the counters twice (once in processUtility, once in the >underlying executor), so we don't provide a queryid for utility >statements in parse analysis. Current magic value 0 has the side >effect of showing an invalid queryid for all utilty statements, and >using a magic value different from 0 will just always display that >magic value. We could instead add another field in the Query and >PlannedStmt structs, say "int queryid_flags", that extensions could >use for their needs? > >> And while on it, the latest patch does not apply, so a rebase is >> needed here. > >Yep, I noticed that this morning. I already rebased the patch >locally, I'll send a new version with new modifications when we reach >an agreement on the utility issue. > Well, this patch was in WoA since November, but now that I look at it that might have been wrong - we're clearly waiting for agreement on how to handle queryid for utility commands. I suspect the WoA status might have been driving people away from this thread :-( I've switched the patch to "needs review" and moved it to the next CF. What I think needs to happen is we get a patch implementing one of the proposed solutions, and discuss that. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services