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 1wUYvn-001G19-03 for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jun 2026 23:53:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wUYvl-00GYmb-2l for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jun 2026 23:53:57 +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 1wUYvl-00GYmT-1p for pgsql-hackers@lists.postgresql.org; Tue, 02 Jun 2026 23:53:57 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wUYvj-00000000pE8-47Wm for pgsql-hackers@postgresql.org; Tue, 02 Jun 2026 23:53:56 +0000 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-68c32f3c6d6so5828949a12.3 for ; Tue, 02 Jun 2026 16:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780444434; cv=none; d=google.com; s=arc-20240605; b=EqVvEzX8dJndkIfZpbXMmB/Zdjq32y+7s9z+H8rSB++CC+XgOfK0JIXArYDqCoyT2x qWPrBedlExxbiHcFfY834cdMXnEA/oMNdCACcP56pabaveGJRapqwgjDx54K1/zY0u/G R/Q1GFAMfLORH32h+uHhq92kRheXCFjaRqvj3rl39etHk0wdVuT4KckJ8xhhlaVTDtyj mO5471LHcrP1AEi9164Zn1F2LcIdb4C+wZclcuWbXLWwmDHg/3/A+98kjRzwJLCpbQ7+ 2V30ifgxic6UVm2LoewaBorNzMwS1mY7LyObOloxfRfCdUlvcb+JWUVJyhR2e8EaHzTe g+8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=rk8FZS8We4xbdT7j8WrQvILUYez/BTl5IuVlk6zc1oA=; fh=fJXjTwmOH2Qo4cjqTgdIorQht9gC8Fs8QC6JQYOzx7w=; b=Zl4nGLeIDcQeD7xSVmiqwcNo8b8a0zSymv+O0XsATQKabxFgnnrKiLkci3rB79hbzz 6/Qzmv/9jP43FI9wvbXiqywumsLktOSlP8yNCcGHw0Vtkejjv7+ZACXORIaRzXs8oXVL oxV2tI1JNhb1V3iC38fsFxVUeMVa6aYgdqhyIwCD4K1o0tSB+BOHkagcL7L6/EJKYdu9 eDiS8kg+/E01M6I+u/uoMJ42KuFx23RwME7jCqWCsA6peP6BvpK+J9fddbkUR1a/CjeE TD/77jBoRBFHCz62ZODpBoU63M2ezVPmqMihHz/AUCWlmb7+ruv3kdLn4aguv//co+i9 l4Lw==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780444434; x=1781049234; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=rk8FZS8We4xbdT7j8WrQvILUYez/BTl5IuVlk6zc1oA=; b=q6eTDUUg0uSmPFEaeU2fLZoExZslNpBXUYDT/27cAfFMZ6RGLs9Smp0HWWKiGI4RF4 ao2nQOEjfs8d6x1cbsWRXyxivGhHd3GTxeN4EYsKM5XqHOc1v/2f9ZhWToK+EUWbyaVT f1s3DRwcCYXhxmxe/dle7bo38ORqy7iz2QRscLM1s42vzAioViM5E9fyOyBc8auVh6cL hyG232FjMi2FBO3rYNWbEa5QhujM3e94tSqnGKuuDJiaeCBD81AUJfO4k7k3tY6g64K6 UfKfaDd6mOUPNayfehF0oHuHvwb/3O25WxU7rz4M0zfiWdtK2VQwpfiiOsfDg3t+d7/N H3Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780444434; x=1781049234; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rk8FZS8We4xbdT7j8WrQvILUYez/BTl5IuVlk6zc1oA=; b=eVgVrMF6hpEdp3TjmN3rb3LBFqz8F6/uWYiu+MTnSlaHdxPR1fpfaPrgxH1dzoZx1o cuWWBvZOz7JFVnBFFLtO3hFrM0raTBax5v2emaXfnUy5JXAbt2eIZjgupKxpVyj3zCO4 XWBcZES6V8KdO17HEFK/B27xhYae4fDmUEl69qUe9wcHBOloZmiRkMWi514ygUWh4qfi +nZ9UpSWLED5QhRuFfX7SHQaV4w+S2dVOzkVE1Tx5lszmkzniq7NhPVzG+ahaCGH4SQ3 lfEJuKwYp2Lc+9hdkjvVDT3TO+73gMOJD28pKKnPNJ8wjgBftu97MxW8Q6to77cC8saf 49cA== X-Forwarded-Encrypted: i=1; AFNElJ+o9Wha+afc7uApRB9WAwFEUokEQ+GMYnFR/KGIG+DpOb+Fhu8LYK4sLVUuYrEZGdokceTzdbjHR0NDFgy4@postgresql.org X-Gm-Message-State: AOJu0YyEDFQNlUj/7DVWOMwDTxOeh0RqMFKE0exd9NG2CrX7fR1Igyx5 JNcjNYlCfwxqY6G30RGGsGHzL1xhYPIjt7P1Wx9AfGWp/Y9CFaq4zW9HM/ydrCqZL/p0ecY+K/B kvygi5qBL5PacluFxEzAwiaAriCbzFu0= X-Gm-Gg: Acq92OGmRKCxsccFiHP4fn/QUP5Ibvcsi2OFPnT7Qi2Hm6N3EV4WuUsONqDo9vzU8fD BsBLnurCeikyi/5IE9Veh/FqTK9J6Tu3YdwhQlmcMZ9UBcVQthgDyu0hM34pAwlruJmntIqJ6H2 fm+VSLlJAcXUlDZN20A8gI2JGzv3GcfInWgNhMa9f0CVm3z2gkIiqPhBFzwLeZTvueu5h5w4Efh sjaTLNY4FpIqNVnUW++/O4lavxFXm364vepnOsGnHN3HW2L6+McTsXPcmO+PpV9MM3ctCeQRiSH WFInh54mWkRKAA5/k9YINMPvXwse0YJWhZE7+WuPkCAGYC2f X-Received: by 2002:a05:6402:540c:b0:68b:d10a:a490 with SMTP id 4fb4d7f45d1cf-68e710eb7a5mr335390a12.13.1780444434208; Tue, 02 Jun 2026 16:53:54 -0700 (PDT) MIME-Version: 1.0 References: <20260601.135858.1116584574478485492.horikyota.ntt@gmail.com> In-Reply-To: From: Sami Imseih Date: Tue, 2 Jun 2026 18:53:43 -0500 X-Gm-Features: AVHnY4JCUvU798XbhObYPjqDd__nYA3Ug7MHGze-z8-fJENFTwiLz7eZn24RCDw Message-ID: Subject: Re: Improve pg_stat_statements scalability To: Michael Paquier Cc: Kyotaro Horiguchi , lukas@fittl.com, pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > > As far as I can see, the current implementation does not apply any > > throttling to calls of this API. In theory, a large number of backends > > could invoke it frequently and generate a high flush rate. For > > example, if 1000 backends were to call it once per second, that would > > result in 1000 shared-stats updates per second. > > > > Whether such a usage pattern would occur in practice is a separate > > question. However, given that existing pgstat code uses > > PGSTAT_MIN_INTERVAL to limit flush frequency, it seems to me that > > anytime stats should probably retain a similar restriction. > > Hmm, OK. One cost in this decision is that it could randomly make the > tests randomly slower, which is one reason why this patch has been > added to this thread. The throttling does make the tests longer, but we can do similar to what was done in f1e251be80a, and disable PGSTAT_MIN_INTERVAL if injection points are enabled. - /* 50 tries with 100ms sleep between tries makes 5 sec total wait */ - for (tries = 0; tries < 50; tries++) + /* + * Retry up to 50 times with 100ms between attempts (max 5s total). Can be + * reduced to 3 attempts (max 0.3s total) to speed up tests. + */ + int ntries = 50; + +#ifdef USE_INJECTION_POINTS + if (IS_INJECTION_POINT_ATTACHED("procarray-reduce-count")) + ntries = 3; +#endif + -- Sami Imseih Amazon Web Services (AWS)