Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1puco7-0000wA-1P for pgsql-performance@arkaria.postgresql.org; Thu, 04 May 2023 17:31:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1puco5-0000Do-UD for pgsql-performance@arkaria.postgresql.org; Thu, 04 May 2023 17:31:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1puco5-0000De-I4 for pgsql-performance@lists.postgresql.org; Thu, 04 May 2023 17:31:53 +0000 Received: from web.profivps.hu ([2a02:730:1220::87]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1puco1-000WQJ-Uq for pgsql-performance@lists.postgresql.org; Thu, 04 May 2023 17:31:52 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by web.profivps.hu (Postfix) with ESMTP id B182152C0EC7 for ; Thu, 4 May 2023 19:31:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=profivps.hu; h= content-type:content-type:organization:message-id:user-agent :subject:subject:from:from:date:date:mime-version; s=default; t= 1683221505; x=1685035906; bh=hwVMxyYy5nuNgmpS6GSwk4djUDz6Sssre+l QviC5ad4=; b=Xox7C3Cq5UO/UuhY8pYh3hU0Vqq7M3555z48lv+pyKp2aoCklRs yK6mej0XZrtBLbnvNgbqbx0X3wD3Vup+yc8yb/zc6mocs/AVysDQMRzcf7Xfewr/ AdwW9TIohWHY77mZxFmA/QJ2cLZWGVFLETHWE2VFTwyI2LgytWFRYmGQQQB/GXtq 5WGDDKBTnyBp2NDhOOfrnLavn9EWd9Gl8Vlv9Uk4Cff+WspHrbf4LADwvORp930p 5DZkZb+1DaGMGPz58Na/jC7V24yMlwmH7yWrZ1vEAYkNqIBBj7QDXDtHHHPxcUNs zUQY0xCV4nhfFyC7cgcPDwhDPI2n2a3coGA== X-Virus-Scanned: amavisd-new at web.profivps.hu Received: from web.profivps.hu ([127.0.0.1]) by localhost (web.profivps.hu [127.0.0.1]) (amavisd-new, port 10026) with LMTP id whlYRtPBYsTX for ; Thu, 4 May 2023 19:31:45 +0200 (CEST) Received: from profivps.hu (localhost [IPv6:::1]) by web.profivps.hu (Postfix) with ESMTP id 4BC9452C0EA4 for ; Thu, 4 May 2023 19:31:45 +0200 (CEST) MIME-Version: 1.0 Date: Thu, 04 May 2023 19:31:45 +0200 From: ProfiVPS Support To: pgsql-performance@lists.postgresql.org Subject: Fsync IO issue User-Agent: Roundcube Webmail/1.4.11 Message-ID: <060c533e971eec98e1f179a2b2846454@profivps.hu> X-Sender: support@profivps.hu Organization: ProfiVPS.hu Content-Type: multipart/alternative; boundary="=_2e9186444c9bdebb9502bc0f7fb8e5b3" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=_2e9186444c9bdebb9502bc0f7fb8e5b3 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi there, I've been struggling with very high write load on a server. We are collecting around 400k values each 5 minutes into a hypertable.=20 (We use timescaledb extension, I also shared this on timescale forum but=20 then I realised the issue is postgresql related.) When running iostat I see a constant 7-10MB/s write by postgres, and=20 this just doesn't add up for me and I'm fully stuck with this. Even=20 with the row overhead it should be around 20Mb / 5 mins ! Even with=20 indeces this 7-10MB/s constant write is inexplicable for me. The writes may trigger an update in an other table, but not all of=20 them do (I use a time filter). Let's say 70% does (which I dont think).=20 There we update two timestamps, and two ints. This still doesnt add up=20 for me. Even if we talk about 50MB of records, that should be 0,16MB/s=20 at most! So I dag in and found it was WAL, of course, what else. Tweaking all around the config, reading forums and docs, to no avail.=20 The only thing that made the scenario realistic is disabling fsync=20 (which I know I must not, but for the experiment I did). That eased the=20 write load to 0.6MB/s. I also found that the 16MB WAL segment got 80+ MB written into it=20 before being closed. So what's happening here? Does fsync cause the=20 whole file to be written out again and again? I checked with pg_dump, the content is as expected. We are talking about some insane data overhead here, two magnitudes=20 more is being written to WAL than the actual useful data. All help is greatly appreciated. Thanks! Andr=C3=A1s --- Olcs=C3=B3 Virtu=C3=A1lis szerver: http://www.ProfiVPS.hu T=C3=A1mogat=C3=A1s: Support@ProfiVPS.hu --=_2e9186444c9bdebb9502bc0f7fb8e5b3 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8

Hi there, 

 I've been struggling with very high write load on a server. <= /p>

 We are collecting around 400k values each 5 minutes into a h= ypertable. (We use timescaledb extension, I also shared this on timescale f= orum but then I realised the issue is postgresql related.) 

 When running iostat I see a constant 7-10MB/s write by postgres, a= nd this just doesn’t add up for me 3D":frowning:" and I’m fully stuck with this. Even with the = row overhead it should be around 20Mb / 5 mins ! Even with indeces this 7-1= 0MB/s constant write is inexplicable for me.

  The writes may trigger an update in an other table, but not all o= f them do (I use a time filter). Let’s say 70% does (which I dont thi= nk). There we update two timestamps, and two ints. This still doesnt add up= for me. Even if we talk about 50MB of records, that should be 0,16MB/s at = most!

 So I dag in and found it was WAL, of course, what else. 

 Tweaking all around the config, reading forums and docs, to no ava= il. The only thing that made the scenario realistic is disabling fsync (whi= ch I know I must not, but for the experiment I did). That eased the write l= oad to 0.6MB/s.

 I also found that the 16MB WAL segment got 80+ MB written into it = before being closed. So what's happening here? Does fsync cause the whole f= ile to be written out again and again? 

 I checked with pg_dump, the content is as expected. 

 We are talking about some insane data overhead here, two magnitude= s more is being written to WAL than the actual useful data. 


All help is greatly appreciated. 

Thanks!

András



---
Olcsó Virtuális szerver:
http://www.Pr= ofiVPS.hu

Támogatás: Support@ProfiVPS.hu
--=_2e9186444c9bdebb9502bc0f7fb8e5b3--