Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BB33647600C for ; Thu, 12 Sep 2002 12:25:46 -0400 (EDT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id E0F81475FEB for ; Thu, 12 Sep 2002 12:25:44 -0400 (EDT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id g8CGPcf04332; Thu, 12 Sep 2002 12:25:38 -0400 (EDT) From: Bruce Momjian Message-Id: <200209121625.g8CGPcf04332@candle.pha.pa.us> Subject: Re: fsync or fdatasync In-Reply-To: To: Mats Lofkvist Date: Thu, 12 Sep 2002 12:25:38 -0400 (EDT) Cc: pgsql-admin@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/143 X-Sequence-Number: 5682 Mats Lofkvist wrote: > > Actually, no, we are only O_SYNC'ing the WAL writes and sometimes that > > is faster because you are not writing then fsyncing, you are just > > writing. The fdatasync only is better than O_SYNC when you are doing > > multiple WAL writes before an fdatasync and we normally don't do that. > > > > I may be wrong on this, but my understanding is that the difference > between fsync() and O_SYNC on the one hand and fdatasync() and O_DSYNC > on the other hand is that the latter don't have to sync metadata > (e.g. file access times) which saves a write to the inode that is > more or less guarantied to require an extra seek. > > Iff this is true you never want to use fsync() or O_SYNC when > fdatasync() and O_DSYNC is available (unless you really need the > metadata to be synced too). Yes, I didn't mention O_DSYNC. It is in the cards. If you are interested, look at the code and how the defaults are chosen. postgresql.conf say: #wal_sync_method = fsync # the default varies across platforms: # # fsync, fdatasync, open_sync, or open_datasync Which means exactly that, varies based on the platform. -- 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