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.96) (envelope-from ) id 1wQvjO-001zF0-1a for pgsql-hackers@arkaria.postgresql.org; Sat, 23 May 2026 23:26:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wQvjJ-00GG8X-35 for pgsql-hackers@arkaria.postgresql.org; Sat, 23 May 2026 23:26:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wQvjJ-00GG8P-1s for pgsql-hackers@lists.postgresql.org; Sat, 23 May 2026 23:26:06 +0000 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wQvjH-00000000Tqo-0nmS for pgsql-hackers@postgresql.org; Sat, 23 May 2026 23:26:05 +0000 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-3698e34a567so7682735a91.2 for ; Sat, 23 May 2026 16:26:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779578760; x=1780183560; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=QwYt42gRJvnlFyraDcpD3HnLgfU3FLWSMhTlYh80+ko=; b=DfrXGyqZHP2SEDGCvojUL10+toKA8WaL1Y2npEQZ37g4+jX9pfUOKzy7V8BGrb2cwB o7SYfD07YW4l0MrFV+ckJHSuB27A6OyzofNVMFVywLGfZ/ca6v082NQtyymfvz0dh4gI /T6l1YYJLonIhEIu/0VEZfIJBaVkyuantokVVrSh2JelDEVpvR5fYXWQh2TvVgEGIdPY NGBO+UbbyEmoV5YiMUzrBaETWqQBr7eMvd/8hBqBc04Fikx4MMlYb3leRnuHwA2MRFHv iBQPj39X4vOIUusZkwW/6iN7qIQAhyECOX08rXA95XzTVXE6BK7U6xkGtUkVejd4wh0A vgVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779578760; x=1780183560; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QwYt42gRJvnlFyraDcpD3HnLgfU3FLWSMhTlYh80+ko=; b=kgLZDAwn5cBDnmkIJIAexi4RtlyQtNXB6ydCMwFq0y1vMwF0k6R0hbkUianzniVoQe Kobix16lyZi8PKd4C90dk5Bcd9ALVG05gLWUxQsxdeGnMSZ60jTcueo6/cZEUjGVrXRN BnxQwK+/Hy3z5J5MaX7pKs2JGO3NrkfuPEypckhBt04kd2c8nwOq8ut4BcriIPnciNRF 0FTj+xNXw/5mnF02XOf3bD52MA8vV/R+TgJhnkmII6AH9cuZ5jik4emHgHVuAQhy9ide 9UpXNXFrjLN8bv5FkV1qVz1JnPICFkFbhD6p06AQy72E5egd1MpAWPZdYRLJ+7OVExzp fXvg== X-Forwarded-Encrypted: i=1; AFNElJ8MSNFWebGJNOl7kmGDdF79GiNks5L7KhsW1gzOk8O2DV2SlEq4Z9Cf5LuXsxoI6RvtKV+SmnKsPuMN9TvR@postgresql.org X-Gm-Message-State: AOJu0YzoQ7Px9MjInhthfa8oKpxu3XtuwHyJAADXdanulwefAmEXRqSD jnosz3tBaAkRVcMPa2vwaAIhg59LgQBE2QDh7x+kPC6TLG+Lkjh1nFHL X-Gm-Gg: Acq92OEUNWhje0El1HE2526LwGxUdPuWkqVSMIJdYnthgkZARDFzFOY7DF87hefbKKc kmvJeRzzz3mw0T9uCizSGLS2/Xxx7t+jUDWipurCYv8Gh/VQM4kHlO9zKz7M+jXYYyDSHlgfdDf uGq6K8zAVXD10D8JhE0SXt7hDeI+4uH/34Fc2TaTkMCcT3dIL6eTm7BySFAcLXMsRFWbxH6MJIj Nb9sFBW047J4ocl92wR7qpOx48VK4WwOxxbm01QNfHbag78FZ2ukbMin5bheMw+7w/r8mItStaC VLb9tkV9sek/1KktcIrlYrMTl2kKUDO6/x1ya5CtJbgKKwrK7i88cAkPX+bZxoBxqW625c6gqjf NNszZtkeqsc3o9B6gQRqG3WZmRFs6rMB93fw4eSZB6djKez5UmDr3bwoAbkSBqQxAKkWiIOiSAN 0LloLAu6+Gvgk8U2Hm72ZZlzQpZmfLnEUthGS34A53Zb6ritG0u7FB X-Received: by 2002:a17:902:ef11:b0:2bd:d7b5:83ed with SMTP id d9443c01a7336-2beb07001camr105998435ad.39.1779578760343; Sat, 23 May 2026 16:26:00 -0700 (PDT) Received: from jrouhaud (S01060c7bc8a5bc4b.vc.shawcable.net. [174.6.105.72]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2beb58dba7bsm52476635ad.66.2026.05.23.16.25.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2026 16:25:59 -0700 (PDT) Date: Sun, 24 May 2026 07:25:57 +0800 From: Julien Rouhaud To: Lukas Fittl Cc: Sami Imseih , pgsql-hackers Subject: Re: Improve pg_stat_statements scalability Message-ID: 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 Fri, May 22, 2026 at 06:15:00PM -0700, Lukas Fittl wrote: > > For archive's sake and others reading along, we had a productive > discussion about this today at PGConf.Dev. > > I've created a new wiki page combining the prior 2025 discussion, and > notes from today: > > https://wiki.postgresql.org/wiki/Scalability_of_pg_stat_statements Thanks a lot Lukas! Just a small clarification, I wasn't asking for a way to remember the last time a query was executed (although I think it's a very good thing to have), but remembering the time each query text was saved. In a reasonable system (that is a system where the number of entries doesn't grow much more than pg_stat_statements.max, ie, you can actually use the current version pg_stat_statements) you will likely get a lot of entries even if you filter out the entries that didn't get executed in the last X minutes. However, the vast majority of them should not be new queries. So if you maintain an external system that snapshot pg_stat_statements once in a while you only care about the (possibly) missing query texts, which should be a very small fraction of all the records you otherwise need.