{"id":350285,"date":"2023-07-14T15:03:10","date_gmt":"2023-07-14T15:03:10","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=350285"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=350285","title":{"rendered":"<span>\u041f\u0435\u0440\u0435\u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044f \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 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>\u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 B-tree \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438. \u0423 \u043d\u0438\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0438 \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0434\u0432\u0438\u0436\u043a\u043e\u0432 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u043f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0435\u0449\u0435 \u0438 \u0441 GIN \u0438 GIST \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043d\u044b\u043c\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438, \u0442\u043e \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u0435\u0449\u0435 \u0438 \u043e BRIN \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0442\u0438\u043f, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0434\u0430\u0436\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u043e. \u041f\u0430\u0440\u0443 \u0432\u0435\u0440\u0441\u0438\u0439 PostgresSQL \u043d\u0430\u0437\u0430\u0434 \u043e\u043d \u0431\u044b\u043b \u043d\u0435 \u0442\u043e \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u043d\u0435\u043f\u043e\u043f\u0443\u043b\u044f\u0440\u0435\u043d, \u043d\u043e \u0438 \u0441\u0442\u0440\u043e\u0433\u043e \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043e\u0439\u0442\u0438 \u0434\u0430\u0436\u0435 B-tree \u0432 \u043f\u043b\u0430\u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p><strong>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441!<\/strong><\/p>\n<h3>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441<\/h3>\n<p>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u043c\u0435\u043a\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 &#171;\u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430&#187;. \u042d\u0442\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 Python \u044d\u0442\u043e Dict, \u0432 Java HashMap, \u0432 JS Map.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<h4>\u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/h4>\n<p>\u0425\u044d\u0448 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0445\u044d\u0448 \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 32-\u0431\u0438\u0442\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e &#8212; \u0445\u044d\u0448-\u043a\u043e\u0434. \u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0441\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0443 (\u0432\u0441\u0435\u0433\u043e \u043e\u043a\u043e\u043b\u043e 4 \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439).<\/p>\n<p>\u0425\u044d\u0448-\u043a\u043e\u0434 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u043e\u043c\u0435\u0440 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0442.\u043d. \u0431\u0430\u043a\u0435\u0442\u043e\u0432. \u0410 \u0432 \u0431\u0430\u043a\u0435\u0442\u0430\u0445 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0445\u044d\u0448-\u043a\u043e\u0434\u0430 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0430\u044f \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u044d\u0442\u043e \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e. \u0414\u0435\u043b\u0438\u043c \u0447\u0438\u0441\u043b\u043e \u0410 \u043d\u0430 \u0447\u0438\u0441\u043b\u043e \u0411 \u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0445\u044d\u0448-\u043a\u043e\u0434\u043e\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u043a\u0438\u0434\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u043f\u043e \u0442\u0440\u0435\u043c \u0431\u0430\u043a\u0435\u0442\u0430\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>mod(3)<\/code><\/p>\n<pre><code class=\"sql\">db=# SELECT n, mod(n, 3) AS bucket FROM generate_series(1, 10) AS n;  n  \u2502 bucket \u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500   1 \u2502      1   2 \u2502      2   3 \u2502      0   4 \u2502      1   5 \u2502      2   6 \u2502      0   7 \u2502      1   8 \u2502      2   9 \u2502      0  10 \u2502      1<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0438\u043d\u0434\u0435\u043a\u0441, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u043a \u043d\u0435\u043c\u0443 \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0445\u044d\u0448-\u043a\u043e\u0434 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043a\u043e\u0440\u0442\u0435\u0436 \u0432 \u0431\u0430\u043a\u0435\u0442. <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0435 \u043f\u043e\u0438\u0441\u043a, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u0435\u0440\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0445\u044d\u0448-\u043a\u043e\u0434, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u0431\u0430\u043a\u0435\u0442, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0438.<\/p>\n<h4>\u041a\u043e\u043b\u043b\u0438\u0437\u0438\u0438<\/h4>\n<p>\u041d\u0435\u0442\u0440\u0443\u0434\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u0442\u043e\u043c\u0443 \u0436\u0435 \u0445\u044d\u0448-\u043a\u043e\u0434\u0443 \u0438 \u0431\u0430\u043a\u0435\u0442\u0443 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>mod(3)<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 2 \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 2, 5, 8.<\/p>\n<p>\u041d\u0430 \u0434\u0435\u043b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0445\u0438\u0442\u0440\u0435\u0435. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0445\u044d\u0448-\u043a\u043e\u0434\u0430<\/p>\n<pre><code class=\"sql\">db=# SELECT     hashtext('text'),     hashchar('c'),     hash_array(array[1,2,3]),     jsonb_hash('{\"me\": \"haki\"}'::jsonb),     timestamp_hash(now()::timestamp); \u2500[ RECORD 1 ]\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 hashtext       \u2502 -451854347 hashchar       \u2502 203891234 hash_array     \u2502 -325393530 jsonb_hash     \u2502 -1784498999 timestamp_hash \u2502 1082344883<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c<code>mod(\u043a\u043e\u043b-\u0432\u043e \u0431\u0430\u043a\u0435\u0442\u043e\u0432)<\/code> \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u0431\u0430\u043a\u0435\u0442\u0430. \u042d\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0431\u0430\u043a\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u0430\u043a\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d, \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0441\u0435\u044f\u0442\u044c \u0445\u044d\u0448-\u043a\u043e\u0434\u044b \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435 \u0438 \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0438.<\/p>\n<p>\u041f\u043e \u043c\u0435\u0440\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043d\u043e\u0432\u044b\u0435 \u0440\u044f\u0434\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f. \u0414\u0430\u043b\u0435\u0435 \u043d\u043e\u0432\u044b\u0435 \u0440\u044f\u0434\u044b \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<h4>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430<\/h4>\n<p>\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u043e\u0440\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u0430\u043a\u0435\u0442 \u043d\u0430 \u0434\u0432\u0430 \u043c\u0435\u043d\u044c\u0448\u0438\u0445. PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044e\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u043a\u0435\u0442\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b \u0440\u043e\u0432\u043d\u043e \u043d\u0430 \u0434\u0432\u0430 \u0431\u0430\u043a\u0435\u0442\u0430. \u041f\u0440\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0431\u0430\u043a\u0435\u0442\u0430 \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, PostgreSQL \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u044e \u0433\u0440\u044f\u0437\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0437\u0430 \u043a\u0443\u043b\u0438\u0441\u0430\u043c\u0438 \u0438 \u043c\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u043d\u044e\u0430\u043d\u0441\u0430\u0445 \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u043a\u0435\u0442\u043e\u0432. \u0414\u043b\u044f \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043f\u043e\u043d\u044f\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u0433\u043b\u0443\u0431\u0436\u0435, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/postgres\/postgres\/blob\/master\/src\/backend\/access\/hash\/README\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438<\/a>.<\/p>\n<h3>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b<\/h3>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u0434\u043e 10 \u0432\u0435\u0440\u0441\u0438\u0438 PostgreSQL. \u0415\u0441\u043b\u0438 \u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442\u0435 <a href=\"https:\/\/www.postgresql.org\/docs\/9.6\/indexes-types.html\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0438<\/a> \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u0432\u0435\u0440\u0441\u0438\u0438 9.6, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u0440\u044f\u043c\u043e\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0435\u0440\u0435\u0436\u0435\u043d\u0438\u0435. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0432 <a href=\"https:\/\/www.postgresql.org\/docs\/current\/wal-intro.html\" rel=\"noopener noreferrer nofollow\">WAL<\/a> &#8212; \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0445 \u0438 \u043d\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0441\u043b\u0435 \u043a\u0440\u044d\u0448\u0435\u0439. <\/p>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 10 \u044d\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u044b\u043b\u0438 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u044b \u0438 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b <a href=\"https:\/\/www.postgresql.org\/docs\/10\/release-10.html#id-1.11.6.20.5.3.3\" rel=\"noopener noreferrer nofollow\">\u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0435\u0441\u0443\u0442<\/a> \u0447\u0435\u0440\u043d\u0443\u044e \u043c\u0435\u0442\u043a\u0443.<\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435<\/h4>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a.<\/p>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441\u044b \u043a\u043e\u0440\u043e\u043a\u0442\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u0442\u0438\u043f\u0430 bit.ly \u0438\u043b\u0438 goo.gl \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 URL, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 URL. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0440\u043e\u0442\u043a\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 <code>https:\/\/short.url\/hb9837<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 <code>https:\/\/hakibenita.com\/automating-the-boring-stuff-in-django-using-the-check-framework<\/code>. \u0427\u0430\u0441\u0442\u044c <code>hb9837<\/code> \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u043e\u043c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043c\u0435\u0436\u0434\u0443 \u0434\u043b\u0438\u043d\u043d\u044b\u043c\u0438 \u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c\u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438:<\/p>\n<pre><code class=\"sql\">CREATE TABLE shorturl (     id serial primary key,     key text not null,     url text not null );<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0441 \u0430\u0432\u0442\u043e\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0438 \u0434\u0432\u0443\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u0435\u0439. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0445\u044d\u0448 \u0438 b-tree \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0434\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u043f\u043e\u043b\u0435\u0439.<\/p>\n<pre><code class=\"sql\">CREATE INDEX shorturl_key_hash_index ON shorturl USING hash(key); CREATE UNIQUE INDEX shorturl_key_btree_index ON shorturl USING btree(key); CREATE INDEX shorturl_url_hash_index ON shorturl USING hash(url); CREATE INDEX shorturl_url_btree_index ON shorturl USING btree(url);<\/code><\/pre>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0438\u0437-\u0437\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, b-tree \u0438\u043d\u0434\u0435\u043a\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0435\u0449\u0435 \u0438  \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c, \u0430 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 &#8212; \u043d\u0435\u0442.<\/p>\n<h4>\u0420\u0430\u0437\u043c\u0435\u0440 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430<\/h4>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043e\u0431\u043e\u0438\u0445 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<pre><code class=\"pgsql\">CREATE EXTENSION \"uuid-ossp\";  DO $$ BEGIN     FOR i IN 0..1000000 loop         INSERT INTO shorturl (key, url) VALUES (         uuid_generate_v4(),         'https:\/\/www.supercool-url.com\/' || round(random() * 10 ^ 6)::text     );     if mod(i, 10000) = 0 THEN         RAISE NOTICE 'rows:%  Hash key%  B-Tree key:%  Hash url:%  B-Tree url:%',             to_char(i, '9999999999'),             to_char(pg_relation_size('shorturl_key_hash_index'), '99999999999'),             to_char(pg_relation_size('shorturl_key_btree_index'), '99999999999'),             to_char(pg_relation_size('shorturl_url_hash_index'), '99999999999'),             to_char(pg_relation_size('shorturl_url_btree_index'), '99999999999');     END IF;     END LOOP; END; $$;<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u043e\u0431\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043f\u043e \u043c\u0435\u0440\u0435 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<ul>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u043c 1\u043a\u043a \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0435 10\u043a \u0441\u0442\u0440\u043e\u043a \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0432\u0441\u0435\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>uuid_generate_v4<\/code> \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 <a href=\"https:\/\/www.postgresql.org\/docs\/current\/uuid-ossp.html\" rel=\"noopener noreferrer nofollow\">uuid-ossp<\/a> \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u043c \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e 6-\u0437\u043d\u0430\u0447\u043d\u043e\u0433\u043e \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u0434\u0435\u043b\u0430\u044f \u0438\u0445 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 PostgreSQL 13 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 \u0447\u0430\u0440\u0442:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/678\/d8d\/c8d\/678d8dc8dc9eab17e06ad58ed2af94c3.png\" alt=\"Hash vs. B-Tree index size\" title=\"\u0420\u0430\u0437\u043c\u0435\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 Hash vs B-Tree\" width=\"822\" height=\"507\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/678\/d8d\/c8d\/678d8dc8dc9eab17e06ad58ed2af94c3.png\"\/><\/p>\n<div><figcaption>\u0420\u0430\u0437\u043c\u0435\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 Hash vs B-Tree<\/figcaption><\/div>\n<\/figure>\n<p>\u0427\u0442\u043e \u043c\u044b \u0442\u0443\u0442 \u0432\u0438\u0434\u0438\u043c?<\/p>\n<ul>\n<li>\n<p>\u0425\u044d\u0448 \u0438\u043d\u0434\u0435\u043a\u0441 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u0435\u0441\u0442\u0430, \u0447\u0435\u043c b-tree<\/p>\n<\/li>\n<li>\n<p>\u0425\u044d\u0448 \u0438\u043d\u0434\u0435\u043a\u0441 \u0440\u0430\u0441\u0442\u0435\u0442 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 b-tree, \u0440\u0430\u0441\u0442\u0443\u0449\u0435\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a, \u0445\u044d\u0448 \u0440\u0430\u0441\u0442\u0435\u0442 \u0440\u044b\u0432\u043a\u0430\u043c\u0438. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0438\u043d\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0434 \u0431\u0430\u043a\u0435\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0425\u044d\u0448 \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430. \u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u0445\u0440\u0430\u043d\u0438\u0442 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b (\u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430), \u0430 b-tree \u0438\u043d\u0434\u0435\u043a\u0441 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0421\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u0430 <code>url<\/code> \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 <code>key<\/code> (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u0435\u043d). \u041e\u0434\u043d\u0430\u043a\u043e \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043e\u0431\u0435\u0438\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438\u043c\u0435\u044e\u0442 \u0441\u0445\u043e\u0436\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440.<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u0430\u044f \u043d\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0442\u0438\u043f\u0430 OLTP, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0438\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c. \u0412\u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<pre><code class=\"sql\">db=# \\di+ shorturl*           Name           \u2502 Type  \u2502 Table    \u2502Size \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 shorturl_key_btree_index \u2502 index \u2502 shorturl \u2502 73 MB shorturl_key_hash_index  \u2502 index \u2502 shorturl \u2502 37 MB shorturl_url_btree_index \u2502 index \u2502 shorturl \u2502 53 MB shorturl_url_hash_index  \u2502 index \u2502 shorturl \u2502 36 MB<\/code><\/pre>\n<p>\u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432\u0434\u0432\u043e\u0435 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b b-tree. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0441 \u043d\u0443\u043b\u044f.<\/p>\n<pre><code>db=# REINDEX TABLE shorturl; REINDEX db=# \\di+ shorturl*           Name           \u2502 Type  \u2502  Table   \u2502 Size \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500 shorturl_key_btree_index \u2502 index \u2502 shorturl \u2502 56 MB shorturl_key_hash_index  \u2502 index \u2502 shorturl \u2502 32 MB shorturl_url_btree_index \u2502 index \u2502 shorturl \u2502 41 MB shorturl_url_hash_index  \u2502 index \u2502 shorturl \u2502 32 MB<\/code><\/pre>\n<p>\u0420\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0432\u0441\u0435\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u043d\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043c\u0435\u0442\u043d\u0435\u0435. \u041d\u043e \u0434\u0430\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0443\u043d\u0434 \u0437\u0430 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438.<\/p>\n<h4>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 fillfactor<\/h4>\n<p><code>fillfactor<\/code> \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u0441\u0430. \u041e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u043c\u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u043a\u043e\u0440\u0442\u0435\u0436\u0438 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0431\u0430\u043a\u0435\u0442\u043e\u0432. \u0427\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 <code>fillfactor<\/code>, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 &#171;\u043f\u0443\u0441\u0442\u043e\u0435&#187; \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435.<\/p>\n<p>\u0414\u043b\u044f b-tree \u044d\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 90, \u0434\u043b\u044f \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430 &#8212; 75. \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u0435 <code>fillfactor<\/code>, \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c.<\/p>\n<details class=\"spoiler\">\n<summary>Code<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"sql\">CREATE TABLE shorturl_ff (     id serial primary key,     key text not null,     url text not null );  CREATE INDEX shorturl_key_hash_index_025 ON shorturl_ff USING hash(key) WITH (fillfactor = 25); CREATE INDEX shorturl_key_hash_index_050 ON shorturl_ff USING hash(key) WITH (fillfactor = 50); CREATE INDEX shorturl_key_hash_index_075 ON shorturl_ff USING hash(key) WITH (fillfactor = 75); CREATE INDEX shorturl_key_hash_index_100 ON shorturl_ff USING hash(key) WITH (fillfactor = 100);  DO $$ BEGIN     RAISE NOTICE 'rows,25,50,75,100';     FOR i IN 0..1000000 LOOP         INSERT INTO shorturl_ff (key, url) VALUES (           uuid_generate_v4(),           'https:\/\/www.supercool-url.com\/' || round(random() * 10 ^ 6)::text         );         IF mod(i, 10000) = 0 THEN             RAISE NOTICE '%,%,%,%,%',                 to_char(i, '9999999999'),                 pg_relation_size('shorturl_key_hash_index_025'),                 pg_relation_size('shorturl_key_hash_index_050'),                 pg_relation_size('shorturl_key_hash_index_075'),                 pg_relation_size('shorturl_key_hash_index_100');         END IF;     END LOOP; END; $$;<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a75\/67a\/164\/a7567a1645f9fb4ac7a3f5bc158c3713.png\" alt=\"Hash index size with different fillfactor values\" title=\"\u0420\u0430\u0437\u043c\u0435\u0440\u044b \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 fillfactor\" width=\"838\" height=\"517\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a75\/67a\/164\/a7567a1645f9fb4ac7a3f5bc158c3713.png\"\/><\/p>\n<div><figcaption>\u0420\u0430\u0437\u043c\u0435\u0440\u044b \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 fillfactor<\/figcaption><\/div>\n<\/figure>\n<p>\u0427\u0430\u0440\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u0435\u043d\u044c\u0448\u0438\u0439 <code>fillfactor<\/code> \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u0430\u043a\u0435\u0442\u044b \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0431\u043e\u043b\u044c\u0448\u0435\u043c\u0443 \u043e\u0431\u0449\u0435\u043c\u0443 \u0440\u0430\u0437\u043c\u0435\u0440\u0443. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 b-tree, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0437\u0435\u0440\u0432\u0438\u0440\u0443\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0434 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043d\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u0441\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u0439 \u0431\u0430\u043a\u0435\u0442. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u0439\u0442\u0435 \u044d\u0442\u043e, \u0435\u0441\u043b\u0438 \u0440\u0435\u0448\u0438\u0442\u0435 \u0432\u043b\u0435\u0437\u0442\u044c \u0440\u0443\u043a\u0430\u043c\u0438 \u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 <code>fillfactor<\/code><\/p>\n<h3>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c<\/h3>\n<p>\u0414\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u0431\u0430\u043b\u0430\u043d\u0441\u0430 \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c\u044e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 &#8212; \u043a\u043b\u044e\u0447 \u043a \u0411\u0414 \u0437\u0434\u043e\u0440\u043e\u0432\u043e\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430. \u041c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438, \u0447\u0442\u043e \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u044e\u0442 \u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u0435. \u0410 \u0447\u0442\u043e \u043d\u0430\u0441\u0447\u0435\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438?<\/p>\n<h4>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0435<\/h4>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u044d\u0442\u0430 \u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432\u043e \u0432\u0441\u0435 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0435 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438\u043d\u0434\u0435\u043a\u0441\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0445\u043e\u0442\u044f \u0438 \u0443\u0441\u043a\u043e\u0440\u044f\u044e\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0447\u0442\u0435\u043d\u0438\u044f, \u043d\u043e \u0438\u043c\u0435\u044e\u0442 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u043f\u0440\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0448\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u043d\u0430 \u0441\u0435\u0439 \u0440\u0430\u0437 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u043c\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c<\/p>\n<pre><code class=\"sql\">DROP TABLE IF EXISTS shorturl_hash; CREATE TABLE shorturl_hash (     id serial primary key,     key text not null,     url text not null ); CREATE INDEX shorturl_hash_hash_ix ON shorturl_hash USING hash(key);<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0437\u0430\u043f\u0438\u0448\u0435\u043c 1\u043a\u043a \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438 \u0437\u0430\u043c\u0435\u0440\u0438\u043c \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f<\/p>\n<details class=\"spoiler\">\n<summary>Code<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"pgsql\">DO $$ DECLARE     n INTEGER := 1000000;     duration INTERVAL := 0;     start TIMESTAMP;     uid TEXT;     url TEXT; BEGIN       FOR i IN 1..n LOOP         uid := uuid_generate_v4()::text;         url := 'https:\/\/www.supercool-url.com\/' || round(random() * 10 ^ 6)::text;         start := clock_timestamp();           INSERT INTO shorturl_hash (key, url) VALUES (uid, url);         duration := duration + (clock_timestamp() - start);     END LOOP;     RAISE NOTICE 'Hash: total=% mean=%', duration, extract('epoch' from duration) \/ n; END; $$; <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code>Hash: total=00:00:09.764746 mean=9.764746e-06<\/code><\/pre>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u0443\u0436\u0435 \u0441 b-tree \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c<\/p>\n<details class=\"spoiler\">\n<summary>Code<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"pgsql\">DO $$ DECLARE   n INTEGER := 100000;   duration INTERVAL := 0;   start TIMESTAMP;   keys TEXT[];  BEGIN   -- Fetch radom keys from the table   SELECT ARRAY_AGG(key) INTO keys   FROM (     SELECT key     FROM shorturl_btree     ORDER BY random()     LIMIT n   ) AS foo;      FOR i IN array_lower(keys, 1)..array_upper(keys, 1) LOOP       start := clock_timestamp();         PERFORM * FROM shorturl_btree WHERE key = keys[i];       duration := duration + (clock_timestamp() - start);   END LOOP;   RAISE NOTICE 'B-Tree: total=% mean=%', duration, extract('epoch' from duration) \/ n; END; $$;<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code>B-Tree: total=00:00:10.822158 mean=1.0822158e-05<\/code><\/pre>\n<p>11 \u0441\u0435\u043a\u0443\u043d\u0434. \u0422\u0435\u0441\u0442 \u0434\u0430\u043b\u0435\u043a \u043e\u0442 \u043d\u0430\u0443\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u0441\u0442\u0432\u043e \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u0441\u0430.<\/p>\n<h4>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438<\/h4>\n<p>\u0412 \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430\u043c \u0432\u0430\u0436\u043d\u0430\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a<\/p>\n<details class=\"spoiler\">\n<summary>Code<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"pgsql\">DO $$ DECLARE   n INTEGER := 100000;   duration INTERVAL := 0;   start TIMESTAMP;   keys TEXT[];  BEGIN     -- Fetch radom keys from the table     SELECT ARRAY_AGG(key) INTO keys     FROM (       SELECT key       FROM shorturl_hash       ORDER BY random()       LIMIT n     ) AS foo;      FOR i IN array_lower(keys, 1)..array_upper(keys, 1) LOOP         start := clock_timestamp();         PERFORM * FROM shorturl_hash WHERE key = keys[i];         duration := duration + (clock_timestamp() - start);     END LOOP;     RAISE NOTICE 'Hash: total=% mean=%', duration, extract('epoch' from duration) \/ n; END; $$; <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code>Hash: total=00:00:00.590032 mean=5.90032e-06<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 100\u043a \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0437\u0430 \u0440\u0430\u0437 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043f\u043e\u043b\u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>\u041f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u043c \u0434\u043b\u044f b-tree<\/p>\n<details class=\"spoiler\">\n<summary>Code<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"pgsql\">DO $$ DECLARE   n INTEGER := 100000;   duration INTERVAL := 0;   start TIMESTAMP;   keys TEXT[];  BEGIN   -- Fetch radom keys from the table   SELECT ARRAY_AGG(key) INTO keys   FROM (     SELECT key     FROM shorturl_btree     ORDER BY random()     LIMIT n   ) AS foo;      FOR i IN array_lower(keys, 1)..array_upper(keys, 1) LOOP       start := clock_timestamp();         PERFORM * FROM shorturl_btree WHERE key = keys[i];       duration := duration + (clock_timestamp() - start);   END LOOP;   RAISE NOTICE 'B-Tree: total=% mean=%', duration, extract('epoch' from duration) \/ n; END; $$;<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<pre><code>B-Tree: total=00:00:00.923244 mean=9.23244e-06<\/code><\/pre>\n<p>\u0411\u0435\u0437 \u0434\u0440\u0430\u043c\u0430\u0442\u0438\u0447\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u043d\u043e \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u043e\u043f\u044f\u0442\u044c \u0432\u043f\u0435\u0440\u0435\u0434\u0438.<\/p>\n<h4>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f<\/h4>\n<p>\u041d\u0438\u0447\u0442\u043e \u043d\u0435 \u0434\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e. \u0423 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043c\u043d\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u043f\u0440\u043e\u0438\u0441\u0442\u0435\u043a\u0430\u044e\u0449\u0438\u0445 \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0441\u0430\u043c\u0438\u0445 \u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430<\/p>\n<pre><code class=\"sql\">db=# CREATE UNIQUE INDEX shorturl_unique_key ON shorturl USING hash(key); ERROR:  access method \"hash\" does not support unique indexes<\/code><\/pre>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432<\/p>\n<pre><code class=\"sql\">db=# CREATE INDEX shorturl_key_and_url ON shorturl USING hash(key, url); ERROR:  access method \"hash\" does not support multicolumn indexes<\/code><\/pre>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443<\/p>\n<pre><code class=\"sql\">db=# CREATE INDEX shorturl_sorted_key ON shorturl USING hash(key desc); ERROR:  access method \"hash\" does not support ASC\/DESC options<\/code><\/pre>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/p>\n<pre><code class=\"sql\">db=# CLUSTER shorturl USING shorturl_url_hash_index; ERROR:  cannot cluster on index \"shorturl_url_hash_index\" because access method does not support clustering<\/code><\/pre>\n<p>\u041d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>CLUSTER<\/code> \u0438 \u0437\u0430\u0447\u0435\u043c \u0432\u0430\u043c \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c? \u041e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/hakibenita.com\/sql-tricks-application-dba#always-load-sorted-data\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c<\/p>\n<pre><code class=\"sql\">db=# EXPLAIN (COSTS OFF) SELECT * FROM shorturl WHERE key BETWEEN '1' AND '2';                                    QUERY PLAN \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Gather   -> Seq Scan on shorturl         Filter: ((key >= '1'::text) AND (key &lt;= '2'::text)) <\/code><\/pre>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0434\u0440\u0443\u0436\u0438\u0442 \u0441 <code>ORDER BY<\/code><\/p>\n<pre><code class=\"sql\">db=# EXPLAIN (COSTS OFF) SELECT * FROM shorturl ORDER BY key LIMIT 10;                                     QUERY PLAN \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 Limit   ->  Index Scan using shorturl_key_btree_index on shorturl<\/code><\/pre>\n<p>\u041c\u043e\u0436\u0435\u043c \u0434\u043b\u044f \u0432\u0435\u0440\u043d\u043e\u0441\u0442\u0438 \u0434\u0440\u043e\u043f\u043d\u0443\u0442\u044c b-tree \u0438\u043d\u0434\u0435\u043a\u0441 \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c<\/p>\n<pre><code class=\"pgsql\">db=# BEGIN; BEGIN db=# DROP INDEX shorturl_key_btree_index; DROP INDEX db=# EXPLAIN (COSTS OFF) SELECT * FROM shorturl ORDER BY key LIMIT 10;                    QUERY PLAN \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500  Limit    ->  Gather Merge          Workers Planned: 2          ->  Sort                Sort Key: key                ->  Parallel Seq Scan on shorturl (6 rows) db=# rollback; ROLLBACK<\/code><\/pre>\n<h3>\u0418\u0442\u043e\u0433<\/h3>\n<p>\u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u044b &#8212; \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u0435\u043d \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043a\u043b\u044e\u0447\u0443. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u044e\u0430\u043d\u0441\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043e 10 \u0432\u0435\u0440\u0441\u0438\u0438 PostgreSQL \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u0438 DBA \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0437\u0430\u0431\u044b\u0442\u044c \u043e \u0442\u0430\u043a\u043e\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0435.<\/p>\n<p>\u041d\u043e \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0432 \u0441\u0432\u0435\u0436\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445:<\/p>\n<ul>\n<li>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u0431\u044b\u043b \u0434\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d-\u0440\u0435\u0434\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u0435\u0441\u0442\u0430, \u0447\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 b-tree.<\/p>\n<\/li>\n<li>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u0442 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u043a \u043f\u0440\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0435, \u0442\u0430\u043a \u0438 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u043c\u0435\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0432\u043e\u0434\u044f\u0442 \u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e\u0441\u0442\u044c \u043a \u0443\u0437\u043a\u043e\u043c\u0443 \u0440\u044f\u0434\u0443 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442\u0435\u0441\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/postgres\/postgres\/blob\/master\/src\/backend\/access\/hash\/README\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a><\/p>\n<\/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\/747910\/\"> https:\/\/habr.com\/ru\/articles\/747910\/<\/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>\u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 B-tree \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438. \u0423 \u043d\u0438\u0445 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0438 \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0434\u0432\u0438\u0436\u043a\u043e\u0432 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u043f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0438\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0442\u043e \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0435\u0449\u0435 \u0438 \u0441 GIN \u0438 GIST \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u043d\u044b\u043c\u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u044f\u0434\u0430\u043c\u0438, \u0442\u043e \u0441\u043b\u044b\u0448\u0430\u043b\u0438 \u0435\u0449\u0435 \u0438 \u043e BRIN \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043c\u0435\u043d\u0435\u0435 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0442\u0438\u043f, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0434\u0430\u0436\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043b\u044b\u0448\u0430\u043b\u043e. \u041f\u0430\u0440\u0443 \u0432\u0435\u0440\u0441\u0438\u0439 PostgresSQL \u043d\u0430\u0437\u0430\u0434 \u043e\u043d \u0431\u044b\u043b \u043d\u0435 \u0442\u043e \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u043d\u0435\u043f\u043e\u043f\u0443\u043b\u044f\u0440\u0435\u043d, \u043d\u043e \u0438 \u0441\u0442\u0440\u043e\u0433\u043e \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043e\u0439\u0442\u0438 \u0434\u0430\u0436\u0435 B-tree \u0432 \u043f\u043b\u0430\u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p><strong>\u0421\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u0442\u043a\u0440\u043e\u0435\u043c \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441!<\/strong><\/p>\n<h3>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441<\/h3>\n<p>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u043c\u0435\u043a\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 &#171;\u0445\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430&#187;. \u042d\u0442\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0412 Python \u044d\u0442\u043e Dict, \u0432 Java HashMap, \u0432 JS Map.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u0440\u043e\u0444\u0438\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0438\u0445 \u0440\u0430\u0431\u043e\u0442\u044b.<\/p>\n<h4>\u0425\u044d\u0448-\u0442\u0430\u0431\u043b\u0438\u0446\u0430<\/h4>\n<p>\u0425\u044d\u0448 \u0438\u043d\u0434\u0435\u043a\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0445\u044d\u0448 \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 32-\u0431\u0438\u0442\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e &#8212; \u0445\u044d\u0448-\u043a\u043e\u0434. \u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0441\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0443 (\u0432\u0441\u0435\u0433\u043e \u043e\u043a\u043e\u043b\u043e 4 \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439).<\/p>\n<p>\u0425\u044d\u0448-\u043a\u043e\u0434 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u043d\u043e\u043c\u0435\u0440 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0442.\u043d. \u0431\u0430\u043a\u0435\u0442\u043e\u0432. \u0410 \u0432 \u0431\u0430\u043a\u0435\u0442\u0430\u0445 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0445\u044d\u0448-\u043a\u043e\u0434\u0430 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0430\u044f \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u044d\u0442\u043e \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e. \u0414\u0435\u043b\u0438\u043c \u0447\u0438\u0441\u043b\u043e \u0410 \u043d\u0430 \u0447\u0438\u0441\u043b\u043e \u0411 \u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0445\u044d\u0448-\u043a\u043e\u0434\u043e\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u043a\u0438\u0434\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u043f\u043e \u0442\u0440\u0435\u043c \u0431\u0430\u043a\u0435\u0442\u0430\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>mod(3)<\/code><\/p>\n<pre><code class=\"sql\">db=# SELECT n, mod(n, 3) AS bucket FROM generate_series(1, 10) AS n;  n  \u2502 bucket \u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500   1 \u2502      1   2 \u2502      2   3 \u2502      0   4 \u2502      1   5 \u2502      2   6 \u2502      0   7 \u2502      1   8 \u2502      2   9 \u2502      0  10 \u2502      1<\/code><\/pre>\n<p>\u041a\u043e\u0433\u0434\u0430 \u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0438\u043d\u0434\u0435\u043a\u0441, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442 \u043a \u043d\u0435\u043c\u0443 \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u043f\u043e\u043c\u0435\u0449\u0430\u0435\u0442 \u0445\u044d\u0448-\u043a\u043e\u0434 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043a\u043e\u0440\u0442\u0435\u0436 \u0432 \u0431\u0430\u043a\u0435\u0442. <\/p>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0435 \u043f\u043e\u0438\u0441\u043a, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u0435\u0440\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0445\u044d\u0448-\u043a\u043e\u0434, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u0431\u0430\u043a\u0435\u0442, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0438.<\/p>\n<h4>\u041a\u043e\u043b\u043b\u0438\u0437\u0438\u0438<\/h4>\n<p>\u041d\u0435\u0442\u0440\u0443\u0434\u043d\u043e \u0434\u043e\u0433\u0430\u0434\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u0442\u043e\u043c\u0443 \u0436\u0435 \u0445\u044d\u0448-\u043a\u043e\u0434\u0443 \u0438 \u0431\u0430\u043a\u0435\u0442\u0443 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>mod(3)<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043e\u0434 2 \u0434\u043b\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 2, 5, 8.<\/p>\n<p>\u041d\u0430 \u0434\u0435\u043b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u0445\u0438\u0442\u0440\u0435\u0435. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0445\u044d\u0448-\u043a\u043e\u0434\u0430<\/p>\n<pre><code class=\"sql\">db=# SELECT     hashtext('text'),     hashchar('c'),     hash_array(array[1,2,3]),     jsonb_hash('{\"me\": \"haki\"}'::jsonb),     timestamp_hash(now()::timestamp); \u2500[ RECORD 1 ]\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 hashtext       \u2502 -451854347 hashchar       \u2502 203891234 hash_array     \u2502 -325393530 jsonb_hash     \u2502 -1784498999 timestamp_hash \u2502 1082344883<\/code><\/pre>\n<p>\u0417\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c<code>mod(\u043a\u043e\u043b-\u0432\u043e \u0431\u0430\u043a\u0435\u0442\u043e\u0432)<\/code> \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u043c\u0435\u0440\u0430 \u0431\u0430\u043a\u0435\u0442\u0430. \u042d\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0431\u0430\u043a\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u0430\u043a\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d, \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0432\u0441\u0435 \u0435\u0449\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0441\u0435\u044f\u0442\u044c \u0445\u044d\u0448-\u043a\u043e\u0434\u044b \u0432 \u043a\u043e\u0440\u0437\u0438\u043d\u0435 \u0438 \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0435 \u043a\u043e\u0440\u0442\u0435\u0436\u0438.<\/p>\n<p>\u041f\u043e \u043c\u0435\u0440\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043d\u043e\u0432\u044b\u0435 \u0440\u044f\u0434\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f. \u0414\u0430\u043b\u0435\u0435 \u043d\u043e\u0432\u044b\u0435 \u0440\u044f\u0434\u044b \u043f\u0438\u0448\u0443\u0442\u0441\u044f \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<h4>\u0420\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0430<\/h4>\n<p>\u0412 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u043e\u0440\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0434\u0438\u043d \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u0430\u043a\u0435\u0442 \u043d\u0430 \u0434\u0432\u0430 \u043c\u0435\u043d\u044c\u0448\u0438\u0445. PostgreSQL \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044e\u0442, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0431\u0430\u043a\u0435\u0442\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b \u0440\u043e\u0432\u043d\u043e \u043d\u0430 \u0434\u0432\u0430 \u0431\u0430\u043a\u0435\u0442\u0430. \u041f\u0440\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0431\u0430\u043a\u0435\u0442\u0430 \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435.<\/p>\n<p>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, PostgreSQL \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u044e \u0433\u0440\u044f\u0437\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0437\u0430 \u043a\u0443\u043b\u0438\u0441\u0430\u043c\u0438 \u0438 \u043c\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u043d\u044e\u0430\u043d\u0441\u0430\u0445 \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0445\u044d\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u043a\u0435\u0442\u043e\u0432. \u0414\u043b\u044f \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0445 \u043f\u043e\u043d\u044f\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 \u0433\u043b\u0443\u0431\u0436\u0435, \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 <a href=\"https:\/\/github.com\/postgres\/postgres\/blob\/master\/src\/backend\/access\/hash\/README\" rel=\"noopener noreferrer nofollow\">\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438<\/a>.<\/p>\n<h3>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b<\/h3>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043a \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044e \u0434\u043e 10 \u0432\u0435\u0440\u0441\u0438\u0438 PostgreSQL. \u0415\u0441\u043b\u0438 \u043f\u043e\u0447\u0438\u0442\u0430\u0435\u0442\u0435 <a href=\"https:\/\/www.postgresql.org\/docs\/9.6\/indexes-types.html\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u043a\u0438<\/a> \u043f\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c \u0432\u0435\u0440\u0441\u0438\u0438 9.6, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u0440\u044f\u043c\u043e\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0435\u0440\u0435\u0436\u0435\u043d\u0438\u0435. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043d\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0432 <a href=\"https:\/\/www.postgresql.org\/docs\/current\/wal-intro.html\" rel=\"noopener noreferrer nofollow\">WAL<\/a> &#8212; \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0445 \u0438 \u043d\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0441\u043b\u0435 \u043a\u0440\u044d\u0448\u0435\u0439. <\/p>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 10 \u044d\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0431\u044b\u043b\u0438 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u044b \u0438 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b <a href=\"https:\/\/www.postgresql.org\/docs\/10\/release-10.html#id-1.11.6.20.5.3.3\" rel=\"noopener noreferrer nofollow\">\u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0435\u0441\u0443\u0442<\/a> \u0447\u0435\u0440\u043d\u0443\u044e \u043c\u0435\u0442\u043a\u0443.<\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435<\/h4>\n<p>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a.<\/p>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441\u044b \u043a\u043e\u0440\u043e\u043a\u0442\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u0442\u0438\u043f\u0430 bit.ly \u0438\u043b\u0438 goo.gl \u0441\u043e\u0437\u0434\u0430\u044e\u0442 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 URL, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 URL. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0440\u043e\u0442\u043a\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 <code>https:\/\/short.url\/hb9837<\/code> \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 <code>https:\/\/hakibenita.com\/automating-the-boring-stuff-in-django-using-the-check-framework<\/code>. \u0427\u0430\u0441\u0442\u044c <code>hb9837<\/code> \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u044e\u0447\u043e\u043c.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043c\u0430\u043f\u043f\u0438\u043d\u0433\u0430 \u043c\u0435\u0436\u0434\u0443 \u0434\u043b\u0438\u043d\u043d\u044b\u043c\u0438 \u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u043c\u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438:<\/p>\n<pre><code class=\"sql\">CREATE TABLE shorturl (     id serial primary key,     key text not null,     url text not null );<\/code><\/pre>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0441 \u0430\u0432\u0442\u043e\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0438 \u0434\u0432\u0443\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u0435\u0439. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0445\u044d\u0448 \u0438 b-tree \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0434\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u043f\u043e\u043b\u0435\u0439.<\/p>\n<pre><code class=\"sql\">CREATE INDEX shorturl_key_hash_index ON shorturl USING hash(key); CREATE UNIQUE INDEX shorturl_key_btree_index ON shorturl USING btree(key); CREATE INDEX shorturl_url_hash_index ON shorturl USING hash(url); CREATE INDEX shorturl_url_btree_index ON shorturl USING btree(url);<\/code><\/pre>\n<p>\u041a\u0441\u0442\u0430\u0442\u0438, \u0438\u0437-\u0437\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, b-tree \u0438\u043d\u0434\u0435\u043a\u0441 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0435\u0449\u0435 \u0438  \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c, \u0430 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 &#8212; \u043d\u0435\u0442.<\/p>\n<h4>\u0420\u0430\u0437\u043c\u0435\u0440 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430<\/h4>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043e\u0431\u043e\u0438\u0445 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<pre><code class=\"pgsql\">CREATE EXTENSION \"uuid-ossp\";  DO $$ BEGIN     FOR i IN 0..1000000 loop         INSERT INTO shorturl (key, url) VALUES (         uuid_generate_v4(),         'https:\/\/www.supercool-url.com\/' || round(random() * 10 ^ 6)::text     );     if mod(i, 10000) = 0 THEN         RAISE NOTICE 'rows:%  Hash key%  B-Tree key:%  Hash url:%  B-Tree url:%',             to_char(i, '9999999999'),             to_char(pg_relation_size('shorturl_key_hash_index'), '99999999999'),             to_char(pg_relation_size('shorturl_key_btree_index'), '99999999999'),             to_char(pg_relation_size('shorturl_url_hash_index'), '99999999999'),             to_char(pg_relation_size('shorturl_url_btree_index'), '99999999999');     END IF;     END LOOP; END; $$;<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u0432\u0435\u0434\u0443\u0442 \u0441\u0435\u0431\u044f \u043e\u0431\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043f\u043e \u043c\u0435\u0440\u0435 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<ul>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u043c 1\u043a\u043a \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u0436\u0434\u044b\u0435 10\u043a \u0441\u0442\u0440\u043e\u043a \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0432\u0441\u0435\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>uuid_generate_v4<\/code> \u0438\u0437 \u043f\u0430\u043a\u0435\u0442\u0430 <a href=\"https:\/\/www.postgresql.org\/docs\/current\/uuid-ossp.html\" rel=\"noopener noreferrer nofollow\">uuid-ossp<\/a> \u0434\u043b\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>\u0413\u0435\u043d\u0435\u0440\u0438\u043c \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e 6-\u0437\u043d\u0430\u0447\u043d\u043e\u0433\u043e \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u0434\u0435\u043b\u0430\u044f \u0438\u0445 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043d\u0430 PostgreSQL 13 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043d\u0430 \u0447\u0430\u0440\u0442:<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0430\u0437\u043c\u0435\u0440 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 Hash vs B-Tree<\/figcaption><\/div>\n<\/figure>\n<p>\u0427\u0442\u043e \u043c\u044b \u0442\u0443\u0442 \u0432\u0438\u0434\u0438\u043c?<\/p>\n<ul>\n<li>\n<p>\u0425\u044d\u0448 \u0438\u043d\u0434\u0435\u043a\u0441 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u0435\u0441\u0442\u0430, \u0447\u0435\u043c b-tree<\/p>\n<\/li>\n<li>\n<p>\u0425\u044d\u0448 \u0438\u043d\u0434\u0435\u043a\u0441 \u0440\u0430\u0441\u0442\u0435\u0442 \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 b-tree, \u0440\u0430\u0441\u0442\u0443\u0449\u0435\u0433\u043e \u043b\u0438\u043d\u0435\u0439\u043d\u043e \u043f\u043e \u043c\u0435\u0440\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a, \u0445\u044d\u0448 \u0440\u0430\u0441\u0442\u0435\u0442 \u0440\u044b\u0432\u043a\u0430\u043c\u0438. \u042d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0438\u043d\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u0430\u043b\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043f\u043e\u0434 \u0431\u0430\u043a\u0435\u0442\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0425\u044d\u0448 \u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430. \u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u0445\u0440\u0430\u043d\u0438\u0442 \u0445\u044d\u0448-\u043a\u043e\u0434\u044b (\u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430), \u0430 b-tree \u0438\u043d\u0434\u0435\u043a\u0441 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u0425\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0421\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u0430 <code>url<\/code> \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 <code>key<\/code> (\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u0435\u043d). \u041e\u0434\u043d\u0430\u043a\u043e \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043e\u0431\u0435\u0438\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438\u043c\u0435\u044e\u0442 \u0441\u0445\u043e\u0436\u0438\u0439 \u0440\u0430\u0437\u043c\u0435\u0440.<\/p>\n<\/li>\n<\/ul>\n<p>\u0417\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u0430\u044f \u043d\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0442\u0438\u043f\u0430 OLTP, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0438\u0434\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c. \u0412\u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/p>\n<pre><code class=\"sql\">db=# \\di+ shorturl*           Name           \u2502 Type  \u2502 Table    \u2502Size \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 shorturl_key_btree_index \u2502 index \u2502 shorturl \u2502 73 MB shorturl_key_hash_index  \u2502 index \u2502 shorturl \u2502 37 MB shorturl_url_btree_index \u2502 index \u2502 shorturl \u2502 53 MB shorturl_url_hash_index  \u2502 index \u2502 shorturl \u2502 36 MB<\/code><\/pre>\n<p>\u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0432\u0434\u0432\u043e\u0435 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b b-tree. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0441 \u043d\u0443\u043b\u044f.<\/p>\n<pre><code>db=# REINDEX TABLE shorturl; REINDEX db=# \\di+ shorturl*           Name           \u2502 Type  \u2502  Table   \u2502 Size \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500 shorturl_key_btree_index \u2502 index \u2502 shorturl \u2502 56 MB shorturl_key_hash_index  \u2502 index \u2502 shorturl \u2502 32 MB shorturl_url_btree_index \u2502 index \u2502 shorturl \u2502 41 MB shorturl_url_hash_index  \u2502 index \u2502 shorturl \u2502 32 MB<\/code><\/pre>\n<p>\u0420\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0432\u0441\u0435\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u043d\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043c\u0435\u0442\u043d\u0435\u0435. \u041d\u043e \u0434\u0430\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0443\u043d\u0434 \u0437\u0430 \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438.<\/p>\n<h4>\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 fillfactor<\/h4>\n<p><code>fillfactor<\/code> \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u0441\u0430. \u041e\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u043c\u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u043a\u043e\u0440\u0442\u0435\u0436\u0438 \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0431\u0430\u043a\u0435\u0442\u043e\u0432. \u0427\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 <code>fillfactor<\/code>, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435 &#171;\u043f\u0443\u0441\u0442\u043e\u0435&#187; \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0432 \u0438\u043d\u0434\u0435\u043a\u0441\u0435.<\/p>\n<p>\u0414\u043b\u044f b-tree \u044d\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 90, \u0434\u043b\u044f \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430 &#8212; 75. \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043b\u0438\u044f\u043d\u0438\u0435 <code>fillfactor<\/code>, \u0441\u0440\u0430\u0432\u043d\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c.<\/p>\n<details class=\"spoiler\">\n<summary>Code<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"sql\">CREATE TABLE shorturl_ff (     id serial primary key,     key text not null,     url text not null );  CREATE INDEX shorturl_key_hash_index_025 ON shorturl_ff USING hash(key) WITH (fillfactor = 25); CREATE INDEX shorturl_key_hash_index_050 ON shorturl_ff USING hash(key) WITH (fillfactor = 50); CREATE INDEX shorturl_key_hash_index_075 ON shorturl_ff USING hash(key) WITH (fillfactor = 75); CREATE INDEX shorturl_key_hash_index_100 ON shorturl_ff USING hash(key) WITH (fillfactor = 100);  DO $$ BEGIN     RAISE NOTICE 'rows,25,50,75,100';     FOR i IN 0..1000000 LOOP         INSERT INTO shorturl_ff (key, url) VALUES (           uuid_generate_v4(),           'https:\/\/www.supercool-url.com\/' || round(random() * 10 ^ 6)::text         );         IF mod(i, 10000) = 0 THEN             RAISE NOTICE '%,%,%,%,%',                 to_char(i, '9999999999'),                 pg_relation_size('shorturl_key_hash_index_025'),                 pg_relation_size('shorturl_key_hash_index_050'),                 pg_relation_size('shorturl_key_hash_index_075'),                 pg_relation_size('shorturl_key_hash_index_100');         END IF;     END LOOP; END; $$;<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<figure class=\"full-width\">\n<div><figcaption>\u0420\u0430\u0437\u043c\u0435\u0440\u044b \u0445\u044d\u0448-\u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 fillfactor<\/figcaption><\/div>\n<\/figure>\n<p>\u0427\u0430\u0440\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u0435\u043d\u044c\u0448\u0438\u0439 <code>fillfactor<\/code> \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0431\u0430\u043a\u0435\u0442\u044b \u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0431\u043e\u043b\u044c\u0448\u0435\u043c\u0443 \u043e\u0431\u0449\u0435\u043c\u0443 \u0440\u0430\u0437\u043c\u0435\u0440\u0443. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 b-tree,<\/p>\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-350285","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350285","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=350285"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/350285\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}