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 1tQV8w-0032Zs-5g for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Dec 2024 17:25:58 +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 1tQV8v-00Ex8I-EQ for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Dec 2024 17:25:57 +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 1tQV8v-00Ex7i-41 for pgsql-hackers@lists.postgresql.org; Wed, 25 Dec 2024 17:25:56 +0000 Received: from relay5-d.mail.gandi.net ([2001:4b98:dc4:8::225]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tQV8s-001a1S-DU for pgsql-hackers@postgresql.org; Wed, 25 Dec 2024 17:25:56 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id A7C121C0003; Wed, 25 Dec 2024 17:25:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vondra.me; s=gm1; t=1735147552; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mSB4e+IS+CwZzU/MPibGqllo+eV1wmGTB7iF1uwR44M=; b=QD2u5WyOrkHmCpkZBOfOFF88+O7HJwJT6GynbhC540BrOL8f/elZvfledHeWAqq2mZrNCU q3gSXSRhokVO4quvPHQ6HWqOklpqdBT5b7jcZf1zSAcAeuNYGkf7XGNzWv2ZMAjwXxCsYU UBat+wY8NptpDOX5wyDmBz0qEF7xmLlxge6RNMcMvnVa110f6FSwS4hNZAShAxGYn+6Jd3 7xlj46LPFFK0dg+tNAlZGeCFjaeHO0pJ4TAwi5K9/3bjMAwftDwfIVjZ3KRM2Wi3U8zNpw p0oEuGxrYyhn8D/ORudAkGIhmnaU1aKXu2XVwCkfvmfvdGTFqkAk2c4KrZoXYw== Message-ID: <8df7cee1-31aa-4db3-bbb7-83157ca139da@vondra.me> Date: Wed, 25 Dec 2024 18:25:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Tomas Vondra Subject: Re: PoC: history of recent vacuum/checkpoint runs (using new hooks) To: wenhui qiu Cc: PostgreSQL Hackers References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: tomas@vondra.me List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 12/23/24 07:35, wenhui qiu wrote: > Hi Tomas  >      This is a great feature.   > + /* > + * Define (or redefine) custom GUC variables. > + */ > + DefineCustomIntVariable("stats_history.size", > + "Sets the amount of memory available for past events.", > + NULL, > + &statsHistorySizeMB, > + 1, > + 1, > + 128, > + PGC_POSTMASTER, > + GUC_UNIT_MB, > + NULL, > + NULL, > + NULL); > + > RAM is in terabytes now, the statsHistorySize is 128MB ,I think can > increase to store more history record ? > Maybe, the 128MB is an arbitrary (and conservative) limit - it's enough for ~500k events, which seems good enough for most systems. Of course, on systems with many relations might need more space, not sure. I was thinking about specifying the space in more natural terms, either as amount of time ("keep 1 day of history") or number of entries ("10k entries"). That would probably mean the memory can't be allocated as fixed size. But maybe it'd be possible to just write the entries to a file. We don't need random access to past entries (unlike e.g. pg_stat_statements), and people won't query that very often either. regards -- Tomas Vondra