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 1kkkLd-0003vi-7g for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Dec 2020 08:52:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kkkLc-0006uX-2a for pgsql-hackers@arkaria.postgresql.org; Thu, 03 Dec 2020 08:52:20 +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 1kkkLb-0006uN-Rq for pgsql-hackers@lists.postgresql.org; Thu, 03 Dec 2020 08:52:19 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kkkLZ-0004Mc-NV for pgsql-hackers@postgresql.org; Thu, 03 Dec 2020 08:52:19 +0000 Received: by mail-pf1-x432.google.com with SMTP id w187so837135pfd.5 for ; Thu, 03 Dec 2020 00:52:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9ucUlbO9eE7gLAXQ4do90VyXgpXdxNe/JjMxhouaGnM=; b=C/PL+KurzYQzskdFMd7O3JM5DmxudUz2MF74xwLEgwxsT8ZSqZCMjPqzLCIzk/W4zj 11jEbH32s+YmPwnoAFxurll2BNpUrtuJ3k2/dwGNpUxJCuw7LAF8PqqJ0ooh0rkmUbeb mH6UjoFh1x6/HVU3WDlf88KRdIJJw/Z6GaAcQd/xbrjV0L2BjOcQlO++eGXyffNkC4l2 sqrBCG5dNIIlVzTOM5e24FN+vvoQ5/taGG1HCH5+VeTS9mHr32IPApNAUDqmO2erJTIM 3V8qAGySZR4vAZ8+0AMwetrRHyKHcP6cVDkS97AG4AucoN/NW6UrAx20FTQV4XIp4yBS VtmA== 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=9ucUlbO9eE7gLAXQ4do90VyXgpXdxNe/JjMxhouaGnM=; b=SZcO7slVnUwPEXcxoWrPHOaPkPZhX4NLhgYwNVs92FtaJTJmXWyI3lUPGX5XOyqokz ueJl1xtSVTcgZwcps8k1qqkEPz0Kl9Do2Ay94zrM4zK4huonTo9ssrs1y2UzIpw1e3Gf HrkmELoN2LXsj5/hXb9oKGUI6NIJthTaKeMHjAA1fzumrzri/Qb4ebISE0lXBRB2Ukw/ qb3NbPnZ2RGbxHkLL7tkOqP3ZKoZmvJdNnmpsgaPi6hF6uTG3GDCOoPiP2ctQoyNgCqY oT/YLYdxP20Oj1u6RUdnbRqH+cYMITaZn92cJaMTma5Xj40XTp7eJf+etzEw1u5hjLsc YAuA== X-Gm-Message-State: AOAM531xRzIfQA2FObelc7p4P1/KScQWh99JzrkmJOzkZOcyGa0vZn+f y/ohdPHUC0x+pftCiKCSre8= X-Google-Smtp-Source: ABdhPJz86SUiU7yUOOoxvH+mzG6mWuvTzefFNYOAeUAbNZmBbNu3IG6hFGafNVrGFWx3YFHQaW3xkw== X-Received: by 2002:a62:be13:0:b029:19a:4c0:efe3 with SMTP id l19-20020a62be130000b029019a04c0efe3mr2335971pff.75.1606985535742; Thu, 03 Dec 2020 00:52:15 -0800 (PST) Received: from nol (36-228-92-107.dynamic-ip.hinet.net. [36.228.92.107]) by smtp.gmail.com with ESMTPSA id e14sm488261pgv.64.2020.12.03.00.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 00:52:14 -0800 (PST) Date: Thu, 3 Dec 2020 16:52:08 +0800 From: Julien Rouhaud To: Sergei Kornilov Cc: legrand legrand , "pgsql-hackers@postgresql.org" Subject: Re: pg_stat_statements oddity with track = all Message-ID: <20201203085208.GB8050@nol> References: <20201202040516.GA43757@nol> <20201202063241.GA51769@nol> <20201202082402.GB51769@nol> <1606916496022-0.post@n3.nabble.com> <861161606917332@mail.yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <861161606917332@mail.yandex.ru> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Dec 02, 2020 at 05:13:56PM +0300, Sergei Kornilov wrote: > Hello > > > - add a parent_statement_id column that would be NULL for top level queries > > Will generate too much entries... Every FK for each different delete/insert, for example. > But very useful for databases with a lot of stored procedures to find where this query is called. May be new mode track = tree? Use NULL to indicate a top-level query (same as with track=tree) and some constant for any nested queries when track = all. Maybe pg_stat_statements isn't the best tool for that use case. For the record the profiler in plpgsql_check can now track queryid for each statements inside a function, so you match pg_stat_statements entries. That's clearly not perfect as dynamic queries could generate different queryid, but that's a start. > Also, currently a top statement will account buffers usage for underlying statements? I think so.