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 1tXp5k-00Eopp-Np for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Jan 2025 22:08:57 +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 1tXp4k-004bRV-OW for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Jan 2025 22:07:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tXp4k-004bRN-FY for pgsql-hackers@lists.postgresql.org; Tue, 14 Jan 2025 22:07:54 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tXp4f-000QlB-2O for pgsql-hackers@postgresql.org; Tue, 14 Jan 2025 22:07:51 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-30613802a6bso36410531fa.1 for ; Tue, 14 Jan 2025 14:07:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736892469; x=1737497269; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kuQboDRUY02ytJvwpu+AbQ1XmSX5RZrWyxpDT9CBgEE=; b=AabP1ixz0WmEWHtia3qf3v2dKm7N3M6D4dQjEOkXwGzj/UO4B5OgTMvAy8gbm9mGSy ia2vFnVLMDGLLpB1ptZuQUTT/3OgUVTq/oevVwYT8warOvgH4mcLdbGQdQUG7Jzkfjth m74WSMc19j06fsbjx0EJ/K+Hf0XtH4i5Cghov2c7eyX512t9mSIB4D1Yehuo9r5kGsoC 7RvQt0musvlODo6JRp6yaJ/iJ/DtnrmPJDiy8wAsl07ParDT4usUM7RA+2mLKc/YTgEx cC/Nc0ZhqlxVNXLIYuaqv6sZ7C9DT+/ccU919wNMj9WvBKWeHaYvMJJCMLT4eoXCuX6/ kXQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736892469; x=1737497269; h=content-transfer-encoding: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=kuQboDRUY02ytJvwpu+AbQ1XmSX5RZrWyxpDT9CBgEE=; b=UwyCSkUDJ6UlSQkK35e6j9nLnBGs6C7iOjkttdXe1X3Bs6fpwbC89KGAyf8kYAfx5k IWXdTeKaWdTcrL5hh5pCo4NlwqszpjeHrvUcml+fSQsJCKVuQboTWmMZhI6gezmW8NuI B2cPj6yEs3XWEY4jS8o8VSjKldtiAdvHryjJWyEGS0mUfkeXAZvstHNJtuJMncGA2fPb LELOsF8HlSJTkf1CSJTGcVoaEHnhnqG6C4dRgX67Ftdf0IpZRgQj56jkZNwVPfs+L58G rB/A6uC4WZa5hStrizsiUgu3ZoZC3gX76sKtPEVeHzcLDGaz7G5k6I9r0YT4hsj2vpN5 I/5A== X-Forwarded-Encrypted: i=1; AJvYcCWcAW2kW3UkhVbJBUabNL2gJNm6/jRwlN3v9XO2iVFH9oq8uW/AYkWzw7e+qGLbaONlQ66ZFch8DSyarNF9@postgresql.org X-Gm-Message-State: AOJu0YwJWqIMXRAVXUFW4tNh7h7r1f6z+/LAeyGYBCJ9vjxMcwq6+gwU e4Dy5rAH7nTgaEUAGZb5DrdjRsEHHdOcVyT4aXEsNSmbzwJXMe2VahTav3GqxcG1zzmGSmIirIT 6EUQY+XjIg6FIujF0mrgvuiHh/yU= X-Gm-Gg: ASbGncuV9fg7kvbBTGFTIyWFt3EfxT2g04DBX8zhi/7K3N62fKgxQajFJ0bUGwMzowO hfGdbjWQWOAQSdHKSgJPsFSP5ZIDETDEihCZM X-Google-Smtp-Source: AGHT+IE+GmwDxgmcq4YCXoEOBidGncHhI+1NQpS3JUzctyCR7bqZVTNKsGqPuJGLaTjmqblBp5NcgyzE80HWkV4qQLI= X-Received: by 2002:a05:651c:401a:b0:300:39eb:1aae with SMTP id 38308e7fff4ca-305f45c7e45mr54730261fa.24.1736892468639; Tue, 14 Jan 2025 14:07:48 -0800 (PST) MIME-Version: 1.0 References: <6707FCA9-FD1A-4609-A1A6-142456C14E0C@yandex-team.ru> <320a31e6-4c91-438b-ab17-8a1d72384727@tantorlabs.com> <52e5e3aa-066a-4daf-8d65-77c34a2f0d98@tantorlabs.com> <6482A576-4465-4E46-A42C-F1767E8DDE30@yandex-team.ru> <20994d10-ab44-4c6b-91bc-c4675cd2e58e@tantorlabs.com> <9D8A5BC8-A3A5-4DA9-9382-F30D343247D1@yandex-team.ru> <6cf6270b-e8fa-4d99-b74a-17e781cdf309@tantorlabs.com> <3a27c830-b81f-4560-9774-a87d9b922fbd@tantorlabs.com> In-Reply-To: <3a27c830-b81f-4560-9774-a87d9b922fbd@tantorlabs.com> From: Sami Imseih Date: Tue, 14 Jan 2025 16:07:36 -0600 X-Gm-Features: AbW1kvbgwiR6uZWXVyu3T7FKBZRRjbR418rmjxful3FTJ_4kAOGf9OVOKIS8QzU Message-ID: Subject: Re: Sample rate added to pg_stat_statements To: Ilia Evdokimov Cc: Alena Rybakina , Alexander Korotkov , Michael Paquier , Greg Sabino Mullane , "Andrey M. Borodin" , pgsql-hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > Alena, Sami =E2=80=93 I apologize for not including you in the previous e= mail. > If you're interested in this approach, I'm open to any suggestions. > > [0]: > https://www.postgresql.org/message-id/1b13d748-5e98-479c-9222-3253a734a03= 8%40tantorlabs.com Here are my thoughts on this: There is good reason to apply sample rate selectively, but I am not sure if execution time is the way to go. I would rather apply a sample rate on the most frequently called queries, since I can gather enough samples to draw conclusions about performance of the query. I just don't know if that can be done in a sensible way, because while we can check the number of calls in the entry, we will need to do that with a shared lock and spin lock, which will defeat the purpose of this patch. This also got me thinking if maybe we should allow the user to disable sample rate for utility statements as those are less frequent in most workloads and a user may want to capture all such statements, i.e. DROP, CREATE, etc. Regards, Sami