Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7405847678B for ; Tue, 10 Sep 2002 11:40:43 -0400 (EDT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id A11F14766B8 for ; Tue, 10 Sep 2002 11:40:36 -0400 (EDT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id g8AFeOo21086; Tue, 10 Sep 2002 11:40:24 -0400 (EDT) From: Bruce Momjian Message-Id: <200209101540.g8AFeOo21086@candle.pha.pa.us> Subject: Re: fsync or fdatasync In-Reply-To: To: Gaetano Mendola Date: Tue, 10 Sep 2002 11:40:24 -0400 (EDT) Cc: pgsql-admin@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UNKNOWN-8BIT X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/107 X-Sequence-Number: 5646 The original poster was wrong about the default. We use fdatasync where available, and fsync when it is not. We also use O_SYNC on open if it is available. --------------------------------------------------------------------------- Gaetano Mendola wrote: > > "Tom Lane" wrote in message > news:11753.1031590251@sss.pgh.pa.us... > > "Gaetano Mendola" writes: > > > apparently the default value for wal_sync_method is fsync, > > > and apparently the best method is fdatasync. > > > > Best on what platform, and according to what evidence? > > Well, the man say ( Linux ): > > > fdatasync flushes all data buffers of a file to disk (before the system call > returns). It resembles fsync but is > not required to update the metadata such as access time. > > Applications that access databases or log files often write a tiny > data fragment (e.g., one line in a log file) > and then call fsync immediately in order to ensure that the > written data is physically stored on the harddisk. > Unfortunately, fsync will always initiate two write operations: one > for the newly written data and another one in > order to update the modification time stored in the inode. If the > modification time is not a part of the transac­ > tion concept fdatasync can be used to avoid unnecessary inode disk > write operations. > > > So, what is wrong here ? Seems clear that one write is better than two. > > Ciao > Gaetano > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073