{"id":23159,"date":"2019-09-20T12:00:30","date_gmt":"2019-09-20T03:00:30","guid":{"rendered":"https:\/\/www.techscore.com\/blog\/?p=23159"},"modified":"2019-09-17T09:59:48","modified_gmt":"2019-09-17T00:59:48","slug":"postgresql-%e3%80%8ceffective_io_concurrency%e3%80%8d%e3%81%ae%e8%a8%ad%e5%ae%9a%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2019\/09\/20\/postgresql-%e3%80%8ceffective_io_concurrency%e3%80%8d%e3%81%ae%e8%a8%ad%e5%ae%9a%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6\/","title":{"rendered":"PostgreSQL \u300ceffective_io_concurrency\u300d\u306e\u8a2d\u5b9a\u306b\u3064\u3044\u3066"},"content":{"rendered":"<p>PostgreSQL\u306e\u300ceffective_io_concurrency\u300d\u3068\u3044\u3046\u8a2d\u5b9a\u3092\u3054\u5b58\u77e5\u3067\u3057\u3087\u3046\u304b\uff1f<br \/>\nPostgreSQL\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u306f\u3001<\/p>\n<p><strong>\u300cPostgreSQL\u304c\u540c\u6642\u5b9f\u884c\u53ef\u80fd\u3067\u3042\u308b\u3068\u60f3\u5b9a\u3059\u308b\u540c\u6642\u30c7\u30a3\u30b9\u30afI\/O\u64cd\u4f5c\u306e\u6570\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u300d<\/strong><\/p>\n<p>\u3068\u3042\u308a\u307e\u3059\u3002<br \/>\n\u3068\u308a\u3042\u3048\u305a\u6709\u52b9\u306b\u3057\u3066\u304a\u3051\u3070\u540c\u6642\u5b9f\u884c\u3067\u306a\u3093\u304b\u901f\u305d\u3046\uff01\u3068\u3044\u3046\u5370\u8c61\u3092\u3046\u3051\u308b\u306e\u3067\u3059\u304c\u3001\u305d\u3093\u306a\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\uff01<br \/>\nPostgreSQL9.6\u4ee5\u4e0b\u306e\u5834\u5408\u306f\u30aa\u30d5\u306b\u3057\u305f\u65b9\u304c\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u826f\u3044\u30b1\u30fc\u30b9\u304c\u591a\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u306a\u305c\u30aa\u30d5\u306b\u3057\u305f\u65b9\u304c\u901f\u3044\u306e\u304b\u3001\u307f\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p><font color=\"red\"><br \/>\n\u203bPostgreSQL10\u4ee5\u964d\u3067\u5b9f\u88c5\u3055\u308c\u305f\u30d1\u30e9\u30ec\u30eb\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u30d2\u30fc\u30d7\u30b9\u30ad\u30e3\u30f3\u306b\u306f\u3042\u3066\u306f\u307e\u308a\u307e\u305b\u3093<br \/>\n\u203b\u5e38\u306b\u300c\u30aa\u30d5\u300d\u304c\u6700\u9069\u8a2d\u5b9a\u3068\u3044\u3046\u3053\u3068\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u30b7\u30b9\u30c6\u30e0\u69cb\u6210\u30fb\u30c7\u30fc\u30bf\u50be\u5411\u6b21\u7b2c\u3067\u3059<br \/>\n\u203b\u691c\u8a3c\u74b0\u5883\u306fCentOS7\u3001PostgreSQL9.6\u3067\u3059<br \/>\n<\/font><\/p>\n<h2>effective_io_concurrency\u3068\u306f\uff1f<\/h2>\n<p>\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u30d2\u30fc\u30d7\u30b9\u30ad\u30e3\u30f3\u6642\u306b\u3001\u30b9\u30c8\u30ec\u30fc\u30b8\u304b\u3089\u306e\u30c7\u30fc\u30bf\u8aad\u307f\u8fbc\u307fIO\u3092\u3001\u30c7\u30fc\u30bf\u306e\u51e6\u7406\u3068\u4e26\u884c\u3055\u305b\u308b\u3053\u3068\u3067\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u5411\u4e0a\u3092\u72d9\u3046\u3082\u306e\u3067\u3001\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u30d2\u30fc\u30d7\u30b9\u30ad\u30e3\u30f3\u5c02\u7528\u306e\u8a2d\u5b9a\u3067\u3059\u3002<br \/>\neffective_io_concurrency\u30921\u4ee5\u4e0a\u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u6709\u52b9\u3068\u306a\u308a\u3001\u6700\u5927\u306f1000\u3067\u3059\u3002\u8a2d\u5b9a\u5024\u3092\u4e0a\u3052\u308b\u307b\u3069\u3088\u308a\u591a\u304f\u306e\u30c7\u30fc\u30bf\u3092\u975e\u540c\u671f\u3067\u8aad\u307f\u8fbc\u3080\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n0\u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u975e\u540c\u671fIO\u3092\u7121\u52b9\u5316\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u3069\u3046\u3084\u3063\u3066\u975e\u540c\u671f\u3067\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080\u306e\u304b\uff1f<\/h2>\n<p>\u305a\u3070\u308a\u3001posix_fadvise\u95a2\u6570\u3067\u3059\u3002\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306b\u306f\u5c06\u6765\u7684\u306b\u5225\u306e\u5b9f\u88c5\u3082\u691c\u8a0e\u3057\u305f\u3044\u3068\u30b3\u30e1\u30f3\u30c8\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u73fe\u6642\u70b9\u3067\u306f\u3042\u308a\u307e\u305b\u3093\u3002<br \/>\n\u305d\u306e\u305f\u3081\u3001posix_fadvise\u95a2\u6570\u304c\u5229\u7528\u3067\u304d\u306a\u3044\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u52d5\u4f5c\u3057\u307e\u305b\u3093\u3002<\/p>\n<p>posix_fadvise\u95a2\u6570\u3068\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u30ab\u30fc\u30cd\u30eb\u306b\u3001\u6b21\u306b\u884c\u3046\u4e88\u5b9a\u306e\u30b9\u30c8\u30ec\u30fc\u30b8\u30a2\u30af\u30bb\u30b9\u3092\u77e5\u3089\u305b\u308b\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u3002<br \/>\n\u3053\u308c\u306b\u3088\u308a\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u304c\u5b9f\u969b\u306b\u30b9\u30c8\u30ec\u30fc\u30b8\u30a2\u30af\u30bb\u30b9\u3092\u884c\u3046\u307e\u3067\u306e\u9593\u306b\u30ab\u30fc\u30cd\u30eb\u304c\u5148\u884c\u3057\u3066\u6e96\u5099\u3092\u9032\u3081\u308b\u3053\u3068\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305f\u3068\u3048\u3070\u3001posix_fadvice(fd, 0, 8192, POSIX_FADV_WILLNEED)\u3068\u3059\u308b\u3068\u3001<br \/>\n\u30ab\u30fc\u30cd\u30eb\u304c\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30bffd\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5148\u982d\u304b\u30898KB\u3092\u30da\u30fc\u30b8\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<br \/>\n\u3053\u306e\u3042\u3068\u306bread()\u3059\u308b\u3068\u3001\u3059\u3067\u306b\u30da\u30fc\u30b8\u30ad\u30e3\u30c3\u30b7\u30e5\u306b\u8aad\u307f\u8fbc\u307e\u308c\u3066\u3044\u308b\u305f\u3081\u3001\u30c7\u30a3\u30b9\u30af\u30a2\u30af\u30bb\u30b9\u304c\u767a\u751f\u3059\u308b\u3053\u3068\u306a\u304f\u5373\u5ea7\u306b\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\uff08read()\u307e\u3067\u306b\u30ab\u30fc\u30cd\u30eb\u306e\u51e6\u7406\u304c\u9593\u306b\u5408\u3063\u3066\u3044\u308c\u3070\uff09<\/p>\n<p>PostgreSQL\u306f\u307e\u3055\u306b\u3053\u308c\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002\u30c7\u30fc\u30bf\u51e6\u7406\u3092\u884c\u3046\u969b\u306b\u6b21\u306b\u8aad\u307f\u8fbc\u3080\u4e88\u5b9a\u306e\u30da\u30fc\u30b8\u3092posix_fadvise\u3067\u30ab\u30fc\u30cd\u30eb\u306b\u77e5\u3089\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u3067\u3001\u4f55\u304c\u554f\u984c\u306a\u306e\uff1f<\/h2>\n<p>\u3068\u3066\u3082\u52b9\u7387\u7684\u306b\u898b\u3048\u308b\u306e\u3067\u3059\u304c\u3001\u9006\u306b\u3068\u3066\u3082\u975e\u52b9\u7387\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u30b1\u30fc\u30b9\u304c\u3042\u308b\u3093\u3067\u3059\u3002<br \/>\n\u305d\u308c\u306f\u300c\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u30d2\u30fc\u30d7\u30b9\u30ad\u30e3\u30f3\u3067\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30da\u30fc\u30b8\u306e\u591a\u304f\u304c\u96a3\u63a5\u3057\u3066\u3044\u308b\u5834\u5408\u300d\u3067\u3059\u3002<br \/>\n\u96a3\u63a5\u3057\u3066\u3044\u308b\u3001\u3064\u307e\u308a\u3001\u30b9\u30c8\u30ec\u30fc\u30b8\u30a2\u30af\u30bb\u30b9\u304c\u30b7\u30fc\u30b1\u30f3\u30b7\u30e3\u30eb\u30ea\u30fc\u30c9\u306b\u306a\u308b\u5834\u5408\u3067\u3059\u3002<\/p>\n<p>PostgreSQL\u306f\u5e38\u306b\u30da\u30fc\u30b8\u30b5\u30a4\u30ba\u3067\u3042\u308b8KB\u5358\u4f4d\u3067read\/write\u3092\u3057\u307e\u3059\u3002\u305f\u3068\u3048\u3070\u8aad\u307f\u53d6\u308b\u4e88\u5b9a\u306e\u30da\u30fc\u30b8\u304c16\u500b\u96a3\u63a5\u3057\u3066\u3044\u305f\u5834\u5408\u3001128KB\u306eread()\u4e00\u56de\u3067\u6e08\u307f\u307e\u3059\u304c\u3001PostgreSQL\u3067\u306f8KB\u306eread()\u309216\u56de\u5b9f\u884c\u3057\u307e\u3059\u3002<br \/>\n\u3068\u3066\u3082\u975e\u52b9\u7387\u306b\u898b\u3048\u307e\u3059\u304c\u3001\u5b9f\u969b\u306fOS\u306e\u6a5f\u80fd\u3067\u30ab\u30d0\u30fc\u3055\u308c\u308b\u305f\u3081\u3001\u307b\u3068\u3093\u3069\u554f\u984c\u306b\u306a\u308a\u307e\u305b\u3093\u3002<br \/>\nLinux\u306b\u306f\u300cread_ahead_kb\u300d\u3068\u3044\u3046\u8a2d\u5b9a\u304c\u3042\u308a\u307e\u3059\u3002\u30b7\u30fc\u30b1\u30f3\u30b7\u30e3\u30eb\u30ea\u30fc\u30c9\u304c\u7d9a\u304f\u5834\u5408\u3001\u3053\u306e\u8a2d\u5b9a\u306b\u3082\u3068\u3065\u3044\u3066\u30ab\u30fc\u30cd\u30eb\u306fread()\u3067\u6307\u5b9a\u3055\u308c\u305f\u30a2\u30c9\u30ec\u30b9\u4ee5\u964d\u306e\u30c7\u30fc\u30bf\u3092\u4e00\u62ec\u3067\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<br \/>\n\u305d\u306e\u305f\u3081\u3001PostgreSQL\u304cread()\u309216\u56de\u5b9f\u884c\u3057\u305f\u3068\u3057\u3066\u3082\u3001\u5b9f\u969b\u306b\u30b9\u30c8\u30ec\u30fc\u30b8\u306b16\u56deIO\u304c\u767a\u884c\u3055\u308c\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u304a\u305d\u3089\u304f\u305b\u3044\u305c\u3044\uff12\uff5e\uff13\u56de\u3067\u3059\u3002<\/p>\n<p>\u304c\u3001\u3053\u3053\u3067\u554f\u984c\u304c\u767a\u751f\u3057\u307e\u3059\u3002posix_fadvice\u306b\u3088\u308b\u5148\u8aad\u307f\u3067\u3059\u3002<br \/>\nPostgreSQL\u306f\u5148\u306b\u66f8\u3044\u305f\u3088\u3046\u306bposix_fadvice\u3067\u5148\u8aad\u307f\u3092\u884c\u3044\u307e\u3059\u304c\u3001\u3053\u308c\u3082\u5e38\u306b8KB\u5358\u4f4d\u3067\u3059\u3002\u9023\u7d9a\u3057\u305f\u9818\u57df\u306b\u5bfe\u3057\u3066posix_fadvice\u3092\u5b9f\u884c\u3057\u3066\u3082\u3001OS\u306fread()\u306e\u3068\u304d\u306e\u3088\u3046\u306b\u5148\u8aad\u307f\u3059\u308b\u3053\u3068\u306f\u306a\u304f\u3001\u305d\u306e\u307e\u307e8KB\u3067IO\u3092\u767a\u884c\u3057\u307e\u3059\u3002<br \/>\n\u7d50\u679c\u3001\u672c\u6765\u3067\u3042\u308c\u3070OS\u306e\u6a5f\u80fd\u306b\u3088\u308a\u6291\u3048\u3089\u308c\u308bIO\u767a\u884c\u56de\u6570\u304c\u6570\u500d\u3001\u6570\u5341\u500d\u306b\u3082\u3075\u304f\u308c\u3042\u304c\u308a\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u5927\u304d\u304f\u60aa\u5316\u3057\u307e\u3059\u3002<\/p>\n<h2>\u5b9f\u969b\u306b\u8a66\u3057\u3066\u307f\u308b<\/h2>\n<p>\u5b9f\u969b\u306b\u518d\u73fe\u3055\u305b\u3066\u307f\u307e\u3059\u3002\u30c6\u30b9\u30c8\u3068\u3057\u3066\u4ee5\u4e0b\u306e\u30c6\u30fc\u30d6\u30eb\u3092\u7528\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">test=# CREATE TABLE foobar(id serial primary key, created_at timestamp, data text);\n<\/pre>\n<p>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3068\u3057\u3066500\u4e07\u4ef6\u6295\u5165\u3057\u307e\u3059\u3002\u6295\u5165\u3059\u308b\u30c7\u30fc\u30bf\u306fcreated_at\u304c1\u79d2\u305a\u3064\u9032\u307f\u3001data\u306f\u3059\u3079\u3066\u540c\u3058900Byte\u306e'A'\u304c\u4e26\u3093\u3060\u30c7\u30fc\u30bf\u3092\u7528\u610f\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u30671\u30da\u30fc\u30b8\u306b\u3061\u3087\u3046\u30698\u884c\u5165\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf<\/p>\n<pre>\"2019-01-01 00:00:01\",\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n\"2019-01-01 00:00:02\",\"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n\u30fb\n\u30fb\n\u30fb\n<\/pre>\n<p>\u30b3\u30d4\u30fc\u3067\u6295\u5165\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">test=# \\copy foobar (created_at,data) FROM '5000000.csv' CSV;\nCOPY 5000000\n<\/pre>\n<p>\u30c6\u30fc\u30d6\u30eb\u30d5\u30a1\u30a4\u30eb\u3092\u78ba\u8a8d\u3057\u307e\u3059\u30021\u30da\u30fc\u30b8\u306b8\u884c\u5165\u308b\u30c7\u30fc\u30bf\u3092500\u4e07\u4ef6\u6295\u5165\u3057\u305f\u306e\u3067\u3001\u8a08625000\u30da\u30fc\u30b8\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u306f625000 * 8192 = 5120000000Byte\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">test=# SELECT * FROM (SELECT datid FROM pg_stat_database WHERE datname = 'test') db CROSS JOIN (SELECT relfilenode FROM pg_class WHERE relname = 'foobar') tbl;\n datid | relfilenode\n-------+-------------\n 16384 |       16407\n\n[postgres@testdb]$  ll  data\/base\/16384\/16407{,.*}\n-rw------- 1 postgres postgres 1073741824  9\u6708  5 10:49 data\/base\/16384\/16407\n-rw------- 1 postgres postgres 1073741824  9\u6708  5 10:49 data\/base\/16384\/16407.1\n-rw------- 1 postgres postgres 1073741824  9\u6708  5 10:49 data\/base\/16384\/16407.2\n-rw------- 1 postgres postgres 1073741824  9\u6708  5 10:50 data\/base\/16384\/16407.3\n-rw------- 1 postgres postgres  825032704  9\u6708  5 10:50 data\/base\/16384\/16407.4\n<\/pre>\n<p>\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u30d2\u30fc\u30d7\u30b9\u30ad\u30e3\u30f3\u3092\u767a\u751f\u3055\u305b\u308b\u305f\u3081\u3001created_at\u306bbrin\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u306f\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">test=# CREATE INDEX foobar_created_at_brin ON foobar USING brin(created_at);\nCREATE INDEX\n<\/pre>\n<p>\u3044\u3088\u3044\u3088\u5b9f\u9a13\u3067\u3059\uff01<br \/>\n\u307e\u305a\u306feffective_io_concurrency\u30921\u3067\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">test=# set effective_io_concurrency=1;\nSET\n\ntest=# EXPLAIN ANALYZE SELECT COUNT(*) FROM foobar WHERE created_at &gt; '2019-02-01' AND id % 2 = 0;\n                                                                      QUERY PLAN\n-------------------------------------------------------------------------------------------------------------------------------------------------------\n Aggregate  (cost=682865.26..682865.27 rows=1 width=8) (actual time=20898.775..20898.775 rows=1 loops=1)\n   -&gt;  Bitmap Heap Scan on foobar  (cost=17414.54..682836.39 rows=11549 width=0) (actual time=84.223..20722.441 rows=1160800 loops=1)\n         Recheck Cond: (created_at &gt; '2019-02-01 00:00:00'::timestamp without time zone)\n         Rows Removed by Index Recheck: 640\n         Filter: ((id % 2) = 0)\n         Rows Removed by Filter: 1160800\n         Heap Blocks: lossy=290280\n         -&gt;  Bitmap Index Scan on foobar_created_at_brin  (cost=0.00..17411.65 rows=2309820 width=0) (actual time=60.019..60.019 rows=2903040 loops=1)\n               Index Cond: (created_at &gt; '2019-02-01 00:00:00'::timestamp without time zone)\n Planning time: 0.095 ms\n Execution time: 20898.836 ms\n(11 rows)\n<\/pre>\n<p>\u7d0420\u79d2\u304b\u304b\u308a\u307e\u3057\u305f\u3002\u3053\u306e\u3068\u304d\u3001\u30b9\u30c8\u30ec\u30fc\u30b8\u3078\u306eIO\u767a\u884c\u72b6\u6cc1\u306f\u4ee5\u4e0b\u3067\u3059\u3002<br \/>\n(blktrace\/blkparse\u3067\u53d6\u5f97\uff09<\/p>\n<pre class=\"lang:sh decode:true \">253,1    1    32703     4.847592450 14489  Q   R 66304224 + 16 [postgres]\n253,1    1    32704     4.847642966     0  C   R 66304224 + 16 [0]\n253,1    1    32705     4.847658615 14489  Q   R 66304240 + 16 [postgres]\n253,1    1    32706     4.847708921     0  C   R 66304240 + 16 [0]\n253,1    1    32707     4.847727665 14489  Q   R 66304256 + 16 [postgres]\n253,1    1    32708     4.847778924     0  C   R 66304256 + 16 [0]\n253,1    1    32709     4.847794801 14489  Q   R 66304272 + 16 [postgres]\n253,1    1    32710     4.847846454     0  C   R 66304272 + 16 [0]\n253,1    1    32711     4.847862889 14489  Q   R 66304288 + 16 [postgres]\n253,1    1    32712     4.847914285     0  C   R 66304288 + 16 [0]\n253,1    1    32713     4.847930219 14489  Q   R 66304304 + 16 [postgres]\n253,1    1    32714     4.847981493     0  C   R 66304304 + 16 [0]\n253,1    1    32715     4.847997950 14489  Q   R 66304320 + 16 [postgres]\n253,1    1    32716     4.848048647     0  C   R 66304320 + 16 [0]\n\n<\/pre>\n<p>+16\u3068\u306a\u3063\u3066\u3044\u308b\u306e\u306f512Byte\u8a08\u7b97\u3067\u30018KB\u306e\u3053\u3068\u3067\u3059\u30028KB\u306e\u8aad\u307f\u8fbc\u307fIO\u304c\u7d9a\u3044\u3066\u3044\u308b\u306e\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>strace\u3067\u307f\u3066\u307f\u308b\u3068\u3001posix_fadvice\u306b\u5bfe\u5fdc\u3059\u308b\u30b7\u30b9\u30c6\u30e0\u30b3\u30fc\u30ebfadvise64\u304c8KB\u3067\u9023\u7d9a\u3057\u305f\u9818\u57df\u306b\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">fadvise64(32, 871890944, 8192, POSIX_FADV_WILLNEED) = 0\nfadvise64(32, 871899136, 8192, POSIX_FADV_WILLNEED) = 0\nfadvise64(32, 871907328, 8192, POSIX_FADV_WILLNEED) = 0\nfadvise64(32, 871915520, 8192, POSIX_FADV_WILLNEED) = 0\nfadvise64(32, 871923712, 8192, POSIX_FADV_WILLNEED) = 0\nfadvise64(32, 871931904, 8192, POSIX_FADV_WILLNEED) = 0\nfadvise64(32, 871940096, 8192, POSIX_FADV_WILLNEED) = 0\nfadvise64(32, 871948288, 8192, POSIX_FADV_WILLNEED) = 0\nfadvise64(32, 871956480, 8192, POSIX_FADV_WILLNEED) = 0\nfadvise64(32, 871964672, 8192, POSIX_FADV_WILLNEED) = 0\nfadvise64(32, 871972864, 8192, POSIX_FADV_WILLNEED) = 0\n<\/pre>\n<p>\u3067\u306f\u6b21\u306beffective_io_concurrency\u30920\u3067\u8a66\u3057\u3066\u307f\u307e\u3059\u3002\uff08\u30ad\u30e3\u30c3\u30b7\u30e5\u7b49\u306f\u3059\u3079\u3066\u30af\u30ea\u30a2\u3057\u305f\u3046\u3048\u3067\uff09<\/p>\n<pre class=\"lang:sh decode:true \">test=# set effective_io_concurrency=0;\nSET\n\ntest=# EXPLAIN ANALYZE SELECT COUNT(*) FROM foobar WHERE created_at &gt; '2019-02-01' AND id % 2 = 0;\n                                                                      QUERY PLAN\n-------------------------------------------------------------------------------------------------------------------------------------------------------\n Aggregate  (cost=682865.26..682865.27 rows=1 width=8) (actual time=3625.882..3625.882 rows=1 loops=1)\n   -&gt;  Bitmap Heap Scan on foobar  (cost=17414.54..682836.39 rows=11549 width=0) (actual time=28.424..3529.730 rows=1160800 loops=1)\n         Recheck Cond: (created_at &gt; '2019-02-01 00:00:00'::timestamp without time zone)\n         Rows Removed by Index Recheck: 640\n         Filter: ((id % 2) = 0)\n         Rows Removed by Filter: 1160800\n         Heap Blocks: lossy=290280\n         -&gt;  Bitmap Index Scan on foobar_created_at_brin  (cost=0.00..17411.65 rows=2309820 width=0) (actual time=22.098..22.098 rows=2903040 loops=1)\n               Index Cond: (created_at &gt; '2019-02-01 00:00:00'::timestamp without time zone)\n Planning time: 0.097 ms\n Execution time: 3625.937 ms\n(11 rows)\n<\/pre>\n<p>\u5287\u7684\u6539\u5584\u3067\u3059\uff013\u79d2\u5f37\u306b\u306a\u308a\u307e\u3057\u305f\uff01<\/p>\n<p>\u3053\u306e\u3068\u304d\u306e\u30b9\u30c8\u30ec\u30fc\u30b8\u3078\u306eIO\u767a\u884c\u72b6\u6cc1\u306f\u4ee5\u4e0b\u3067\u3059\u3002<\/p>\n<pre class=\"lang:sh decode:true \">253,1    1     3306     2.360343529 16694  Q   R 63859640 + 1024 [postgres]\n253,1    1     3307     2.360385438 16694  Q   R 63860664 + 1024 [postgres]\n253,1    1     3308     2.360436292 16694  Q   R 63861688 + 1024 [postgres]\n253,1    1     3309     2.360477008 16694  Q   R 63862712 + 1024 [postgres]\n253,1    1     3310     2.360517538 16694  Q   R 63863736 + 1024 [postgres]\n253,1    1     3311     2.360558272 16694  Q   R 63864760 + 1024 [postgres]\n253,1    1     3312     2.360603382 16694  Q   R 63865784 + 1024 [postgres]\n253,1    1     3313     2.360642645 16694  Q   R 63866808 + 1024 [postgres]\n253,1    1     3314     2.360682197 16694  Q   R 63867832 + 1024 [postgres]\n253,1    1     3315     2.360727269 16694  Q   R 63868856 + 1024 [postgres]\n253,1    1     3316     2.360767066 16694  Q   R 63869880 + 1024 [postgres]\n253,1    1     3317     2.360806320 16694  Q   R 63870904 + 1024 [postgres]\n<\/pre>\n<p>\u5148\u307b\u3069\u306e8KB\u306e\u30ea\u30fc\u30c9\u304c\u4e26\u3093\u3067\u3044\u305f\u306e\u3068\u306f\u9055\u3044\u3001512KB\u306e\u30ea\u30fc\u30c9\u304c\u4e26\u3093\u3067\u3044\u307e\u3059\u3002<br \/>\n\u304b\u306a\u308a\u767a\u884cIO\u6570\u3092\u6e1b\u3089\u305b\u3066\u3044\u305d\u3046\u3067\u3059\u3002<\/p>\n<h2>\u6700\u5f8c\u306b<\/h2>\n<p>\u4eca\u56de\u306e\u5b9f\u9a13\u3067\u306f\u78ba\u5b9f\u306b\u30c7\u30fc\u30bf\u304c\u96a3\u63a5\u3057\u3066\u3044\u308b\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u30d2\u30fc\u30d7\u30b9\u30ad\u30e3\u30f3\u3068\u306a\u308b\u3088\u3046\u610f\u56f3\u7684\u306b\u30c7\u30fc\u30bf\u3092\u7528\u610f\u3057\u305f\u305f\u3081\u3001\u9855\u8457\u306b\u9055\u3044\u304c\u3067\u307e\u3057\u305f\u3002<br \/>\n\u5b9f\u969b\u306b\u904b\u7528\u3057\u3066\u3044\u308b\u30b7\u30b9\u30c6\u30e0\u3067\u306f\u3053\u3053\u307e\u3067\u30c7\u30fc\u30bf\u304c\u96a3\u63a5\u3059\u308b\u3053\u3068\u306f\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u30d2\u30fc\u30d7\u30b9\u30ad\u30e3\u30f3\u306f\u30b9\u30ad\u30e3\u30f3\u958b\u59cb\u524d\u306b\u30da\u30fc\u30b8\u4f4d\u7f6e\u9806\u306b\u30bd\u30fc\u30c8\u3059\u308b\u305f\u3081\u3001\u6975\u7aef\u306b\u30e9\u30f3\u30c0\u30e0\u30a2\u30af\u30bb\u30b9\u306b\u306a\u308b\u3053\u3068\u3082\u5c11\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u305d\u306e\u305f\u3081\u3001effective_io_concurrency\u7121\u52b9\u5316\u306f\u5341\u5206\u306b\u8a66\u3059\u4fa1\u5024\u304c\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u7279\u5b9a\u306e\u30af\u30a8\u30ea\u3060\u3051\u5b9f\u884c\u524d\u306bSET\u3067\u30aa\u30d5\u306b\u3059\u308b\u3068\u3044\u3046\u306e\u3082\u30a2\u30ea\u3067\u3059\u306d\u3002<\/p>\n<p>PostgreSQL10\u4ee5\u964d\u3067\u8a66\u3057\u305f\u3068\u3053\u308d\u3001\u30d1\u30e9\u30ec\u30eb\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u30d2\u30fc\u30d7\u30b9\u30ad\u30e3\u30f3\u306e\u5834\u5408\u306feffective_io_concurrency\u30921\u306b\u3057\u3066\u3082read_ahead\u304c\u6a5f\u80fd\u3057\u3066\u3044\u307e\u3057\u305f\u3002<br \/>\n\u30d1\u30e9\u30ec\u30eb\u3067\u306a\u3044\u5834\u5408\u306f9\u7cfb\u307e\u3067\u3068\u540c\u3058\u6319\u52d5\u3068\u306a\u308b\u306e\u3067\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PostgreSQL\u306e\u300ceffective_io_concurrency\u300d\u3068\u3044\u3046\u8a2d\u5b9a\u3092\u3054\u5b58\u77e5\u3067\u3057\u3087\u3046\u304b\uff1f<br \/>\nPostgreSQL\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u306f\u3001<\/p>\n<p>\u300cPostgreSQL\u304c\u540c\u6642\u5b9f\u884c\u53ef\u80fd\u3067\u3042\u308b\u3068\u60f3\u5b9a\u3059<br \/><a href=\"https:\/\/www.techscore.com\/blog\/2019\/09\/20\/postgresql-%e3%80%8ceffective_io_concurrency%e3%80%8d%e3%81%ae%e8%a8%ad%e5%ae%9a%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6\/\">\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[62,18],"tags":[23,206],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/23159"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=23159"}],"version-history":[{"count":13,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/23159\/revisions"}],"predecessor-version":[{"id":23424,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/23159\/revisions\/23424"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=23159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=23159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=23159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}