{"id":320,"date":"2014-07-14T10:00:26","date_gmt":"2014-07-14T01:00:26","guid":{"rendered":"http:\/\/www.skyarch.net\/blog\/?p=320"},"modified":"2014-09-10T21:05:09","modified_gmt":"2014-09-10T12:05:09","slug":"postgresql%e3%81%aeautovacuum%e3%82%92%e7%89%b9%e5%ae%9a%e3%83%86%e3%83%bc%e3%83%96%e3%83%ab%e3%81%a7off%e3%81%ab%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/postgresql%e3%81%aeautovacuum%e3%82%92%e7%89%b9%e5%ae%9a%e3%83%86%e3%83%bc%e3%83%96%e3%83%ab%e3%81%a7off%e3%81%ab%e3%81%99%e3%82%8b\/","title":{"rendered":"PostgreSQL\u306eautovacuum\u3092\u7279\u5b9a\u30c6\u30fc\u30d6\u30eb\u3067Off\u306b\u3059\u308b"},"content":{"rendered":"<h1>\u76ee\u7684<\/h1>\n<p>\u7279\u5b9a\u6642\u9593\u306b\u30b5\u30a4\u30c8\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u843d\u3061\u3066\u3057\u307e\u3046\u4e8b\u3092\u9632\u6b62\u3057\u305f\u3044<\/p>\n<p>\u5b9f\u969b\u306b\u306f\u30b5\u30a4\u30c8\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u7570\u69d8\u306b\u9045\u3044\u4e8b\u304c\u3042\u308a\u30ed\u30b0\u3092\u898b\u305f\u3068\u3053\u308d<br \/>\nautovacuum\u304c\u5b9f\u65bd\u3055\u308c\u3066\u3044\u305f\u30b1\u30fc\u30b9\u304c\u591a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h1>\u74b0\u5883<\/h1>\n<p>EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3088\u308a pgbench\u3092\u5b9f\u884c<br \/>\nRDS PostgreSQL<\/p>\n<table>\n<thead>\n<tr>\n<th align=\"left\">\u8a2d\u5b9a\u9805\u76ee<\/th>\n<th align=\"left\">\u5024<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td align=\"left\">DB\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9<\/td>\n<td align=\"left\">pgsql-test.xxxxx.ap-northeast-1.rds.amazonaws.com<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">DB<\/td>\n<td align=\"left\">testdb<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u30e6\u30fc\u30b6<\/td>\n<td align=\"left\">pguser<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u3053\u3061\u3089\u306e\u30a8\u30f3\u30c8\u30ea\u3067\u306f\u3001\u4e0b\u8a18\u3092\u5b9f\u65bd\u3057\u307e\u3059\u3002<br \/>\n1. autovacuum \u304c\u5b9f\u65bd\u3055\u308c\u308b\u72b6\u614b\u3092\u4f5c\u308b (pgbench)<br \/>\n2. vacuum \u53ca\u3073 autovacuum \u304c\u5b9f\u65bd\u3055\u308c\u305f\u6700\u7d42\u6642\u523b\u3092\u78ba\u8a8d<br \/>\n3. \u7279\u5b9a\u30c6\u30fc\u30d6\u30eb\u306e autovacuum \u3092\u6291\u5236<\/p>\n<p><strong>autovacuum\u3092\u505c\u6b62\u3057\u305f\u5f8c\u306f\u5fc5\u305a\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u30b9\u30af\u30ea\u30d7\u30c8\u7b49\u3067\u90fd\u5408\u306e\u826f\u3044\u6642\u9593\u5e2f\u3067 vacuum\u3092\u5b9f\u65bd\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046<\/strong><\/p>\n<h1>\u6e96\u5099<\/h1>\n<pre>\n[root@ip-xxxxxx ~]$ \/usr\/local\/pgsql\/bin\/pgbench -i -s10 -U pguser -h pgsql-test.xxxxx.ap-northeast-1.rds.amazonaws.com testdb\nPassword:\ncreating tables...\n100000 of 1000000 tuples (10%) done (elapsed 0.38 s, remaining 3.42 s).\n200000 of 1000000 tuples (20%) done (elapsed 1.26 s, remaining 5.05 s).\n300000 of 1000000 tuples (30%) done (elapsed 3.03 s, remaining 7.07 s).\n400000 of 1000000 tuples (40%) done (elapsed 5.37 s, remaining 8.06 s).\n500000 of 1000000 tuples (50%) done (elapsed 5.80 s, remaining 5.80 s).\n600000 of 1000000 tuples (60%) done (elapsed 7.75 s, remaining 5.17 s).\n700000 of 1000000 tuples (70%) done (elapsed 10.01 s, remaining 4.29 s).\n800000 of 1000000 tuples (80%) done (elapsed 10.43 s, remaining 2.61 s).\n900000 of 1000000 tuples (90%) done (elapsed 12.64 s, remaining 1.40 s).\n1000000 of 1000000 tuples (100%) done (elapsed 13.08 s, remaining 0.00 s).\nvacuum...\nset primary keys...\ndone.\n\ntestdb=> select relname, seq_scan, seq_tup_read, idx_scan, n_live_tup, n_dead_tup, last_vacuum, last_autovacuum from pg_stat_all_tables where relname like 'pgbench%';\n     relname      | seq_scan | seq_tup_read | idx_scan | n_live_tup | n_dead_tup |          last_vacuum          |        last_autovacuum\n------------------+----------+--------------+----------+------------+------------+-------------------------------+-------------------------------\n pgbench_branches |    71390 |       539310 |        0 |         10 |        164 | 2014-07-10 08:57:15.398869+00 | 2014-07-10 05:02:05.198489+00\n pgbench_tellers  |    56532 |      5392200 |        0 |        100 |          0 | 2014-07-10 08:57:15.405037+00 | 2014-07-10 08:58:14.467415+00\n pgbench_history  |        0 |            0 |          |      10000 |          0 | 2014-07-10 02:48:56.913997+00 |\n pgbench_accounts |        1 |      1000000 |   107843 |    1000000 |      25601 | 2014-07-10 02:48:56.686276+00 |\n(4 rows)\n<\/pre>\n<h1>\u5b9f\u65bd<\/h1>\n<h2>auto_vacuum\u8a2d\u5b9a\u3092\u4f55\u3082\u5909\u66f4\u305b\u305a\u306b\u5b9f\u884c\u3057 autovacuum\u304c\u8d70\u3063\u3066\u3044\u308b\u4e8b\u3092\u78ba\u8a8d<\/h2>\n<pre>\n[root@ip-xxxxxx ~]$ \/usr\/local\/pgsql\/bin\/pgbench -c10 -t1000 -U pguser -h pgsql-test.xxxxx.ap-northeast-1.rds.amazonaws.com testdb\nPassword:\nstarting vacuum...end.\ntransaction type: TPC-B (sort of)\nscaling factor: 10\nquery mode: simple\nnumber of clients: 10\nnumber of threads: 1\nnumber of transactions per client: 1000\nnumber of transactions actually processed: 10000\/10000\ntps = 321.557791 (including connections establishing)\ntps = 323.035636 (excluding connections establishing)\n\ntestdb=> select relname, seq_scan, seq_tup_read, idx_scan, n_live_tup, n_dead_tup, last_vacuum, last_autovacuum from pg_stat_all_tables where relname like 'pgbench%';\n     relname      | seq_scan | seq_tup_read | idx_scan | n_live_tup | n_dead_tup |          last_vacuum          |        last_autovacuum\n------------------+----------+--------------+----------+------------+------------+-------------------------------+-------------------------------\n pgbench_branches |    84508 |       639320 |        0 |         10 |        141 | 2014-07-10 09:05:39.648791+00 | 2014-07-10 05:02:05.198489+00\n pgbench_tellers  |    67016 |      6392200 |        0 |        100 |          0 | 2014-07-10 09:05:39.65411+00  | 2014-07-10 09:06:14.905845+00\n pgbench_history  |        0 |            0 |          |      10000 |          0 | 2014-07-10 02:48:56.913997+00 |\n pgbench_accounts |        1 |      1000000 |   127843 |    1000000 |      28860 | 2014-07-10 02:48:56.686276+00 |\n(4 rows)\n\ntestdb=> select now();\n              now\n-------------------------------\n 2014-07-10 09:06:21.412179+00\n(1 row)\n<\/pre>\n<h2>vacuum\u8a2d\u5b9a\u306e\u5909\u66f4<\/h2>\n<pre>\ntestdb=> alter table pgbench_tellers set (autovacuum_enabled = false);\nALTER TABLE\ntestdb=> alter table pgbench_tellers set (toast.autovacuum_enabled = false);\nALTER TABLE\n<\/pre>\n<h2>pg_bench\u3092\u4f55\u56de\u5b9f\u884c\u3057\u3066\u3082 autovacuum\u304c\u8d70\u3089\u306a\u3044\u4e8b\u3092\u78ba\u8a8d<\/h2>\n<pre>\ntestdb=> select relname, seq_scan, seq_tup_read, idx_scan, n_live_tup, n_dead_tup, last_vacuum, last_autovacuum from pg_stat_all_tables where relname like 'pgbench%';\n     relname      | seq_scan | seq_tup_read | idx_scan | n_live_tup | n_dead_tup |          last_vacuum          |        last_autovacuum\n------------------+----------+--------------+----------+------------+------------+-------------------------------+-------------------------------\n pgbench_branches |    97681 |       739330 |        0 |         10 |        164 | 2014-07-10 09:07:26.572718+00 | 2014-07-10 05:02:05.198489+00\n pgbench_tellers  |    77495 |      7392200 |        0 |        100 |        102 | 2014-07-10 09:07:26.579097+00 | 2014-07-10 09:06:14.905845+00\n pgbench_history  |        0 |            0 |          |      20000 |          0 | 2014-07-10 02:48:56.913997+00 |\n pgbench_accounts |        1 |      1000000 |   147843 |    1000000 |      30786 | 2014-07-10 02:48:56.686276+00 |\n(4 rows)\n\ntestdb=> select now();\n              now\n-------------------------------\n 2014-07-10 09:08:14.090072+00\n(1 row)\n...\ntestdb=> select relname, seq_scan, seq_tup_read, idx_scan, n_live_tup, n_dead_tup, last_vacuum, last_autovacuum from pg_stat_all_tables where relname like 'pgbench%';\n     relname      | seq_scan | seq_tup_read | idx_scan | n_live_tup | n_dead_tup |          last_vacuum          |        last_autovacuum\n------------------+----------+--------------+----------+------------+------------+-------------------------------+-------------------------------\n pgbench_branches |   110794 |       839340 |        0 |         10 |        168 | 2014-07-10 09:08:30.25682+00  | 2014-07-10 05:02:05.198489+00\n pgbench_tellers  |    87978 |      8392200 |        0 |        100 |         99 | 2014-07-10 09:08:30.267249+00 | 2014-07-10 09:06:14.905845+00\n pgbench_history  |        0 |            0 |          |      10000 |          0 | 2014-07-10 02:48:56.913997+00 |\n pgbench_accounts |        1 |      1000000 |   167843 |    1000000 |      31924 | 2014-07-10 02:48:56.686276+00 |\n(4 rows)\n\n...\ntestdb=> select relname, seq_scan, seq_tup_read, idx_scan, n_live_tup, n_dead_tup, last_vacuum, last_autovacuum from pg_stat_all_tables where relname like 'pgbench%';\n     relname      | seq_scan | seq_tup_read | idx_scan | n_live_tup | n_dead_tup |          last_vacuum          |        last_autovacuum\n------------------+----------+--------------+----------+------------+------------+-------------------------------+-------------------------------\n pgbench_branches |   123880 |       939350 |        0 |         10 |        155 | 2014-07-10 09:09:47.869879+00 | 2014-07-10 05:02:05.198489+00\n pgbench_tellers  |    98463 |      9392200 |        0 |        100 |        116 | 2014-07-10 09:09:47.875082+00 | 2014-07-10 09:06:14.905845+00\n pgbench_history  |        0 |            0 |          |      10000 |          0 | 2014-07-10 02:48:56.913997+00 |\n pgbench_accounts |        1 |      1000000 |   187843 |    1000000 |      32562 | 2014-07-10 02:48:56.686276+00 |\n(4 rows)\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u7684 \u7279\u5b9a\u6642\u9593\u306b\u30b5\u30a4\u30c8\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u843d\u3061\u3066\u3057\u307e\u3046\u4e8b\u3092\u9632\u6b62\u3057\u305f\u3044 \u5b9f\u969b\u306b\u306f\u30b5\u30a4\u30c8\u30ec\u30b9\u30dd\u30f3\u30b9\u304c\u7570\u69d8\u306b\u9045\u3044\u4e8b\u304c\u3042\u308a\u30ed\u30b0\u3092\u898b\u305f\u3068\u3053\u308d autovacuum\u304c\u5b9f\u65bd\u3055\u308c\u3066\u3044\u305f\u30b1\u30fc\u30b9\u304c\u591a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002 \u74b0\u5883 EC2\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3088\u308a&#8230;<\/p>\n","protected":false},"author":2,"featured_media":310,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"","_original_post":"","footnotes":""},"categories":[20,25,19,23],"tags":[106,36],"class_list":{"0":"post-320","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-aws","8":"category-postgresql","9":"category-19","10":"category-23","11":"tag-postgresql","12":"tag-tips","13":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/320","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=320"}],"version-history":[{"count":6,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/320\/revisions"}],"predecessor-version":[{"id":361,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/320\/revisions\/361"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/310"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}