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 1sPSjI-004jYg-Pg for pgsql-general@arkaria.postgresql.org; Thu, 04 Jul 2024 20:06: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 1sPSjG-002c9s-Kc for pgsql-general@arkaria.postgresql.org; Thu, 04 Jul 2024 20:06: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 1sPSjF-002c9h-60 for pgsql-general@lists.postgresql.org; Thu, 04 Jul 2024 20:06:54 +0000 Received: from fhigh7-smtp.messagingengine.com ([103.168.172.158]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPSjC-000RRi-7Q for pgsql-general@postgresql.org; Thu, 04 Jul 2024 20:06:53 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 2F97311401EB; Thu, 4 Jul 2024 16:06:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 04 Jul 2024 16:06:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1720123607; x=1720210007; bh=3naO5mM1HzTCYQ+talq9HIY35EJv/lpxkwPQ5fpeCZM=; b= b1T2/JlGl+u0hs6cZXD9j6xG9/YFdauc0kUpdvefwLhQ2YpKi1YxRiK14aV7YOVX fXbkXOfYW4jGaS9j066Cc+8XI77eHL/JVToHDfc+WE30AWctBVjnstMoeEw+kUrA EAy0U7CBvkDfZGkUYwDMISH1BR2lGgSlvOfu+zqIdvJmmZfGpNcQrj4s8KLdcKqu TjTx5isS1+B9BLGUww/1yTc3FHOVEyT86OBK7/RVf2PuiZQzGz0dSyxbGpflC+Iv n982iLPhGps/Y9ewvcsG4cMY6bP8Lj6zqloXJHOD1g7ya8vLoqRsDrHGvMHWgdwk pRjTIzlV7rqkpnP4dljnFA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1720123607; x= 1720210007; bh=3naO5mM1HzTCYQ+talq9HIY35EJv/lpxkwPQ5fpeCZM=; b=V +bIQfhrNUyP7Fmgw0ilg2eiJYY+0QLsCveGUvpus1A85fFepUl+Mo9NNnXLBbMzx Onu386ih0CsfNa+RqNp9CzdsS311zb/5uP2ZrMxjgikcPjnFfoXdWcDh3W23TzP6 yJqyIyqSXjv+3eHL/p9ELlkk4330DCerxjwkH42Rb8AQ33bgLe2aRqVMZuy1tkuc 44xD/1OXugN6hAfYW9UL6qn2imxoUEPN8Z+0ZHyGdtpIpNjYyxS86N9dsqnAp3cH tR/kpgXtu/WNnCKKWyO2C+dDFEFLLNe8OHovVJ9JsF0EWit/RvvLAH0jWlZPt2Vf UKNpU9ki8QmTuKo2zD+kw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudelgddugedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpedviedtuefgleetffetteetteduieehiefgjeffjeef hfegfeejieevuddtjedtueenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhk lhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Jul 2024 16:06:46 -0400 (EDT) Message-ID: <0d27eb23-56bf-4158-9a7f-2fd954788fe9@aklaver.com> Date: Thu, 4 Jul 2024 13:06:45 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Configure autovacuum To: "Shenavai, Manuel" , pgsql-general References: <8d268806-6162-4c31-a516-e3b1c13024b5@aklaver.com> <3f683e09-d229-42dd-b299-986d61c201aa@aklaver.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/4/24 10:24, Shenavai, Manuel wrote: > Thanks for the questions. > > Here are some details: > 1) we use this query to get the bloat: https://github.com/ioguix/pgsql-bloat-estimation/blob/master/table/table_bloat.sql > But in our load test, we got a empty database with 1 record that gets updated very frequently. Here we just meature the DB size to see how big the DB grows: > SELECT pg_total_relation_size('my-table') / 1024/1014; That really does not clear things up: 1) pg_total_relation_size measures the size of a relation(table) not the database. 2) The database is not empty if it has relation of size 200GB. 3) Just because a database grows big does not mean it is bloated. Include the output of the bloat query. > > 2) Dead tuples: select n_dead_tup,n_live_tup, n_tup_del, relname,* from pg_stat_all_tables where relname= (select REPLACE((SELECT cast (reltoastrelid::regclass as text) FROM pg_class WHERE relkind = 'r' AND reltoastrelid <> 0 and relname = 'my-table'),'pg_toast.','')); > We are only updating the blob so we are mostly interested in the toast By blob do you mean bytea or large objects? > > 3) In our load test, High Load means constantly updating a single record with a predefined payload (i.e. random bytearray of x MB) for x minutes. We update up to 60MB per second Do you do this all in one transaction? > 4) Postgres Version: 14.12-2 > 5) We are using default autovacuum-settings > > Best regards, > Manuel > > -----Original Message----- > From: Adrian Klaver > Sent: 04 July 2024 17:43 > To: Shenavai, Manuel ; pgsql-general > Subject: Re: Configure autovacuum > > On 7/4/24 08:16, Shenavai, Manuel wrote: >> We see that our DB keeps increasing under high load (many updates). We see that our DB has a size of 200GB and we got 199GB bloat, 0 dead tuple. And when the DB is put on high load (many updates), we still see that the DB size grows. We try to find parameters to avoid DB growth. > > Show your work: > > 1) How did you determine the bloat number? > > 2) How did you determine there are 0 dead tuples? > > 3) Define high load. > > 4) Postgres version? > > 5) What are your autovacuum settings? > > >> >> I think we need to tweak the autovacuum settings and maybe limit the volume of data that can be written to the DB. > > That will need to happen on client end. > >> >> Is there any setting in postgres that would allow to write only certain volume? For example, limit the amount of data that can be written to a table to 100MB/minute. >> >> Best regards, >> Manuel >> >> -----Original Message----- >> From: Adrian Klaver >> Sent: 14 June 2024 16:32 >> To: Shenavai, Manuel ; pgsql-general >> Subject: Re: Configure autovacuum >> >> On 6/13/24 23:20, Shenavai, Manuel wrote: >>> Hi everyone, >>> >>> I would like to configure the autovacuum in a way that it runs very >>> frequently (i.e. after each update-statement). I tried the following >> >> Why? >> >> What is the problem you are trying to solve? >> >>> settings on my table: >>> >>> alter table mytable set (autovacuum_vacuum_scale_factor  = 0.0); >>> >>> alter table mytable set (autovacuum_vacuum_cost_delay  = 0.0); >>> >>> alter table mytable set (autovacuum_vacuum_cost_limit  = 10000); >>> >>> alter table mytable set (autovacuum_vacuum_threshold  = 1); >>> >>> I do a lot of updates on a single tuple and I would expect that the >>> autovacuum would start basically after each update (due to >>> autovacuum_vacuum_threshold=1). But the autovacuum is not running. >>> >>> Is it possible to configure postgres to autovacuum very aggressively >>> (i.e. after each update-statement)? >>> >>> Thanks in advance & >>> >>> Best regards, >>> >>> Manuel >>> >> > -- Adrian Klaver adrian.klaver@aklaver.com