企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
       pg_test_fsync用于判断最快的`wal_sync_method`,还可以在发生认定的 I/O 问题时提供诊断信息。pg\_test\_fsync显示的区别可能不会在真实的数据库吞吐量上产生显著的区别,特别是由于 很多数据库服务器被它们的预写日志限制了速度。pg\_test\_fsync为`wal_sync_method`报告以微秒计的平均文件同步操作时间, 也能被用来提示用于优化`commit_delay`值的方法。 **命令格式:** pg_test_fsync [-f FILENAME] [-s SECS-PER-TEST] > **option:** > * **-f filename**:指定要写入测试数据到其中的文件名。这个文件必须位于和`pg_wal`目录所在或者将被放置的同一个文件系统中(`pg_wal`包含WAL文件)。默认是当前 目录中的pg_test_fsync.out > * **-s --secs-per-test**:指定每次测试的秒数。每个测试的时间越长,测试的精度就越高,但是 它需要更多时间来运行。默认是 5 秒,这允许程序在 2 分钟以内完成 > * **-v --version**:打印pg_test_fsync版本并且退出 > * **-? --help**:显示有关pg\_test\_fsync命令行参数的帮助并且退出 ``` // 命令实例 // ops/sec:每秒操作数 [postgres@izwz91quxhnlkan8kjak5hz ~]$ pg_test_fsync -s 10 10 seconds per test O_DIRECT supported on this platform for open_datasync and open_sync. Compare file sync methods using one 8kB write: (in wal_sync_method preference order, except fdatasync is Linux's default) open_datasync 869.351 ops/sec 1150 usecs/op fdatasync 868.032 ops/sec 1152 usecs/op fsync 315.819 ops/sec 3166 usecs/op fsync_writethrough n/a open_sync 318.236 ops/sec 3142 usecs/op Compare file sync methods using two 8kB writes: (in wal_sync_method preference order, except fdatasync is Linux's default) open_datasync 422.282 ops/sec 2368 usecs/op fdatasync 708.952 ops/sec 1411 usecs/op fsync 309.492 ops/sec 3231 usecs/op fsync_writethrough n/a open_sync 169.229 ops/sec 5909 usecs/op Compare open_sync with different write sizes: (This is designed to compare the cost of writing 16kB in different write open_sync sizes.) 1 * 16kB open_sync write 307.012 ops/sec 3257 usecs/op 2 * 8kB open_sync writes 160.402 ops/sec 6234 usecs/op 4 * 4kB open_sync writes 87.594 ops/sec 11416 usecs/op 8 * 2kB open_sync writes 42.867 ops/sec 23328 usecs/op 16 * 1kB open_sync writes 21.538 ops/sec 46430 usecs/op Test if fsync on non-write file descriptor is honored: (If the times are similar, fsync() can sync data written on a different descriptor.) write, fsync, close 331.295 ops/sec 3018 usecs/op write, close, fsync 322.619 ops/sec 3100 usecs/op Non-sync'ed 8kB writes: write 86980.000 ops/sec 11 usecs/op ```