]> granicus.if.org Git - postgresql/blob - doc/README.fsync
Minor cleanup in markup, especially in the Output section.
[postgresql] / doc / README.fsync
1 Fsync() patch (backend -F option)
2 =================================
3
4 Normally, the Postgres'95 backend makes sure that updates are actually
5 committed to disk by calling the standard function fsync() in
6 several places. Fsync() should guarantee that every modification to
7 a certain file is actually written to disk and will not hang around
8 in write caches anymore. This increases the chance that a database
9 will still be usable after a system crash by a large amount.
10
11 However, this operation severely slows down Postgres'95, because at all
12 those points it has to wait for the OS to flush the buffers. Especially
13 in one-shot operations, like creating a new database or loading lots
14 of data, you'll have a clear restart point if something goes wrong. That's
15 where the -F option kicks in: it simply disables the calls to fsync(). 
16
17 Without fsync(), the OS is allowed to do its best in buffering, sorting
18 and delaying writes, so this can be a _very_ big perfomance increase. However,
19 if the system crashes, large parts of the latest transactions will still hang
20 around in memory without having been committed to disk - lossage of data
21 is therefore almost certain to occur.
22
23 So it's a tradeoff between data integrity and speed. When initializing a
24 database, I'd use it - if the machine crashes, you simply remove the files
25 created and redo the operation. The same goes for bulk-loading data: on
26 a crash, you remove the database and restore the backup you made before
27 starting the bulk-load (you always make backups before bulk-loading,
28 don't you?).
29
30 Whether you want to use it in production, is up to you. If you trust your
31 operating system, your utility company, and your hardware, you might enable
32 it; however, keep in mind that you're running in an unsecure mode and that
33 performance gains will very much depend on access patterns (because it won't
34 help on reading data). I'd recommend against it.