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 1n7Tvb-0003kS-KH for pgsql-general@arkaria.postgresql.org; Wed, 12 Jan 2022 03:03:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n7Tv3-0001xU-TM for pgsql-general@arkaria.postgresql.org; Wed, 12 Jan 2022 03:03: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 1n7Tv3-0001xK-Gd for pgsql-general@lists.postgresql.org; Wed, 12 Jan 2022 03:03:25 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n7Tv0-0001x7-9k for pgsql-general@lists.postgresql.org; Wed, 12 Jan 2022 03:03:24 +0000 Received: by mail-pl1-x629.google.com with SMTP id l8so2002876plt.6 for ; Tue, 11 Jan 2022 19:03:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ecJHIbgLvSdBHvz4AxxU61y3KdRwzZBHZ1Ezo2h88bA=; b=fHgwxi4XZH3OpSQtij3eVYNsRqpE8OWe8/zEJ/NLfivLY2ldOo0hADx67H+wgT5ecd YaGtDnCgoxGgyaUt3lEOu/iRTn3plcRp4eN/Ao4+mCU6Z9+Ivh7Do818UmwQmwVA/WW0 DYHEx1cJpsVXCIa5Tzyyv2aNx4L9NkPX0uh66ooSnoA+fh462IZvLD/mn76WFh8VGjf2 lo9FrrNeK7DSLd51a9lumNRYIRAUNVA3bH62G4+Pn/RuQk9tEzhI5ylzLlbueUOBVL01 XQg93kYwEaMs+dM9FIC2erI7NGKsxip98DXh3gpyPH41ntuqC9+flhLNq2B4LpTfJ2kS X7Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ecJHIbgLvSdBHvz4AxxU61y3KdRwzZBHZ1Ezo2h88bA=; b=Jj+jdeInY8YGfkAnTh7DhfIBYM/k6uzBY/x6IX6pjUF32ji5DdwaJRbBkitWOiUl2V +/bUIiydk3F6nVAQkH0fVdEUOTP5ZIkT7W70v0VQHwXwAEx+gaiz4pU7TysFrDmRvCPV J8l5KNZ4wZupEAk/QFfnRA9Te5DylCG4Z3TPcFBXlAAZBwgDk4vKMT5ViwWrW1m22Xao GsJ7VRYnItnWYnDbVOlYXVWBr2f6ulmAydtalQe5dKamAqeuZCL6FQVEHrE27sevdp3e 1ADn+zHt7EqjEka01W/9QXuJIjGrx6GxhAU56HRXfW75nSOLP7/Xnq8TNstuEWIuXqYE FybQ== X-Gm-Message-State: AOAM5336RhKJJse4J0BfiABd6YCpl+kDTJBNIoYrzotM7UxL311JJ76u +9L7fHoqcC4kAt1UCZ8cr/4= X-Google-Smtp-Source: ABdhPJz3JtyIoKyIRp64I85RgFP7vevj6nWk78QBCvtac7F8+x9SkGAv1NECKRqmGFJJxNUofyLcSA== X-Received: by 2002:a17:902:7793:b0:149:c4ad:ecc3 with SMTP id o19-20020a170902779300b00149c4adecc3mr7360254pll.171.1641956599426; Tue, 11 Jan 2022 19:03:19 -0800 (PST) Received: from jrouhaud (1-171-174-202.dynamic-ip.hinet.net. [1.171.174.202]) by smtp.gmail.com with ESMTPSA id h5sm12040459pfi.46.2022.01.11.19.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 19:03:19 -0800 (PST) Date: Wed, 12 Jan 2022 11:03:15 +0800 From: Julien Rouhaud To: "Dirschel, Steve" Cc: "pgsql-general@lists.postgresql.org" Subject: Re: pg_stat_statements Message-ID: <20220112030315.vx3lkrvhjanxel7u@jrouhaud> 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 Hi, On Tue, Jan 11, 2022 at 03:04:14PM +0000, Dirschel, Steve wrote: > > I'm not sure if this is the correct distribution list for this type of > question but I'll try anyways. We have an app that uses multiple schemas. > It will do a set schema 'schema_name' and execute queries. The queries > executed are the same regardless of the schema the connection set. > > In pg_stat_statements the exact same query will get a different queryid for > each schema that executes the query. > > I'm unable to determine which queryid comes from which schema the query was > executed under. Is anyone aware of a way to determine this? > Unfortunately this is a known limitation. There were some previous discussions (e.g. [1] and [2] more recently), but I don't think there was a real consensus on how to solve that problem. Storing a query text with fully qualified names (either the current query or a new field) is not practical for performance purpose, but there were no objections to storing additional information, like the active search_path when the entry was created. But as noted, while it technically gives the information you need it's far from being convenient to use, which is probably why it was never implemented. [1] https://www.postgresql.org/message-id/flat/8f54c609-17c6-945b-fe13-8b07c0866420%40dalibo.com [2] https://www.postgresql.org/message-id/flat/9baf5c06-d6ab-c688-010c-843348e3d98c%40gmail.com