{"id":462283,"date":"2025-06-06T15:01:05","date_gmt":"2025-06-06T15:01:05","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=462283"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=462283","title":{"rendered":"<span>\u0412\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445 PostgreSQL<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 (HOT cleanup) \u2013 \u044d\u0442\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u043c\u043e\u0433\u0443\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f \u0438\u0437 \u0431\u043b\u043e\u043a\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446. \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0451\u043d\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438. \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u0442\u043e, \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0435 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u0441\u0442\u0440\u043e\u043a, \u0432\u044b\u0448\u0435\u0434\u0448\u0438\u043c\u0438 \u0437\u0430 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (xmin horizon).\u00a0\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438\u00a0\u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.\u00a0\u0415\u0441\u043b\u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0442\u043e \u043d\u0438 \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430, \u043d\u0438 \u0432\u0430\u043a\u0443\u0443\u043c \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u043e, \u0438 \u0442\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u043b\u043e\u043a. \u0423\u0432\u0438\u0434\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 pgbench, \u043a\u0430\u043a \u0441\u0438\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043d\u0438\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044f \u0441 \u0434\u043e\u043b\u0433\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u0438\u043b\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439) \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0432 \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u0445 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u0444\u0430\u0439\u043b\u0435 pruneheap.c (heap page pruning and HOT-chain management code) \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 PostgreSQL. \u041f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0431\u043b\u043e\u043a\u0435 (\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435) \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0443\u0434\u0430\u043b\u044f\u044e\u0449\u0430\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0432\u043e\u0439 \u043d\u043e\u043c\u0435\u0440 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043f\u043e\u043b\u0435 xmax \u0438 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0434 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u043e\u043c \u0436\u0435 \u0441\u0430\u043c\u043e\u043c \u0431\u043b\u043e\u043a\u0435,\u00a0\u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u041f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0441\u0442\u0440\u043e\u043a\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 XLOG Ctl (CLOG) \u0438 \u0438\u043d\u043e\u0433\u0434\u0430 \u2014 \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043c\u0443\u043b\u044c\u0442\u0438\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 Shared MultiXact State. \u041f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u0441\u0432\u0435\u0440\u043a\u0438 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0438\u0442\u044b-\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f, \u0443\u0434\u0430\u043b\u0438\u0432\u0448\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0443, \u0431\u044b\u043b\u0430 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0438\u043b\u0438 \u043e\u0442\u043c\u0435\u043d\u0435\u043d\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u043c\u043e\u0433\u0443\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0415\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0442\u0440\u043e\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u044b\u043b \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0434\u0435\u043a\u0441, \u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0432\u043f\u0440\u043e\u0447\u0435\u043c, \u043a\u0430\u043a \u0438 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a \u0441\u0442\u0440\u043e\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0438\u043d\u0434\u0435\u043a\u0441 (Index Scan), \u0438 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430 (\u0438\u043b\u0438 \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0441\u0442\u0440\u043e\u043a, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c) \u0443\u0434\u0430\u043b\u0435\u043d\u0430 \u0438 \u0432\u044b\u0448\u043b\u0430 \u0437\u0430 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0431\u0430\u0437\u044b, \u0442\u043e \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 (leaf page) \u0432 lp_flags \u043e\u043d \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u0431\u0438\u0442-\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443 LP_DEAD (\u0435\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 known dead, killed tuple). \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 indexam.c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 PostgreSQL \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0442\u0430\u043a: If we scanned a whole HOT chain and found only dead tuples, tell index AM to kill its entry for that TID.<\/p>\n<p>LP_DEAD \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0437\u0430\u043f\u0438\u0441\u0438 \u0442\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<p>LP_DEAD \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0431\u044b\u043b\u0430 \u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 (\u0438\u043b\u0438 \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0441\u0442\u0440\u043e\u043a, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c) \u0443\u0434\u0430\u043b\u0435\u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0438\u043b\u0438 \u044d\u0442\u0438\u043c \u0436\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c.<\/p>\n<p>\u0412\u0441\u0442\u0430\u0432\u043a\u0443 \u044d\u0442\u043e\u0433\u043e \u0431\u0438\u0442\u0430-\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u043e\u0439 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445. \u0411\u0438\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 dead, \u0432\u044b\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 bt_page_items (&#8216;\u0438\u043c\u044f_\u0438\u043d\u0434\u0435\u043a\u0441\u0430&#8217;,\u043d\u043e\u043c\u0435\u0440_\u0431\u043b\u043e\u043a\u0430).<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/h3>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0432\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0443\u0434\u0430\u043b\u0438\u043c \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a:<\/p>\n<pre><code class=\"sql\">create extension if not exists pageinspect; drop table t; create table t (id int primary key, c text) with (autovacuum_enabled = off); insert into t SELECT i, 'some text ' || i from generate_series(1, 10000) as i; delete from t where id between 100 and 9000; analyze t; CREATE EXTENSION DROP TABLE CREATE TABLE INSERT 0 10000 DELETE 8901 ANALYZE \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 68 \u0431\u043b\u043e\u043a\u043e\u0432, \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 30 \u0431\u043b\u043e\u043a\u043e\u0432: select pg_table_size('t')\/8192 table_size, pg_relation_size('t_pkey')\/8192 index_size;  table_size | index_size ------------+------------          68 |         30 (1 row)<\/code><\/pre>\n<p>\u0412 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0445 (dead = f):<\/p>\n<pre><code class=\"sql\">select itemoffset, ctid, itemlen, dead, left(data,8) data from bt_page_items('t_pkey',20) limit 3;  itemoffset |  ctid    | itemlen | dead | data ------------+----------+---------+------+-----------           1 | (44,1)   |      16 |      | 2b 1b 00           2 | (42,151) |      16 | f    | bd 19 00           3 | (41,152) |      16 | f    | be 19 00<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0431\u043b\u043e\u043a\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 (itemoffset=1) \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043e\u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u0442 High Key. \u0412 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 ctid \u2013 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0431\u043b\u043e\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 (\u043d\u043e\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430, \u043d\u043e\u043c\u0435\u0440 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443).<\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0411\u044b\u0441\u0442\u0440\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u043c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0443\u0434\u0430\u043b\u044f\u043b\u0438 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a, \u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u2014 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0432\u044b\u0431\u0440\u0430\u043b Index Scan. \u0427\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0438 \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043d\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 explain:<\/p>\n<pre><code class=\"sql\">explain (analyze, settings, buffers, costs off) select * from t where id between 1 and 9000;                     QUERY PLAN ------------------------------------------------------------------  Index Scan using t_pkey on t (actual time=0.023..1.667 rows=99 loops=1)    Index Cond: ((id &gt;= 1) AND (id &lt;= 9000))    Buffers: shared hit=109 dirtied=17  Planning:    Buffers: shared hit=15 dirtied=2  Planning Time: 0.147 ms  Execution Time: 1.822 ms (7 rows)<\/code><\/pre>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u043a \u0431\u043b\u043e\u043a\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 68 \u0431\u043b\u043e\u043a\u043e\u0432, \u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u043b\u0430\u0441\u044c \u043a 109+17 \u0431\u043b\u043e\u043a\u043e\u0432. \u0412 109 \u0431\u043b\u043e\u043a\u043e\u0432 \u0432\u0445\u043e\u0434\u044f\u0442 \u0431\u043b\u043e\u043a\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0440\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041e\u0447\u0438\u0441\u0442\u0438\u0432 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0431\u043b\u043e\u043a\u0430\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f \u0432 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u043f\u043e\u043c\u0435\u0442\u0438\u043b \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u0430\u043a \u043c\u0451\u0440\u0442\u0432\u044b\u0435 (\u043f\u0440\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0431\u0438\u0442 dead), \u0442\u043e \u0435\u0441\u0442\u044c, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430:<\/p>\n<pre><code class=\"sql\">select itemoffset, ctid, itemlen, dead, left(data,8) data from bt_page_items('t_pkey',20) limit 3;  itemoffset |   ctid   | itemlen | dead |   data ------------+----------+---------+------+----------           1 | (44,1)   |      16 |      | 2b 1b 00           2 | (41,151) |      16 | t    | bd 19 00           3 | (41,152) |      16 | t    | be 19 00 (3 rows)<\/code><\/pre>\n<p>\u0412 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 dead \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &#8216;t&#8217; \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u0430 \u043a\u0430\u043a \u0432\u0435\u0434\u0443\u0449\u0430\u044f \u043d\u0430 \u043c\u0435\u0440\u0442\u0432\u0443\u044e (\u0443\u0434\u0430\u043b\u0451\u043d\u043d\u0443\u044e) \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u041f\u0440\u0438 Bitmap Index Scan \u0438 Seq Scan (\u043d\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435) \u0431\u0438\u0442-\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u041f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u0430\u044f \u0442\u0430\u043a\u0438\u043c \u0444\u043b\u0430\u0433\u043e\u043c \u0441\u0442\u0440\u043e\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0430 \u043f\u043e\u0437\u0436\u0435, \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043d\u043e\u0441\u0438\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0431\u043b\u043e\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, UPDATE.<\/p>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0442 \u0432 \u0431\u043b\u043e\u043a \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432 \u043d\u0435\u043c \u0444\u043b\u0430\u0433\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b (Execution Time: 1.822 ms), \u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e. \u041f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u043c\u043e\u0433\u0443\u0442 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0431\u043b\u043e\u043a\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u0435\u0434\u0451\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043c\u0451\u0440\u0442\u0432\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e:<\/p>\n<pre><code class=\"sql\">explain (analyze, settings, buffers, costs off) select * from t where id between 1 and 9000;                                 QUERY PLAN -------------------------------------------------------------  Index Scan using t_pkey on t (actual time=0.012..0.203 rows=99 loops=1)    Index Cond: ((id &gt;= 1) AND (id &lt;= 9000))    Buffers: shared hit=27  Planning:    Buffers: shared hit=3  Planning Time: 0.085 ms  Execution Time: 0.356 ms (7 rows)<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 (\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435) \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u0440\u043e\u0447\u043b\u0430 27 \u0431\u043b\u043e\u043a\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u043e 109. \u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u043e\u0441\u044c \u0441 1.822 \u043c\u0441 \u0434\u043e 0.356 \u043c\u0441, \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438 \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u043c \u0447\u0438\u0441\u043b\u0435 \u0441\u0442\u0440\u043e\u043a \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u0442\u0435\u0441\u0442\u043e\u043c pgbench.<\/p>\n<h3>\u0412\u043b\u0438\u044f\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0441\u0430\u043c\u0443\u044e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 pgbench_branches, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b pgbench \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043c \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435 \u043e\u0447\u0438\u0441\u0442\u0438\u043b \u0431\u043b\u043e\u043a\u0438 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e. \u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0442\u0435\u0441\u0442\u0430 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c \u043d\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a, \u043d\u0435 \u0432\u044b\u0448\u0435\u0434\u0448\u0438\u0435 \u0437\u0430 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"sql\">pgbench -i psql -c \"alter table pgbench_branches set (autovacuum_enabled=off)\"<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0431\u0430\u0437\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435 \u0434\u0430\u0432\u0430\u044f \u0432\u0430\u043a\u0443\u0443\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442:<\/p>\n<pre><code class=\"sql\">begin; select pg_current_xact_id();<\/code><\/pre>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"sql\">pgbench -T 100000 -P 30 progress: 30.0 s, 510.9 tps, lat 1.954 ms stddev 1.278, 0 failed progress: 60.0 s, 374.2 tps, lat 2.670 ms stddev 1.959, 0 failed progress: 90.0 s, 308.6 tps, lat 3.238 ms stddev 1.583, 0 failed progress: 120.0 s, 255.5 tps, lat 3.911 ms stddev 1.989, 0 failed progress: 150.0 s, 211.3 tps, lat 4.730 ms stddev 2.706, 0 failed progress: 180.0 s, 163.9 tps, lat 6.098 ms stddev 4.372, 0 failed progress: 210.0 s, 130.1 tps, lat 7.684 ms stddev 5.986, 0 failed progress: 240.0 s, 102.7 tps, lat 9.735 ms stddev 7.363, 0 failed progress: 270.0 s, 70.9 tps, lat 14.094 ms stddev 9.706, 0 failed progress: 300.0 s, 62.4 tps, lat 16.018 ms stddev 9.223, 0 failed<\/code><\/pre>\n<p>\u0418\u0437-\u0437\u0430 \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430 \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 UPDATE (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 pgbench), \u043d\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u043e\u0447\u0438\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u043e\u0439, \u043d\u0438 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c\u043e\u043c. \u0412\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u043d\u0430\u0447\u043d\u0443\u0442 \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0431\u043b\u043e\u043a\u0430\u0445.<\/p>\n<p>\u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 pgbench_branches \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430, \u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0412 \u0431\u043b\u043e\u043a\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f 226 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a, \u0438 \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u0447\u0435\u0440\u043f\u0430\u043d\u043e, \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u0439\u0434\u0443\u0442 \u0443\u0436\u0435 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u043b\u043e\u043a. \u0421\u0442\u0440\u043e\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439: UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;<\/p>\n<pre><code class=\"sql\">select lp, t_ctid, (t_infomask2 &amp; 16384)!=0 hhu, (t_infomask2 &amp; 32768)!=0 hot from heap_page_items(get_raw_page('pgbench_branches', 0));  lp  | t_ctid  | hhu | hot  -----+---------+-----+-----    1 | (0,2)   | t   | f    2 | (0,3)   | t   | t ...  224 | (0,225) | t   | t  226 | (1,1)   | f   | t (4 rows)<\/code><\/pre>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b9c\/034\/22d\/b9c03422d5899ff6675ff1df7963b489.png\" alt=\"\u0426\u0435\u043f\u043e\u0447\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b pgbench_branches \u0438 \u0435\u0451 \u0438\u043d\u0434\u0435\u043a\u0441\" title=\"\u0426\u0435\u043f\u043e\u0447\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b pgbench_branches \u0438 \u0435\u0451 \u0438\u043d\u0434\u0435\u043a\u0441\" width=\"1363\" height=\"670\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/b9c\/034\/22d\/b9c03422d5899ff6675ff1df7963b489.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b9c\/034\/22d\/b9c03422d5899ff6675ff1df7963b489.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0426\u0435\u043f\u043e\u0447\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b pgbench_branches \u0438 \u0435\u0451 \u0438\u043d\u0434\u0435\u043a\u0441<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0431\u043b\u043e\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0432\u0435\u0440\u0441\u0438\u0439, \u0438 \u043d\u0430 \u043f\u0435\u0440\u0432\u0443\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0432 \u0431\u043b\u043e\u043a \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430. \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 HOT update. \u0418\u043d\u0434\u0435\u043a\u0441 \u0441\u043e\u0437\u0434\u0430\u043d \u043d\u0430 \u0441\u0442\u043e\u043b\u0431\u0435\u0446\u00a0bid,\u00a0\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u043b\u0431\u0435\u0446 bbalance. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u0439 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u043e \u0432\u00a0\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0431\u043b\u043e\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0446\u0435\u043f\u043e\u0447\u0435\u043a \u0432\u0435\u0440\u0441\u0438\u0439 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<pre><code class=\"sql\">begin transaction isolation level repeatable read; EXPLAIN (analyze, timing off, buffers) select bbalance from pgbench_branches WHERE bid = 1; select pg_table_size('pgbench_branches')\/8192 table_size, pg_relation_size('pgbench_branches_pkey')\/8192 index_size; select blkno, type, live_items, dead_items, avg_item_size, free_size  from bt_multi_page_stats('pgbench_branches_pkey',1,-1); select itemoffset, ctid, itemlen, dead, left(data,2) data from bt_page_items('pgbench_branches_pkey',1) limit 5; rollback; BEGIN               QUERY PLAN -----------------------------------------  Index Scan using pgbench_branches_pkey on pgbench_branches  (cost=0.15..8.17 rows=1 width=4) (actual rows=1 loops=1)    Index Cond: (bid = 1)    Buffers: shared hit=374  Planning Time: 0.052 ms  Execution Time: 5.053 ms (5 rows)  table_size | index_size ------------+------------         377 |          2 (1 row)  blkno | type | live_items | dead_items | avg_item_size | free_size  -------+------+------------+------------+---------------+-----------      1 | l    |        373 |          0 |            16 |       688 (1 row)  itemoffset | ctid  | itemlen |  dead | data   ------------+-------+---------+-------+-----           1 | (0,1) |      16 | f     | 01           2 | (1,1) |      16 | f     | 01           3 | (2,1) |      16 | f     | 01           4 | (3,1) |      16 | f     | 01           5 | (4,1) |      16 | f     | 01 (5 rows)<\/code><\/pre>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0435\u0442\u00a0HighKey? \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0435\u0440\u0435\u0432\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u043c \u0438 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u043c \u043f\u0440\u0430\u0432\u044b\u043c. \u0412 \u043f\u0440\u0430\u0432\u044b\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 HighKey. \u0427\u0435\u0440\u0435\u0437 600 \u0441\u0435\u043a\u0443\u043d\u0434 \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0435\u0441\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0440\u0430\u0437\u0440\u043e\u0441\u043b\u0430\u0441\u044c \u0434\u043e 377 \u0431\u043b\u043e\u043a\u043e\u0432, \u0438\u00a0\u044d\u0442\u043e \u043f\u0440\u0438 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430. \u042d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u043d\u0438\u044f (bloat) \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0412 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 373 \u0437\u0430\u043f\u0438\u0441\u0438, \u0438 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f Buffers: shared hit=374 \u0431\u0443\u0444\u0435\u0440\u043e\u0432.<\/p>\n<pre><code class=\"sql\">progress: 600.0 s, 48.7 tps, lat 20.530 ms stddev 8.386, 0 failed progress: 630.0 s, 42.0 tps, lat 23.821 ms stddev 10.743, 0 failed progress: 660.0 s, 47.6 tps, lat 21.026 ms stddev 12.074, 0 failed progress: 690.0 s, 45.1 tps, lat 22.165 ms stddev 11.254, 0 failed progress: 720.0 s, 43.7 tps, lat 22.905 ms stddev 10.442, 0 failed<\/code><\/pre>\n<p>\u0421\u043d\u0438\u0436\u0435\u043d\u0438\u0435 tps \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u2014 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u0432 10 \u0440\u0430\u0437 \u0437\u0430 \u043f\u043e\u043b\u0447\u0430\u0441\u0430.<\/p>\n<p>\u041d\u0430 900 \u0441\u0435\u043a\u0443\u043d\u0434\u0435 \u0442\u0435\u0441\u0442\u0430 \u043d\u0430\u0447\u043d\u0435\u0442\u0441\u044f \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432 \u0431\u043b\u043e\u043a\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430:<\/p>\n<pre><code class=\"sql\">begin transaction isolation level repeatable read; select pg_table_size('pgbench_branches')\/8192 table_size, pg_relation_size('pgbench_branches_pkey')\/8192 index_size; select blkno, type, live_items, dead_items, avg_item_size, free_size  from bt_multi_page_stats('pgbench_branches_pkey',1,-1); select itemoffset, ctid, itemlen, dead, left(data,2) data, left(tids::text,11) tids from bt_page_items('pgbench_branches_pkey',1) limit 5; rollback;  table_size | index_size ------------+------------         421 |          2 (1 row)  blkno | type | live_items | dead_items | avg_item_size | free_size  -------+------+------------+------------+---------------+-----------      1 | l    |         12 |          0 |           220 |      5460 (1 row)  itemoffset |   ctid    | itemlen |  dead | data | tids ------------+-----------+---------+-------+------+------------           1 | (16,8414) |    1352 | f     | 01   | {\"(0,1)\",\"(           2 | (16,8377) |    1128 | f     | 01   | {\"(222,1)\",           3 | (407,1)   |      16 | f     | 01   |           4 | (408,1)   |      16 | f     | 01   |            5 | (409,1)   |      16 | f     | 01   |  (5 rows)<\/code><\/pre>\n<p>\u0414\u0432\u0435 \u043f\u0435\u0440\u0432\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0445\u0440\u0430\u043d\u044f\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0441\u0441\u044b\u043b\u043e\u043a (tids) \u043d\u0430 \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0432\u044b\u043c\u0438 \u0432 \u0431\u043b\u043e\u043a \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0435 \u0432\u0435\u0440\u0441\u0438\u0439 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0431\u043b\u043e\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0423 \u043f\u0435\u0440\u0432\u044b\u0445 \u0434\u0432\u0443\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0434\u043b\u0438\u043d\u0430 itemlen=1352 \u0438 1128. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 live_items \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u043e\u0441\u044c \u0441 373 \u0434\u043e 12, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u0431\u043b\u043e\u043a\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f 409 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041f\u043e\u0447\u0435\u043c\u0443 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 (live_items) \u0432 \u0431\u043b\u043e\u043a\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u043e\u0441\u044c? \u041f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0431\u043b\u043e\u043a\u0435 \u043d\u0435\u0442 \u043c\u0435\u0441\u0442\u0430. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432 \u0431\u043b\u043e\u043a\u0435 \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0437\u0430\u043f\u0438\u0441\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 16 \u0431\u0430\u0439\u0442, \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0430 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0431\u043b\u043e\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u0442\u0430 \u0441\u0442\u0430\u043b\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0442\u044c, \u0431\u044b\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0430 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f: \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0431\u044b\u043b\u0438 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u044b \u0432 2 \u0437\u0430\u043f\u0438\u0441\u0438. \u041d\u043e\u0432\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435\u0434\u0435\u0434\u0443\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0431\u043b\u043e\u043a\u0435 \u0441\u043d\u043e\u0432\u0430 \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442 \u043c\u0435\u0441\u0442\u0430, \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0441\u043d\u043e\u0432\u0430.<\/p>\n<p>\u0418\u043d\u0434\u0435\u043a\u0441 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0431\u043b\u043e\u043a\u043e\u0432 (16 \u041a\u0431): \u043e\u0434\u043d\u043e\u0433\u043e \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 (\u043e\u043d \u0436\u0435 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0431\u043b\u043e\u043a) \u0438 \u0431\u043b\u043e\u043a\u0430 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"sql\">select pg_table_size('pgbench_branches')\/8192 table_size, pg_relation_size('pgbench_branches_pkey')\/8192 index_size;  table_size | index_size ------------+------------         713 |          2 (1 row)<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c \u0435\u0449\u0435 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 (\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u043c pgbench) \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c tps \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e \u0441\u043d\u0438\u0436\u0430\u0442\u044c\u0441\u044f.<\/p>\n<p>\u0417\u0430\u0432\u0435\u0440\u0448\u0438\u043c \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0442\u0435\u0441\u0442 pgbench \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0435\u0439 \u043a\u043b\u0430\u0432\u0438\u0448 Ctrl+C. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e, \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0443\u044e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0431\u0430\u0437\u044b:<\/p>\n<pre><code class=\"sql\">postgres=# begin; BEGIN postgres=*# select pg_current_xact_id();  pg_current_xact_id  --------------------            16375547 (1 row) postgres=*# rollback;<\/code><\/pre>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:<\/p>\n<pre><code class=\"sql\">explain (analyze, timing off, buffers) select bbalance from pgbench_branches where bid = 1;                      QUERY PLAN -----------------------------------------------------------  Index Scan using pgbench_branches_pkey on pgbench_branches  (cost=0.15..8.17 rows=1 width=4) (actual rows=1 loops=1)    Index Cond: (bid = 1)    Buffers: shared hit=711 dirtied=522  Planning Time: 0.077 ms  Execution Time: 8.349 ms (5 rows)<\/code><\/pre>\n<p>\u042d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442. \u0412\u0441\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a, \u043a\u0440\u043e\u043c\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439, \u0432\u044b\u0448\u043b\u0438 \u0437\u0430 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442, \u0438 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043e\u0447\u0438\u0449\u0430\u0442\u044c. \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0442\u0435\u0441\u0442\u0430 \u043c\u044b \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435 \u0443\u0441\u043f\u0435\u043b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u043d\u044c\u0448\u0435 \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c Index Scan \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0434\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442 \u0431\u044b\u0441\u0442\u0440\u0443\u044e \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u0431\u043b\u043e\u043a\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0443\u044e \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u041d\u0430 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043b\u0430\u043d\u0430 Buffers: shared hit=711 dirtied=522.\u00a0<\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0437\u0430\u043d\u044f\u043b\u043e 8.349 ms. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0438 \u0431\u044b\u043b\u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 pgbench_branches \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430. \u0418\u043d\u0434\u0435\u043a\u0441 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430, \u0438 \u0435\u0433\u043e \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u043d\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b UPDATE.<\/p>\n<p>\u0427\u0442\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 tps \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 pgbench, \u043a\u043e\u0433\u0434\u0430 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f? \u042d\u0442\u043e\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u0441\u043d\u0438\u0436\u0430\u044e\u0442 \u0434\u0432\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b UPDATE \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b pgbench_branches \u0438 pgbench_tellers. \u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 UPDATE pgbench_branches \u043e\u0431\u0440\u0430\u0449\u0430\u043b\u0430\u0441\u044c \u043a\u043e \u0432\u0441\u0435\u043c \u0431\u043b\u043e\u043a\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041a\u043e\u043c\u0430\u043d\u0434\u0430 UPDATE pgbench_tellers \u043e\u0431\u0440\u0430\u0449\u0430\u043b\u0430\u0441\u044c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e 1\/10 \u0431\u043b\u043e\u043a\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u043e \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0431\u044b\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0431\u043b\u043e\u043a\u043e\u0432. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u043a\u043b\u0430\u0434 \u043e\u0431\u0435\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0432 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435 tps \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0432\u043d\u043e\u0437\u043d\u0430\u0447\u0435\u043d.<\/p>\n<p>\u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 pgbench_accounts \u2014 10 000 \u0441\u0442\u0440\u043e\u043a. \u0412 \u043e\u0434\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u0430 (\u0447\u0438\u0441\u043b\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 tps) \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b: pgbench_accounts, pgbench_tellers, pgbench_branches. \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 pgbench_accounts \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0443\u0441\u043f\u0435\u0432\u0430\u044e\u0442, \u0438 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u0439 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u044b \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0434\u043d\u0438\u043c \u0431\u043b\u043e\u043a\u043e\u043c. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b UPDATE \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 \u2013 1\/10000. \u0412 pg_bench_branches \u0441\u0442\u0440\u043e\u043a\u0430 \u043e\u0434\u043d\u0430, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438. \u041a\u043e\u043c\u0430\u043d\u0434\u044b \u0442\u0435\u0441\u0442\u0430 (SELECT \u0438 UPDATE), \u043e\u0431\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 pgbench_accounts, \u0432 \u043f\u0435\u0440\u0432\u044b\u0435 \u0447\u0430\u0441\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0442\u0435\u0441\u0442\u0430 \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430 tps \u043d\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442.<\/p>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 pgbench_branches \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c:<\/p>\n<pre><code class=\"sql\">EXPLAIN (analyze, timing off, buffers) select bbalance from pgbench_branches WHERE bid = 1;                       QUERY PLAN ------------------------------------------------------------------  Index Scan using pgbench_branches_pkey on pgbench_branches  (cost=0.15..8.17 rows=1 width=4) (actual rows=1 loops=1)    Index Cond: (bid = 1)    Buffers: shared hit=2  Planning Time: 0.037 ms  Execution Time: 0.024 ms (5 rows)<\/code><\/pre>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b:<\/p>\n<pre><code class=\"sql\">select pg_table_size('pgbench_branches')\/8192 table_size, pg_relation_size('pgbench_branches_pkey')\/8192 index_size; select blkno, type, live_items, dead_items, avg_item_size, free_size  from bt_multi_page_stats('pgbench_branches_pkey',1,-1); select itemoffset, ctid, itemlen, dead, left(data,2) data, left(tids::text,11) tids from bt_page_items('pgbench_branches_pkey',1) limit 5;  table_size | index_size ------------+------------         713 |          2 (1 row)  blkno | type | live_items | dead_items | avg_item_size | free_size  -------+------+------------+------------+---------------+-----------      1 | l    |          1 |         22 |           196 |      3536 (1 row)  itemoffset |   ctid    | itemlen |  dead | data | tids ------------+-----------+---------+-------+------+-----------           1 | (16,8414) |    1352 |  t    | 01   | {\"(0,1)\",\"(           2 | (16,8414) |    1352 |  t    | 01   | {\"(222,1)\",           3 | (16,8414) |    1352 |  t    | 01   | {\"(444,1)\",           4 | (16,8414) |    1352 |  t    | 01   | {\"(666,1)\",           5 | (16,8414) |    1352 |  t    | 01   | {\"(888,1)\", (5 rows)<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u043d\u043e\u0432\u0430 \u0442\u0435\u0441\u0442, \u0438 \u0435\u0441\u043b\u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0431\u0430\u0437\u044b \u043d\u0435 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c, tps \u0441\u043d\u0438\u0436\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0443\u0442:<\/p>\n<pre><code class=\"sql\">pgbench -n -T 100000 -P 10 pgbench (17.0 (Ubuntu 17.0-1.pgdg22.04+1)) progress: 10.0 s, 618.5 tps, lat 1.613 ms stddev 1.571, 0 failed progress: 20.0 s, 593.4 tps, lat 1.682 ms stddev 1.482, 0 failed progress: 30.0 s, 617.6 tps, lat 1.616 ms stddev 1.084, 0 failed progress: 40.0 s, 650.2 tps, lat 1.535 ms stddev 0.176, 0 failed<\/code><\/pre>\n<p>\u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e tps \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u0441\u044f \u0441 43.7 \u0434\u043e 650.<\/p>\n<p>\u0418\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435 tps \u043f\u0440\u0438 \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430? \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043d\u0438 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0430\u044f \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 (HOT prune\/cleanup). \u0418\u0437-\u0437\u0430 \u0447\u0430\u0441\u0442\u043e\u0433\u043e (\u0441\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e tps) \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u043d\u043d\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0432\u0435\u0440\u0441\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0431\u043b\u043e\u043a\u043e\u0432. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0441\u0442\u0440\u043e\u043a\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0435\u0451 \u0432\u0435\u0440\u0441\u0438\u0438, \u043e\u043d\u0438 \u0440\u0430\u0437\u0431\u0438\u0442\u044b \u043d\u0430 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 hhu (heap hot update, \u0431\u0438\u0442 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b) \u0432 \u0431\u043b\u043e\u043a\u0430\u0445. \u0415\u0441\u043b\u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u043d\u0435 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0431\u043b\u043e\u043a\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0434 \u043d\u043e\u0432\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043b\u0433\u043e, \u0447\u0442\u043e update \u043d\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043c\u0435\u0441\u0442\u0430 \u0432 \u0431\u043b\u043e\u043a\u0435, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 hhu \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432 \u0431\u043b\u043e\u043a \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442\u0441\u044f 226 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u0440\u0438 tps = 226 \u044d\u0442\u043e \u0441\u0435\u043a\u0443\u043d\u0434\u0430).<\/p>\n<p>\u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0441\u0434\u0432\u0438\u043d\u0435\u0442\u0441\u044f, \u0442\u0443\u0442 \u0436\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435. \u0415\u0441\u043b\u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0434\u043e\u043b\u0433\u043e \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u0441\u044f \u0438 \u0440\u0435\u0437\u043a\u043e \u0441\u0434\u0432\u0438\u043d\u0435\u0442\u0441\u044f, \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0435\u0434\u0430\u043d\u0438\u0435 tps \u2014 \u0432 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0438 \u043f\u043e\u0442\u043e\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 tps. \u0427\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u043e \u0447\u0438\u0441\u043b\u0443 \u0431\u043b\u043e\u043a\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c, \u0430 \u0438\u043d\u0434\u0435\u043a\u0441 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0433\u043e (\u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e) \u0431\u043b\u043e\u043a\u0430 \u0438 \u0431\u043b\u043e\u043a\u0430 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u0441\u044f, \u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043d\u0430 tps \u043d\u0435 \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442. \u0421 \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f\u043c\u0438 tps \u0432\u044b\u0448\u0435, \u0447\u0435\u043c \u0431\u0435\u0437 \u043d\u0435\u0433\u043e, \u0438 \u043a\u0440\u0438\u0432\u0430\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f tps \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0430\u0447\u0435.<\/p>\n<h3>\u0420\u0435\u0437\u044e\u043c\u0435<\/h3>\n<p>\u041c\u044b \u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430. \u0423\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430 \u0434\u043e\u043b\u0433\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439 \u0438\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043d\u0430 \u0440\u0435\u043f\u043b\u0438\u043a\u0435 \u0441 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u044c\u044e \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u043d\u0438 \u0432\u0430\u043a\u0443\u0443\u043c\u0443, \u043d\u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u0435, \u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u043f\u043e\u043c\u0438\u043c\u043e \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 pgbench \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0442\u044c \u0437\u0430 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u0442\u0435\u0441\u0442\u0430, \u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0446\u0435\u043f\u043e\u0447\u0435\u043a \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0431\u043b\u043e\u043a\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. \u0421\u043d\u0438\u0436\u0435\u043d\u0438\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0447\u0430\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u0442\u0440\u043e\u043a.\u00a0<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/916318\/\"> https:\/\/habr.com\/ru\/articles\/916318\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 (HOT cleanup) \u2013 \u044d\u0442\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u043c\u043e\u0433\u0443\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0443\u0434\u0430\u043b\u044f\u0442\u044c\u0441\u044f \u0438\u0437 \u0431\u043b\u043e\u043a\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446. \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0451\u043d\u043d\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438. \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u0442\u043e, \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u043c\u043e\u0435 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 \u0441\u0442\u0440\u043e\u043a, \u0432\u044b\u0448\u0435\u0434\u0448\u0438\u043c\u0438 \u0437\u0430 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (xmin horizon).\u00a0\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438\u00a0\u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.\u00a0\u0415\u0441\u043b\u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0442\u043e \u043d\u0438 \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430, \u043d\u0438 \u0432\u0430\u043a\u0443\u0443\u043c \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0441\u0442\u043e, \u0438 \u0442\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u043b\u043e\u043a. \u0423\u0432\u0438\u0434\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430 pgbench, \u043a\u0430\u043a \u0441\u0438\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043d\u0438\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 (\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044f \u0441 \u0434\u043e\u043b\u0433\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u0438\u043b\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439) \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0432 \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u0445 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0447\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u0444\u0430\u0439\u043b\u0435 pruneheap.c (heap page pruning and HOT-chain management code) \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 PostgreSQL. \u041f\u0440\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0431\u043b\u043e\u043a\u0435 (\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435) \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0443\u0434\u0430\u043b\u044f\u044e\u0449\u0430\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0432\u043e\u0439 \u043d\u043e\u043c\u0435\u0440 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043f\u043e\u043b\u0435 xmax \u0438 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0434 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u043e\u043c \u0436\u0435 \u0441\u0430\u043c\u043e\u043c \u0431\u043b\u043e\u043a\u0435,\u00a0\u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u0438 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f. \u041f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0441\u0442\u0440\u043e\u043a\u0435 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0441\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 XLOG Ctl (CLOG) \u0438 \u0438\u043d\u043e\u0433\u0434\u0430 \u2014 \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u0430 \u043c\u0443\u043b\u044c\u0442\u0438\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 Shared MultiXact State. \u041f\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c \u0441\u0432\u0435\u0440\u043a\u0438 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0438\u0442\u044b-\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f, \u0443\u0434\u0430\u043b\u0438\u0432\u0448\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0443, \u0431\u044b\u043b\u0430 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0438\u043b\u0438 \u043e\u0442\u043c\u0435\u043d\u0435\u043d\u0430. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u043c\u043e\u0433\u0443\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0415\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0442\u0440\u043e\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u044b\u043b \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0434\u0435\u043a\u0441, \u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0432\u043f\u0440\u043e\u0447\u0435\u043c, \u043a\u0430\u043a \u0438 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a \u0441\u0442\u0440\u043e\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0438\u043d\u0434\u0435\u043a\u0441 (Index Scan), \u0438 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430 (\u0438\u043b\u0438 \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0441\u0442\u0440\u043e\u043a, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c) \u0443\u0434\u0430\u043b\u0435\u043d\u0430 \u0438 \u0432\u044b\u0448\u043b\u0430 \u0437\u0430 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0431\u0430\u0437\u044b, \u0442\u043e \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043b\u0438\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0430 (leaf page) \u0432 lp_flags \u043e\u043d \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u0431\u0438\u0442-\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0443 LP_DEAD (\u0435\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 known dead, killed tuple). \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435 indexam.c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 PostgreSQL \u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0442\u0430\u043a: If we scanned a whole HOT chain and found only dead tuples, tell index AM to kill its entry for that TID.<\/p>\n<p>LP_DEAD \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0437\u0430\u043f\u0438\u0441\u0438 \u0442\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<p>LP_DEAD \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u0431\u044b\u043b\u0430 \u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 (\u0438\u043b\u0438 \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0441\u0442\u0440\u043e\u043a, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c) \u0443\u0434\u0430\u043b\u0435\u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0438\u043b\u0438 \u044d\u0442\u0438\u043c \u0436\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c.<\/p>\n<p>\u0412\u0441\u0442\u0430\u0432\u043a\u0443 \u044d\u0442\u043e\u0433\u043e \u0431\u0438\u0442\u0430-\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u043e\u0439 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445. \u0411\u0438\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 dead, \u0432\u044b\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 bt_page_items (&#8216;\u0438\u043c\u044f_\u0438\u043d\u0434\u0435\u043a\u0441\u0430&#8217;,\u043d\u043e\u043c\u0435\u0440_\u0431\u043b\u043e\u043a\u0430).<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/h3>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0432\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0443\u0434\u0430\u043b\u0438\u043c \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a:<\/p>\n<pre><code class=\"sql\">create extension if not exists pageinspect; drop table t; create table t (id int primary key, c text) with (autovacuum_enabled = off); insert into t SELECT i, 'some text ' || i from generate_series(1, 10000) as i; delete from t where id between 100 and 9000; analyze t; CREATE EXTENSION DROP TABLE CREATE TABLE INSERT 0 10000 DELETE 8901 ANALYZE \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 68 \u0431\u043b\u043e\u043a\u043e\u0432, \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 30 \u0431\u043b\u043e\u043a\u043e\u0432: select pg_table_size('t')\/8192 table_size, pg_relation_size('t_pkey')\/8192 index_size;  table_size | index_size ------------+------------          68 |         30 (1 row)<\/code><\/pre>\n<p>\u0412 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0430 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0445 (dead = f):<\/p>\n<pre><code class=\"sql\">select itemoffset, ctid, itemlen, dead, left(data,8) data from bt_page_items('t_pkey',20) limit 3;  itemoffset |  ctid    | itemlen | dead | data ------------+----------+---------+------+-----------           1 | (44,1)   |      16 |      | 2b 1b 00           2 | (42,151) |      16 | f    | bd 19 00           3 | (41,152) |      16 | f    | be 19 00<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0431\u043b\u043e\u043a\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 (itemoffset=1) \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043e\u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u0442 High Key. \u0412 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 ctid \u2013 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0431\u043b\u043e\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 (\u043d\u043e\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430, \u043d\u043e\u043c\u0435\u0440 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0443).<\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0411\u044b\u0441\u0442\u0440\u0430\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u043c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438, \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0443\u0434\u0430\u043b\u044f\u043b\u0438 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a, \u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0440\u043e\u043a \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u2014 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0432\u044b\u0431\u0440\u0430\u043b Index Scan. \u0427\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0432\u044b\u0431\u0440\u0430\u043d\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0438 \u0447\u0442\u043e\u0431\u044b \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u043d\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u0441\u0442\u0440\u043e\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 explain:<\/p>\n<pre><code class=\"sql\">explain (analyze, settings, buffers, costs off) select * from t where id between 1 and 9000;                     QUERY PLAN ------------------------------------------------------------------  Index Scan using t_pkey on t (actual time=0.023..1.667 rows=99 loops=1)    Index Cond: ((id &gt;= 1) AND (id &lt;= 9000))    Buffers: shared hit=109 dirtied=17  Planning:    Buffers: shared hit=15 dirtied=2  Planning Time: 0.147 ms  Execution Time: 1.822 ms (7 rows)<\/code><\/pre>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u043a \u0431\u043b\u043e\u043a\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 68 \u0431\u043b\u043e\u043a\u043e\u0432, \u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043e\u0431\u0440\u0430\u0442\u0438\u043b\u0430\u0441\u044c \u043a 109+17 \u0431\u043b\u043e\u043a\u043e\u0432. \u0412 109 \u0431\u043b\u043e\u043a\u043e\u0432 \u0432\u0445\u043e\u0434\u044f\u0442 \u0431\u043b\u043e\u043a\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0442\u0440\u043e\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041e\u0447\u0438\u0441\u0442\u0438\u0432 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0431\u043b\u043e\u043a\u0430\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0435\u0440\u043d\u0443\u043b\u0441\u044f \u0432 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0435 \u0431\u043b\u043e\u043a\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u043f\u043e\u043c\u0435\u0442\u0438\u043b \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u0430\u043a \u043c\u0451\u0440\u0442\u0432\u044b\u0435 (\u043f\u0440\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0431\u0438\u0442 dead), \u0442\u043e \u0435\u0441\u0442\u044c, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u043b\u0438\u0441\u0442\u043e\u0432\u044b\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430:<\/p>\n<pre><code class=\"sql\">select itemoffset, ctid, itemlen, dead, left(data,8) data from bt_page_items('t_pkey',20) limit 3;  itemoffset |   ctid   | itemlen | dead |   data ------------+----------+---------+------+----------           1 | (44,1)   |      16 |      | 2b 1b 00           2 | (41,151) |      16 | t    | bd 19 00           3 | (41,152) |      16 | t    | be 19 00 (3 rows)<\/code><\/pre>\n<p>\u0412 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 dead \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &#8216;t&#8217; \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u0430 \u043a\u0430\u043a \u0432\u0435\u0434\u0443\u0449\u0430\u044f \u043d\u0430 \u043c\u0435\u0440\u0442\u0432\u0443\u044e (\u0443\u0434\u0430\u043b\u0451\u043d\u043d\u0443\u044e) \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0435\u0435 \u043d\u0443\u0436\u043d\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u041f\u0440\u0438 Bitmap Index Scan \u0438 Seq Scan (\u043d\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435) \u0431\u0438\u0442-\u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430 \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u041f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u0430\u044f \u0442\u0430\u043a\u0438\u043c \u0444\u043b\u0430\u0433\u043e\u043c \u0441\u0442\u0440\u043e\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u0435\u043d\u0430 \u043f\u043e\u0437\u0436\u0435, \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u043d\u043e\u0441\u0438\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0431\u043b\u043e\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, UPDATE.<\/p>\n<p>\u0412\u043e\u0437\u0432\u0440\u0430\u0442 \u0432 \u0431\u043b\u043e\u043a \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432 \u043d\u0435\u043c \u0444\u043b\u0430\u0433\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b (Execution Time: 1.822 ms), \u043d\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e. \u041f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u043c\u043e\u0433\u0443\u0442 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0431\u043b\u043e\u043a\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u0435\u0434\u0451\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u043c\u0451\u0440\u0442\u0432\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e:<\/p>\n<pre><code class=\"sql\">explain (analyze, settings, buffers, costs off) select * from t where id between 1 and 9000;                                 QUERY PLAN -------------------------------------------------------------  Index Scan using t_pkey on t (actual time=0.012..0.203 rows=99 loops=1)    Index Cond: ((id &gt;= 1) AND (id &lt;= 9000))    Buffers: shared hit=27  Planning:    Buffers: shared hit=3  Planning Time: 0.085 ms  Execution Time: 0.356 ms (7 rows)<\/code><\/pre>\n<p>\u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 (\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435) \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u0440\u043e\u0447\u043b\u0430 27 \u0431\u043b\u043e\u043a\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u043e 109. \u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u043e\u0441\u044c \u0441 1.822 \u043c\u0441 \u0434\u043e 0.356 \u043c\u0441, \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438 \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u043c \u0447\u0438\u0441\u043b\u0435 \u0441\u0442\u0440\u043e\u043a \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0443\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u044d\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c \u0442\u0435\u0441\u0442\u043e\u043c pgbench.<\/p>\n<h3>\u0412\u043b\u0438\u044f\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0441\u0430\u043c\u0443\u044e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 pgbench_branches, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b pgbench \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043c \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043d\u0435 \u043e\u0447\u0438\u0441\u0442\u0438\u043b \u0431\u043b\u043e\u043a\u0438 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e. \u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0442\u0435\u0441\u0442\u0430 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c \u043d\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a, \u043d\u0435 \u0432\u044b\u0448\u0435\u0434\u0448\u0438\u0435 \u0437\u0430 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"sql\">pgbench -i psql -c \"alter table pgbench_branches set (autovacuum_enabled=off)\"<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0431\u0430\u0437\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435 \u0434\u0430\u0432\u0430\u044f \u0432\u0430\u043a\u0443\u0443\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442:<\/p>\n<pre><code class=\"sql\">begin; select pg_current_xact_id();<\/code><\/pre>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"sql\">pgbench -T 100000 -P 30 progress: 30.0 s, 510.9 tps, lat 1.954 ms stddev 1.278, 0 failed progress: 60.0 s, 374.2 tps, lat 2.670 ms stddev 1.959, 0 failed progress: 90.0 s, 308.6 tps, lat 3.238 ms stddev 1.583, 0 failed progress: 120.0 s, 255.5 tps, lat 3.911 ms stddev 1.989, 0 failed progress: 150.0 s, 211.3 tps, lat 4.730 ms stddev 2.706, 0 failed progress: 180.0 s, 163.9 tps, lat 6.098 ms stddev 4.372, 0 failed progress: 210.0 s, 130.1 tps, lat 7.684 ms stddev 5.986, 0 failed progress: 240.0 s, 102.7 tps, lat 9.735 ms stddev 7.363, 0 failed progress: 270.0 s, 70.9 tps, lat 14.094 ms stddev 9.706, 0 failed progress: 300.0 s, 62.4 tps, lat 16.018 ms stddev 9.223, 0 failed<\/code><\/pre>\n<p>\u0418\u0437-\u0437\u0430 \u0443\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430 \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 UPDATE (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 pgbench), \u043d\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u043e\u0447\u0438\u0449\u0430\u0442\u044c\u0441\u044f \u043d\u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0432\u043d\u0443\u0442\u0440\u0438\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u043e\u0439, \u043d\u0438 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c\u043e\u043c. \u0412\u0435\u0440\u0441\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u043d\u0430\u0447\u043d\u0443\u0442 \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0431\u043b\u043e\u043a\u0430\u0445.<\/p>\n<p>\u0412 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 pgbench_branches \u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u043e\u043a\u0430, \u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0412 \u0431\u043b\u043e\u043a\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f 226 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a, \u0438 \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u0447\u0435\u0440\u043f\u0430\u043d\u043e, \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a \u043f\u043e\u0439\u0434\u0443\u0442 \u0443\u0436\u0435 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u043b\u043e\u043a. \u0421\u0442\u0440\u043e\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439: UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;<\/p>\n<pre><code class=\"sql\">select lp, t_ctid, (t_infomask2 &amp; 16384)!=0 hhu, (t_infomask2 &amp; 32768)!=0 hot from heap_page_items(get_raw_page('pgbench_branches', 0));  lp  | t_ctid  | hhu | hot  -----+---------+-----+-----    1 | (0,2)   | t   | f    2 | (0,3)   | t   | t ...  224 | (0,225) | t   | t  226 | (1,1)   | f   | t (4 rows)<\/code><\/pre>\n<figure class=\"full-width\">\n<div><figcaption>\u0426\u0435\u043f\u043e\u0447\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b pgbench_branches \u0438 \u0435\u0451 \u0438\u043d\u0434\u0435\u043a\u0441<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0431\u043b\u043e\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u0432\u0435\u0440\u0441\u0438\u0439, \u0438 \u043d\u0430 \u043f\u0435\u0440\u0432\u0443\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0432 \u0431\u043b\u043e\u043a \u0432\u0435\u0440\u0441\u0438\u044e \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430. \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0441\u0442\u0440\u043e\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 HOT update. \u0418\u043d\u0434\u0435\u043a\u0441 \u0441\u043e\u0437\u0434\u0430\u043d \u043d\u0430 \u0441\u0442\u043e\u043b\u0431\u0435\u0446\u00a0bid,\u00a0\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u043b\u0431\u0435\u0446 bbalance. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438 \u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0432\u0435\u0440\u0441\u0438\u0439 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u043e \u0432\u00a0\u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0431\u043b\u043e\u043a\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0446\u0435\u043f\u043e\u0447\u0435\u043a \u0432\u0435\u0440\u0441\u0438\u0439 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<pre><code class=\"sql\">begin transaction isolation level repeatable<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-462283","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/462283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=462283"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/462283\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=462283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=462283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=462283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}