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 1ly3lV-0000TI-R6 for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jun 2021 02:46: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 1ly3kw-0000iZ-9p for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Jun 2021 02:45:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ly3kw-0000iQ-23 for pgsql-hackers@lists.postgresql.org; Tue, 29 Jun 2021 02:45:46 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ly3kp-0000tP-FC for pgsql-hackers@postgresql.org; Tue, 29 Jun 2021 02:45:45 +0000 Received: by mail-io1-xd31.google.com with SMTP id i189so24867563ioa.8 for ; Mon, 28 Jun 2021 19:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ihlu7EkPS2DPWx8MgF20/3uapKc6e3tdboHUIetqKes=; b=VUvuwxqTVnRIfWMjwWTWNkh64gkwqPCYQTzjY0cNSLBGfFYGwlkzQYF2NETimpR48X nU0rApfQKNmn5k/ry06sb4BWucaZPFUoRTITp57lwesLUv0RYIAwH9DQ5eMsd5NbsGRz H/nc1szNAdYb+5aY9QHNbI4UND4dbYGvImmLRzioca7P2ScGycsD2qJogcOxkykoEDJK LkGz7j7iK+QZsx41hZwL3ulfmn4wMWlvGfK/25QJoLQxvBq4Nh7iKn8jvwllFSCg2sd0 8C0qL+3IXKQEZ3umwvIy1mWQqO7Nkix/IWKdkr0FpjGBV1zdQVszXjfH1iqR5854Xq3K 3kcg== 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:user-agent; bh=ihlu7EkPS2DPWx8MgF20/3uapKc6e3tdboHUIetqKes=; b=l0KdgGFzksNQQ2LwjB58d5dUoRqF7p95jRPV+ZInPcUOB88zgmAezgsxAqXDT/vZHg tkAjO8NFrvC0lL4U6vi7WDJmarjCnBD6oYMdfgXRP5O/wViAes9+QwY8VPABHjeB832W wx1pMHrP1zLEuhTvsBXP11s2QrveCXwwSFEBdRHzKKW0KkhDWA8dJKQTiQ2H4Z5MwJWr dL9d8kucO7rupceDfwcExnx8awlbVT8w/kNeOQcgK53tjjrfDpURT20UXZlxZ+RNYqKa P9mt9WR/WZ94x21tainHzSp838YS0JnAIR0JXOyINIeNhNB5pXS4dK4KOqIaXZBkR9+m D6bA== X-Gm-Message-State: AOAM530LrICuVh4oRdU1kH2Wmov63NjIJRun2rDLfXUOtMekeZNLwTsG SyaC0cYJGUAO+RoctSiX/Wp2Kw== X-Google-Smtp-Source: ABdhPJwgVhO7wH19s4TtFTl/9BrfW+ExMiR4rx2c36DjAVRjmw4n3Nto5yV8E3XWFWkdd/sc5WWpSg== X-Received: by 2002:a05:6638:11c7:: with SMTP id g7mr2254448jas.11.1624934738067; Mon, 28 Jun 2021 19:45:38 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id y2sm6012443ilh.82.2021.06.28.19.45.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jun 2021 19:45:37 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id EFF80800870; Mon, 28 Jun 2021 21:45:35 -0500 (CDT) Date: Mon, 28 Jun 2021 21:45:35 -0500 From: Justin Pryzby To: Julien Rouhaud Cc: Fujii Masao , Pavel Stehule , Peter Geoghegan , "Tharakan, Robins" , pgsql-hackers@postgresql.org Subject: Re: track_planning causing performance regression Message-ID: <20210629024535.GG21248@telsasoft.com> References: <646e5cae-5e8b-feaa-43dc-014bf355bf08@oss.nttdata.com> <20210418233615.GB7256@telsasoft.com> <20210419145545.GF7256@telsasoft.com> <20210421145338.GT7256@telsasoft.com> <20210421154007.GU7256@telsasoft.com> <20210629020918.GE21248@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jun 29, 2021 at 10:29:43AM +0800, Julien Rouhaud wrote: > On Tue, Jun 29, 2021 at 10:09 AM Justin Pryzby wrote: > > Is "identical structure" really accurate here? For instance a multi > tenant application could rely on the search_path and only use > unqualified relation name. So while they have queries with identical > structure, those will generate a large number of different query_id. We borrowed that language from the previous text: | Plannable queries (that is, SELECT, INSERT, UPDATE, and DELETE) are combined into a single pg_stat_statements entry whenever they have identical query structures according to an internal hash calculation Note that it continues to say: |In some cases, queries with visibly different texts might get merged into a single pg_stat_statements entry. Normally this will happen only for semantically equivalent queries, but there is a small chance of hash collisions causing unrelated queries to be merged into one entry. (This cannot happen for queries belonging to different users or databases, however.) | |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. Really, I'm only trying to fix where it currently says "a fewer kinds". It looks like I'd sent the wrong diff (git diff with a previous patch applied). I think this is the latest proposal: Enabling this parameter may incur a noticeable performance penalty, - especially when a fewer kinds of queries are executed on many - concurrent connections. + especially when queries with identical structure are executed by many + concurrent connections which compete to update a small number of + pg_stat_statements entries. It could say "identical structure" or "the same queryid" or "identical queryid". -- Justin