{"id":452398,"date":"2025-03-19T21:00:37","date_gmt":"2025-03-19T21:00:37","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=452398"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=452398","title":{"rendered":"<span>\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \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>\u0412 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 pg_locks \u0435\u0441\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0435\u0446 fastpath, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0443\u0442\u0438. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u043f\u0438\u0441\u0430\u043d \u043a\u043e\u0440\u043e\u0442\u043a\u043e. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0447\u0435\u043c \u043e\u043d \u043b\u0443\u0447\u0448\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438.<\/p>\n<p>\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0442\u0441\u044f, \u043d\u043e \u0440\u0435\u0434\u043a\u043e \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442. \u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b SELECT, INSERT, UPDATE, DELETE, MERGE.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043b\u0430\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442 \u0432\u0441\u0435 relations (\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0441\u0435\u043a\u0446\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446) \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043b\u0430\u043d\u0430 \u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430 \u0442\u0435\u0445 relations, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c \u043f\u043b\u0430\u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439, \u043e\u0431\u044b\u0447\u043d\u043e, \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0442\u0430\u043a\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u043e\u043d\u0438 \u043d\u0435 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p>\u041f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u043e\u0431\u0449\u0430\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a. \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0435\u0439  \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0443\u0437\u043a\u0438\u043c \u043c\u0435\u0441\u0442\u043e\u043c, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u044b (partitions), \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0449\u0438\u0449\u0451\u043d \u043e\u0434\u043d\u043e\u0439 \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439. \u041a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u044f \u0437\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0435\u0439 \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0442\u0430\u043a\u043e\u0435 \u0443\u0437\u043a\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u043e, \u0432 PostgreSQL \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 PGPROC \u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443. \u0412 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 PGPROC \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f 16 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a.<\/p>\n<p>\u0414\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 (shared LWLock) \u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a, \u0430 \u044d\u0442\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443. \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0449\u0438\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0430 relation \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b PGPROC? <\/p>\n<p>\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 relation \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0430\u0437\u0434\u0435\u043b \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a. \u0425\u044d\u0448 \u0434\u043b\u044f relations \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 dboid \u0438 reloid. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u0437 1024 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 (\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c FAST_PATH_STRONG_LOCK_HASH_PARTITIONS), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430. \u041d\u0430\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 &#171;Fast Path Strong Relation Lock Data&#187;:<\/p>\n<pre><code class=\"sql\">select * from (select *, lead(off) over(order by off) - off as true_size from pg_shmem_allocations) as a where name like 'Fast%';                 name                 |    off    | size | allocated_size | true_size  -------------------------------------+-----------+------+----------------+-----------  Fast Path Strong Relation Lock Data | 144058368 | 4100 |           4224 |      4224 (1 row)<\/code><\/pre>\n<p>\u00a0\u041a\u0430\u0436\u0434\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e \u00a0&#171;\u0441\u0438\u043b\u044c\u043d\u044b\u0445&#187; \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a (Share, ShareRowExclusive, Exclusive, AccessExclusive), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432\u0430\u0442\u044c \u0441 \u0442\u0435\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0432 1\/1024 \u0447\u0430\u0441\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u043a\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043a\u0430\u043a\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u043f\u0430\u043b, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0431\u044b\u0441\u0442\u0440\u043e &#8212; \u043f\u043e \u0445\u044d\u0448\u0443. \u0415\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u043b\u044e, \u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0430\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f relation, \u0445\u044d\u0448 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b.<\/p>\n<p>\u041c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 &#8212; \u043a \u044d\u0442\u043e\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0442\u043e\u0436\u0435 \u043d\u0430\u0434\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0435\u043c \u043e\u043d \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a? \u041e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0434\u043a\u043e, \u0430 \u0441\u043b\u0430\u0431\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u0447\u0430\u0441\u0442\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 relations \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u043f\u0440\u0430\u0432\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 NUM_LOCK_PARTITIONS=16 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0443\u043b\u044f, \u0442\u043e \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0415\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u0443\u044e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043d\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u043d\u0430 relation, \u0445\u044d\u0448 \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u0432 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0430\u0437\u0434\u0435\u043b (1\/1024) \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a. \u041e\u0446\u0435\u043d\u043a\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f: \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 10, \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 1% \u0441\u043b\u0443\u0447\u0430\u0435\u0432 (1\/1024*10).<\/p>\n<p><strong>\u0421\u043b\u0430\u0431\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438<\/strong><\/p>\n<p>\u0421\u043b\u0430\u0431\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 &#8212; \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0443\u0442\u0438:<br \/>AccessShare &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 SELECT, COPY TO, ALTER TABLE ADD FOREIGN KEY (PARENT) \u0438 \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0438\u0442\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<br \/>RowShare &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 SELECT FOR UPDATE, FOR NO KEY UPDATE, FOR SHARE, FOR KEY SHARE.<br \/>RowExclusive &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442 INSERT, UPDATE, DELETE, MERGE, COPY FROM.<\/p>\n<p>\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043d\u0438 \u043a \u0441\u0438\u043b\u044c\u043d\u043e\u0439 (\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u0435\u0448\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c), \u043d\u0438 \u043a \u0441\u043b\u0430\u0431\u043e\u0439 (\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c): ShareUpdateExclusive. \u0415\u0451 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c, \u0430\u0432\u0442\u043e\u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b VACUUM (\u0431\u0435\u0437 FULL), ANALYZE, CREATE INDEX CONCURRENTLY, DROP INDEX CONCURRENTLY, CREATE STATISTICS, COMMENT ON, REINDEX CONCURRENTLY, ALTER INDEX (RENAME), 11 \u0432\u0438\u0434\u043e\u0432 ALTER TABLE. \u0413\u043b\u0430\u0432\u043d\u043e\u0435, \u0442\u043e, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c \u0438 \u0430\u0432\u0442\u043e\u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0435 \u043c\u0435\u0448\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c \u0438\u043b\u0438 \u0430\u0432\u0442\u043e\u0430\u043d\u0430\u043b\u0438\u0437 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443, \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0443\u044e \u0441 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c (ShareUpdateExclusive), \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0447\u0435\u0440\u0435\u0437 deadlock_timeout \u0438 \u0432 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0436\u0443\u0440\u043d\u0430\u043b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>ERROR:\u00a0 canceling autovacuum task DETAIL: automatic vacuum of table '\u0438\u043c\u044f'<\/code><\/pre>\n<p>\u0410\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0446\u0438\u043a\u043b\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442 \u0441\u043d\u043e\u0432\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0435\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b. \u0422\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c\u0438 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u0415\u0441\u043b\u0438 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u043d\u0438\u044e \u0435\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p><strong>\u0421\u0438\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438<\/strong><\/p>\n<p>\u0421\u0438\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442, \u0442\u043e \u043c\u0435\u0448\u0430\u044e\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u0430\u0431\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0443\u0442\u0438. \u0418\u0445 \u0441\u043f\u0438\u0441\u043e\u043a:<br \/>Share &#8212; CREATE INDEX (\u0431\u0435\u0437 CONCURRENTLY);<br \/>ShareRowExclusive &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 CREATE TRIGGER \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u0438\u0434\u0430\u043c\u0438 ALTER TABLE;<br \/>Exclusive &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 REFRESH MATERIALIZED VIEW CONCURRENTLY;<br \/>AccessExclusive &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 DROP TABLE, TRUNCATE, REINDEX, CLUSTER, VACUUM FULL \u0438 REFRESH MATERIALIZED VIEW (\u0431\u0435\u0437 CONCURRENTLY), ALTER INDEX, 21 \u0432\u0438\u0434 ALTER TABLE.<br \/>\u041a\u043e\u043c\u0430\u043d\u0434\u044b, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0433\u0434\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443.\u00a0<\/p>\n<p><strong>\u0420\u0430\u0437\u0434\u0435\u043b\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a<\/strong><\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 16 \u0447\u0430\u0441\u0442\u0435\u0439 (2^4). \u0421\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0432\u043e\u0439\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">\/* Number of partitions the shared lock tables are divided into *\/ #define LOG2_NUM_LOCK_PARTITIONS  4 #define NUM_LOCK_PARTITIONS  (1 &lt;&lt; LOG2_NUM_LOCK_PARTITIONS)<\/code><\/pre>\n<p>\u0412 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 PGPROC \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u0430\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442:<\/p>\n<pre><code class=\"cpp\">\/* All PROCLOCK objects for locks held or awaited by this backend are linked into one of these lists, according to the partition number of their lock. *\/ dlist_headmyProcLocks[NUM_LOCK_PARTITIONS];<\/code><\/pre>\n<p>\u0412 PostgreSQL LOG2_NUM_LOCK_PARTITIONS &#8212; \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430. \u0412 \u0444\u043e\u0440\u043a\u0430\u0445 PostgreSQL \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 log2_num_lock_partitions. \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c PGPROC \u0438\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e (\u0432\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f &#171;\u0433\u043e\u0440\u044f\u0447\u0435\u0439&#187;). \u0415\u0441\u043b\u0438 &#171;\u0433\u043e\u0440\u044f\u0447\u0438\u0435&#187; \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0443\u0442 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u044d\u0448\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0447\u043d\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c\u0441\u044f. \u0423\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b PGPROC. \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0442\u043e\u043b\u044c\u043a\u043e 16 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e, \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 log2_num_lock_partitions \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0444\u043e\u0440\u043a\u043e\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043c\u0435\u043d\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 LWLocks &#171;\u0443\u0442\u044f\u0436\u0435\u043b\u044f\u044f&#187; \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 lwlock_shared_limit ( <a href=\"https:\/\/pgconf.ru\/media\/2020\/02\/06\/Korotkov_pgconfru_2020_Bottlenecks_2.pdf\" rel=\"noopener noreferrer nofollow\">https:\/\/pgconf.ru\/media\/2020\/02\/06\/Korotkov_pgconfru_2020_Bottlenecks_2.pdf<\/a> ).<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>&gt; We have increased LOG2_NUM_LOCK_PARTITIONS to 8<br \/>&gt; and &#8230; clients start to report &#171;too many LWLocks taken&#187; error.<br \/>&gt; There is yet another hardcoded constant MAX_SIMUL_LWLOCKS = 200<br \/>&gt; which relation with NUM_LOCK_PARTITIONS\u00a0 was not mentioned anywhere.<\/p>\n<p>Seems like self-inflicted damage. I certainly don&#8217;t recall anyplace in the docs where we suggest that you can alter that constant without worrying about consequences.<\/p>\n<p>&gt; So looks like NUM_LOCK_PARTITIONS and MAXNUMMESSAGES\u00a0 <br \/>&gt; constants have to be replaced with GUCs.<\/p>\n<p> I seriously doubt we&#8217;d do that.<br \/> \u00a0\u00a0          regards, tom lane<br \/><a href=\"https:\/\/www.postgresql.org\/message-id\/flat\/da3205c4-5b07-a65c-6c26-a293c6464fdb%40postgrespro.ru\" rel=\"noopener noreferrer nofollow\">https:\/\/www.postgresql.org\/message-id\/flat\/da3205c4-5b07-a65c-6c26-a293c6464fdb%40postgrespro.ru<\/a><\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u0444\u043e\u0440\u043a\u0430\u0445 \u0442\u0430\u043a\u0436\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 fastpath_num_locks \u0432\u043c\u0435\u0441\u0442\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u0430 FP_LOCK_SLOTS_PER_BACKEND. \u0423\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 FP_LOCK_SLOTS_PER_BACKEND \u0441 16 \u0434\u043e 64 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b PGPROC \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 PGPROC \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 880 \u0431\u0430\u0439\u0442, \u0447\u0442\u043e \u0440\u0430\u0432\u043d\u043e 14 cache lines (\u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445), \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 48 xid \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442 \u0435\u0435 \u043d\u0430 192 \u0431\u0430\u0439\u0442\u0430 (3 cache lines). &#171;\u041b\u0438\u043d\u0438\u0438 \u043a\u044d\u0448\u0430&#187; &#8212; \u0431\u043b\u043e\u043a\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 64 \u0431\u0430\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u044d\u0448\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u043f\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u0412 PostgreSQL \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0441 \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u043c\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043e\u0434, \u0447\u0435\u043c \u0441 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>As for turning the parameter into a GUC, that has a cost too. Either direct &#8212; a compiler can do far more optimizations with compile-time constants than with values that may change during execution, for example. Or indirect &#8212; if we can&#8217;t give users any guidance how\/when to tune the GUC, it can easily lead to misconfiguration (I can&#8217;t even count how many times I had to deal with systems where the values were &#171;tuned&#187; following the logic that more is always better).<br \/>which just leads back to (1) and (2) even for this case.<\/p>\n<p>regards<br \/>&#8212; <br \/>Tomas Vondra<br \/>EnterpriseDB<br \/><a href=\"https:\/\/www.postgresql.org\/message-id\/flat\/779f2bd6-00f3-4aac-a792-b81f47e41abd%40enterprisedb.com\" rel=\"noopener noreferrer nofollow\">https:\/\/www.postgresql.org\/message-id\/flat\/779f2bd6-00f3-4aac-a792-b81f47e41abd%40enterprisedb.com<\/a><\/p>\n<\/div>\n<\/details>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438<\/strong><\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 pgbench. \u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0435\u0442 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u0438 \u0438\u0437 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043d\u0435\u0442 \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0432 \u043a\u043b\u044e\u0447 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code>echo \"explain (analyze, costs false) select abalance from pgbench_accounts where bid=1 limit 1;\" &gt; fast.sql<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 7 \u0441\u0435\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"sql\">pgbench -i -s 1 --partitions=7 pgbench -T 100 -P 5 -f fast.sql pgbench (17.4 (Ubuntu 17.4-1.pgdg22.04+2)) starting vacuum...end. progress: 5.0 s, 2610.9 tps, lat 0.376 ms stddev 0.194, 0 failed progress: 10.0 s, 2598.8 tps, lat 0.378 ms stddev 0.212, 0 failed progress: 15.0 s, 2616.6 tps, lat 0.376 ms stddev 0.169, 0 failed progress: 20.0 s, 2582.6 tps, lat 0.381 ms stddev 0.152, 0 failed progress: 25.0 s, 2578.2 tps, lat 0.382 ms stddev 0.171, 0 failed<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 8 \u0441\u0435\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"sql\">pgbench -i -s 1 --partitions=8 pgbench -T 100 -P 5 -f fast.sql pgbench (17.4 (Ubuntu 17.4-1.pgdg22.04+2)) starting vacuum...end. progress: 5.0 s, 2471.2 tps, lat 0.398 ms stddev 0.115, 0 failed progress: 10.0 s, 2497.9 tps, lat 0.394 ms stddev 0.139, 0 failed progress: 15.0 s, 2495.8 tps, lat 0.394 ms stddev 0.182, 0 failed progress: 20.0 s, 2506.8 tps, lat 0.393 ms stddev 0.189, 0 failed progress: 25.0 s, 2489.0 tps, lat 0.395 ms stddev 0.244, 0 failed<\/code><\/pre>\n<p>tps \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u0441\u044f. \u0423\u0432\u0435\u043b\u0438\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u0440\u0435\u043c\u044f \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u0435\u043c \u0436\u0435 (limit 1).<br \/>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0431\u044b\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438:<\/p>\n<pre><code class=\"sql\">postgres=# begin; BEGIN postgres=*# explain (analyze, costs false) select abalance from pgbench_accounts where bid=1 limit 1;                                       QUERY PLAN                                       --------------------------------------------------------------------------------------  Limit (actual time=0.034..0.055 rows=1 loops=1)    -&gt;  Append (actual time=0.025..0.036 rows=1 loops=1)          -&gt;  Seq Scan on pgbench_accounts_1 (actual time=0.018..0.021 rows=1 loops=1)                Filter: (bid = 1)          -&gt;  Seq Scan on pgbench_accounts_2 (never executed)                Filter: (bid = 1)          -&gt;  Seq Scan on pgbench_accounts_3 (never executed)                Filter: (bid = 1)          -&gt;  Seq Scan on pgbench_accounts_4 (never executed)                Filter: (bid = 1)          -&gt;  Seq Scan on pgbench_accounts_5 (never executed)                Filter: (bid = 1)          -&gt;  Seq Scan on pgbench_accounts_6 (never executed)                Filter: (bid = 1)          -&gt;  Seq Scan on pgbench_accounts_7 (never executed)                Filter: (bid = 1)          -&gt;  Seq Scan on pgbench_accounts_8 (never executed)                Filter: (bid = 1)  Planning Time: 1.604 ms  Execution Time: 0.233 ms (20 rows) postgres=*# select pid, relation::regclass::text, mode, granted, fastpath from pg_locks where locktype='relation' and database = (select oid from pg_database where datname=current_database()) order by pid, fastpath desc;   pid  |        relation         |      mode       | granted | fastpath  -------+-------------------------+-----------------+---------+----------  16065 | pgbench_accounts_7_pkey | AccessShareLock | t       | t  16065 | pgbench_accounts_7      | AccessShareLock | t       | t  16065 | pgbench_accounts_6_pkey | AccessShareLock | t       | t  16065 | pgbench_accounts_6      | AccessShareLock | t       | t  16065 | pgbench_accounts_5_pkey | AccessShareLock | t       | t  16065 | pgbench_accounts_5      | AccessShareLock | t       | t  16065 | pgbench_accounts_4_pkey | AccessShareLock | t       | t  16065 | pgbench_accounts_4      | AccessShareLock | t       | t  16065 | pgbench_accounts_3_pkey | AccessShareLock | t       | t  16065 | pgbench_accounts_3      | AccessShareLock | t       | t  16065 | pgbench_accounts_2_pkey | AccessShareLock | t       | t  16065 | pgbench_accounts_2      | AccessShareLock | t       | t  16065 | pgbench_accounts_1_pkey | AccessShareLock | t       | t  16065 | pgbench_accounts_1      | AccessShareLock | t       | t  16065 | pgbench_accounts_pkey   | AccessShareLock | t       | t  16065 | pgbench_accounts        | AccessShareLock | t       | t  16065 | pgbench_accounts_8_pkey | AccessShareLock | t       | f  16065 | pg_locks                | AccessShareLock | t       | f  16065 | pgbench_accounts_8      | AccessShareLock | t       | f (19 rows)<\/code><\/pre>\n<p>16 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a: \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043f\u0435\u0440\u0432\u044b\u0435 7 \u0441\u0435\u043a\u0446\u0438\u0439 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043d\u0430 \u043d\u0438\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0443\u0442\u0438.<br \/>\u041d\u0430 8 \u0441\u0435\u043a\u0446\u0438\u044e \u0438 \u0438\u043d\u0434\u0435\u043a\u0441 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u043f\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438.<\/p>\n<p>\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0442\u0438\u043f\u0430 AccessShareLock \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f &#8212; \u043d\u0430 \u0432\u0441\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0441\u0435\u043a\u0446\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u043e\u043c. \u041f\u0435\u0440\u0432\u044b\u0435 16 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440, \u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0434\u043e\u043b\u044c\u0448\u0435, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f. \u0417\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0443\u0440\u043e\u0432\u043d\u044f \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0437\u0430 \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0442\u0438\u043f\u0430 LockManager (\u0447\u0438\u0441\u043b\u0430 \u0441\u0435\u0441\u0441\u0438\u0439 \u043e\u0431\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0437\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438). <\/p>\n<p>\u0423\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043d\u0430 \u0442\u0435\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445, \u0433\u0434\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u043e. \u041d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0435 \u043a\u044d\u0448\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0437\u0430\u043d\u043e\u0432\u043e.<\/p>\n<p>\u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f relations. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 SELECT \u00a0\u0432\u0441\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0443\u0442\u0438, \u0442\u043e \u044d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u044f, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c. \u0415\u0441\u043b\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f relations, \u0442\u043e \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0437\u0430\u043c\u0435\u0434\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0437\u0430\u043c\u0435\u0442\u043d\u044b\u043c \u0438\u0437-\u0437\u0430 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u0438 \u0437\u0430 \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0442\u0438\u043f\u0430 LockManager (\u0434\u043e 13 \u0432\u0435\u0440\u0441\u0438\u0438 PostgreSQL \u044d\u0442\u043e\u0442 \u0442\u0438\u043f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u043b\u0441\u044f lock_manager). \u0410\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c \u0438 \u0430\u0432\u0442\u043e\u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0435 \u043c\u0435\u0448\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/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\/892460\/\"> https:\/\/habr.com\/ru\/articles\/892460\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 pg_locks \u0435\u0441\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0435\u0446 fastpath, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0443\u0442\u0438. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u043f\u0438\u0441\u0430\u043d \u043a\u043e\u0440\u043e\u0442\u043a\u043e. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0447\u0435\u043c \u043e\u043d \u043b\u0443\u0447\u0448\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438.<\/p>\n<p>\u0411\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0445 \u0440\u0430\u0441\u0445\u043e\u0434\u043e\u0432 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0442\u0441\u044f, \u043d\u043e \u0440\u0435\u0434\u043a\u043e \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442. \u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b SELECT, INSERT, UPDATE, DELETE, MERGE.<\/p>\n<p>\u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u043b\u0430\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0442 \u0432\u0441\u0435 relations (\u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0441\u0435\u043a\u0446\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446) \u043d\u0430 \u0432\u0440\u0435\u043c\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043b\u0430\u043d\u0430 \u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430 \u0442\u0435\u0445 relations, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c \u043f\u043b\u0430\u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0421 \u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439, \u043e\u0431\u044b\u0447\u043d\u043e, \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u0442\u0430\u043a\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u043e\u043d\u0438 \u043d\u0435 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0442 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p>\u041f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u043e\u0431\u0449\u0430\u044f \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a. \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0435\u0439  \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u0442\u044c \u0443\u0437\u043a\u0438\u043c \u043c\u0435\u0441\u0442\u043e\u043c, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u044b (partitions), \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0449\u0438\u0449\u0451\u043d \u043e\u0434\u043d\u043e\u0439 \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439. \u041a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0438\u044f \u0437\u0430 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043d\u0435\u0439 \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430\u043c\u0438.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0442\u0430\u043a\u043e\u0435 \u0443\u0437\u043a\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043d\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u043b\u043e, \u0432 PostgreSQL \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 PGPROC \u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443. \u0412 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 PGPROC \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f 16 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a.<\/p>\n<p>\u0414\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u0443\u044e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 (shared LWLock) \u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a, \u0430 \u044d\u0442\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443. \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u0443\u044e\u0449\u0438\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0430 relation \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b PGPROC? <\/p>\n<p>\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 relation \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0430\u0437\u0434\u0435\u043b \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a. \u0425\u044d\u0448 \u0434\u043b\u044f relations \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 dboid \u0438 reloid. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u0437 1024 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 (\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c FAST_PATH_STRONG_LOCK_HASH_PARTITIONS), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430. \u041d\u0430\u0437\u044b\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 &#171;Fast Path Strong Relation Lock Data&#187;:<\/p>\n<pre><code class=\"sql\">select * from (select *, lead(off) over(order by off) - off as true_size from pg_shmem_allocations) as a where name like 'Fast%';                 name                 |    off    | size | allocated_size | true_size  -------------------------------------+-----------+------+----------------+-----------  Fast Path Strong Relation Lock Data | 144058368 | 4100 |           4224 |      4224 (1 row)<\/code><\/pre>\n<p>\u00a0\u041a\u0430\u0436\u0434\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e \u00a0&#171;\u0441\u0438\u043b\u044c\u043d\u044b\u0445&#187; \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a (Share, ShareRowExclusive, Exclusive, AccessExclusive), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u044b \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432\u0430\u0442\u044c \u0441 \u0442\u0435\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0432 1\/1024 \u0447\u0430\u0441\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a. \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u043a\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043a\u0430\u043a\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u043f\u0430\u043b, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0431\u044b\u0441\u0442\u0440\u043e &#8212; \u043f\u043e \u0445\u044d\u0448\u0443. \u0415\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u043b\u044e, \u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u0430\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f relation, \u0445\u044d\u0448 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b.<\/p>\n<p>\u041c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441 &#8212; \u043a \u044d\u0442\u043e\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0442\u043e\u0436\u0435 \u043d\u0430\u0434\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0435\u043c \u043e\u043d \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a? \u041e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u043b\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0434\u043a\u043e, \u0430 \u0441\u043b\u0430\u0431\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u0447\u0430\u0441\u0442\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 relations \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0431\u0443\u0434\u0435\u0442 \u0432\u043f\u0440\u0430\u0432\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 NUM_LOCK_PARTITIONS=16 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0430 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0443\u043b\u044f, \u0442\u043e \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0415\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u0443\u044e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043d\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0431\u0443\u0434\u0435\u0442, \u0435\u0441\u043b\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443 \u043d\u0430 relation, \u0445\u044d\u0448 \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u0432 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0430\u0437\u0434\u0435\u043b (1\/1024) \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a. \u041e\u0446\u0435\u043d\u043a\u0430 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u044f: \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043d\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0435 10, \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 1% \u0441\u043b\u0443\u0447\u0430\u0435\u0432 (1\/1024*10).<\/p>\n<p><strong>\u0421\u043b\u0430\u0431\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438<\/strong><\/p>\n<p>\u0421\u043b\u0430\u0431\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 &#8212; \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0443\u0442\u0438:<br \/>AccessShare &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 SELECT, COPY TO, ALTER TABLE ADD FOREIGN KEY (PARENT) \u0438 \u043b\u044e\u0431\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0447\u0438\u0442\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<br \/>RowShare &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 SELECT FOR UPDATE, FOR NO KEY UPDATE, FOR SHARE, FOR KEY SHARE.<br \/>RowExclusive &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442 INSERT, UPDATE, DELETE, MERGE, COPY FROM.<\/p>\n<p>\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043d\u0438 \u043a \u0441\u0438\u043b\u044c\u043d\u043e\u0439 (\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u0435\u0448\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c), \u043d\u0438 \u043a \u0441\u043b\u0430\u0431\u043e\u0439 (\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c): ShareUpdateExclusive. \u0415\u0451 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c, \u0430\u0432\u0442\u043e\u0430\u043d\u0430\u043b\u0438\u0437 \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b VACUUM (\u0431\u0435\u0437 FULL), ANALYZE, CREATE INDEX CONCURRENTLY, DROP INDEX CONCURRENTLY, CREATE STATISTICS, COMMENT ON, REINDEX CONCURRENTLY, ALTER INDEX (RENAME), 11 \u0432\u0438\u0434\u043e\u0432 ALTER TABLE. \u0413\u043b\u0430\u0432\u043d\u043e\u0435, \u0442\u043e, \u0447\u0442\u043e \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c \u0438 \u0430\u0432\u0442\u043e\u0430\u043d\u0430\u043b\u0438\u0437 \u043d\u0435 \u043c\u0435\u0448\u0430\u044e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c \u0438\u043b\u0438 \u0430\u0432\u0442\u043e\u0430\u043d\u0430\u043b\u0438\u0437 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0443, \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u0443\u044e \u0441 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c (ShareUpdateExclusive), \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c\u0430 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0447\u0435\u0440\u0435\u0437 deadlock_timeout \u0438 \u0432 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0436\u0443\u0440\u043d\u0430\u043b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>ERROR:\u00a0 canceling autovacuum task DETAIL: automatic vacuum of table '\u0438\u043c\u044f'<\/code><\/pre>\n<p>\u0410\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0446\u0438\u043a\u043b\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442 \u0441\u043d\u043e\u0432\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u0435\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b. \u0422\u0430\u043a\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u044b\u043c\u0438 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u0415\u0441\u043b\u0438 \u0430\u0432\u0442\u043e\u0432\u0430\u043a\u0443\u0443\u043c \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0442\u043e \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u0440\u0430\u0437\u0434\u0443\u0432\u0430\u043d\u0438\u044e \u0435\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p><strong>\u0421\u0438\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438<\/strong><\/p>\n<p>\u0421\u0438\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442, \u0442\u043e \u043c\u0435\u0448\u0430\u044e\u0442 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u0430\u0431\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u043f\u0443\u0442\u0438. \u0418\u0445 \u0441\u043f\u0438\u0441\u043e\u043a:<br \/>Share &#8212; CREATE INDEX (\u0431\u0435\u0437 CONCURRENTLY);<br \/>ShareRowExclusive &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 CREATE TRIGGER \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u0438\u0434\u0430\u043c\u0438 ALTER TABLE;<br \/>Exclusive &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 REFRESH MATERIALIZED VIEW CONCURRENTLY;<br \/>AccessExclusive &#8212; \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 DROP TABLE, TRUNCATE, REINDEX, CLUSTER, VACUUM FULL \u0438 REFRESH MATERIALIZED VIEW (\u0431\u0435\u0437 CONCURRENTLY), ALTER INDEX, 21 \u0432\u0438\u0434 ALTER TABLE.<br \/>\u041a\u043e\u043c\u0430\u043d\u0434\u044b, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0433\u0434\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0438\u0441\u043f\u044b\u0442\u044b\u0432\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443.\u00a0<\/p>\n<p><strong>\u0420\u0430\u0437\u0434\u0435\u043b\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a<\/strong><\/p>\n<p>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0430 \u043d\u0430 16 \u0447\u0430\u0441\u0442\u0435\u0439 (2^4). \u0421\u0442\u0435\u043f\u0435\u043d\u044c \u0434\u0432\u043e\u0439\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">\/* Number of partitions the shared lock tables are divided into *\/ #define LOG2_NUM_LOCK_PARTITIONS  4 #define NUM_LOCK_PARTITIONS  (1 &lt;&lt; LOG2_NUM_LOCK_PARTITIONS)<\/code><\/pre>\n<p>\u0412 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 PGPROC \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0447\u0430\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043d \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442:<\/p>\n<pre><code class=\"cpp\">\/* All PROCLOCK objects for locks held or awaited by this backend are linked into one of these lists, according to the partition number of their lock. *\/ dlist_headmyProcLocks[NUM_LOCK_PARTITIONS];<\/code><\/pre>\n<p>\u0412 PostgreSQL LOG2_NUM_LOCK_PARTITIONS &#8212; \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430. \u0412 \u0444\u043e\u0440\u043a\u0430\u0445 PostgreSQL \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 log2_num_lock_partitions. \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c PGPROC \u0438\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e (\u0432\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f &#171;\u0433\u043e\u0440\u044f\u0447\u0435\u0439&#187;). \u0415\u0441\u043b\u0438 &#171;\u0433\u043e\u0440\u044f\u0447\u0438\u0435&#187; \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0443\u0442 \u043f\u043e\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u043a\u044d\u0448\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432, \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0447\u043d\u0435\u0442 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c\u0441\u044f. \u0423\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b PGPROC. \u041d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043f\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u0442\u043e\u043b\u044c\u043a\u043e 16 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e, \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 log2_num_lock_partitions \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0444\u043e\u0440\u043a\u043e\u0432 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043c\u0435\u043d\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 LWLocks &#171;\u0443\u0442\u044f\u0436\u0435\u043b\u044f\u044f&#187; \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 lwlock_shared_limit ( <a href=\"https:\/\/pgconf.ru\/media\/2020\/02\/06\/Korotkov_pgconfru_2020_Bottlenecks_2.pdf\" rel=\"noopener noreferrer nofollow\">https:\/\/pgconf.ru\/media\/2020\/02\/06\/Korotkov_pgconfru_2020_Bottlenecks_2.pdf<\/a> ).<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>&gt; We have increased LOG2_NUM_LOCK_PARTITIONS to 8<br \/>&gt; and &#8230; clients start to report &#171;too many LWLocks taken&#187; error.<br \/>&gt; There is yet another hardcoded constant MAX_SIMUL_LWLOCKS = 200<br \/>&gt; which relation with NUM_LOCK_PARTITIONS\u00a0 was not mentioned anywhere.<\/p>\n<p>Seems like self-inflicted damage. I certainly don&#8217;t recall anyplace in the docs where we suggest that you can alter that constant without worrying about consequences.<\/p>\n<p>&gt; So looks like NUM_LOCK_PARTITIONS and MAXNUMMESSAGES\u00a0 <br \/>&gt; constants have to be replaced with GUCs.<\/p>\n<p> I seriously doubt we&#8217;d do that.<br \/> \u00a0\u00a0          regards, tom lane<br \/><a href=\"https:\/\/www.postgresql.org\/message-id\/flat\/da3205c4-5b07-a65c-6c26-a293c6464fdb%40postgrespro.ru\" rel=\"noopener noreferrer nofollow\">https:\/\/www.postgresql.org\/message-id\/flat\/da3205c4-5b07-a65c-6c26-a293c6464fdb%40postgrespro.ru<\/a><\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u0444\u043e\u0440\u043a\u0430\u0445 \u0442\u0430\u043a\u0436\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 fastpath_num_locks \u0432\u043c\u0435\u0441\u0442\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u0430 FP_LOCK_SLOTS_PER_BACKEND. \u0423\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 FP_LOCK_SLOTS_PER_BACKEND \u0441 16 \u0434\u043e 64 \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b PGPROC \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 PGPROC \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 880 \u0431\u0430\u0439\u0442, \u0447\u0442\u043e \u0440\u0430\u0432\u043d\u043e 14 cache lines (\u0431\u043b\u043e\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445), \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 48 xid \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442 \u0435\u0435 \u043d\u0430 192 \u0431\u0430\u0439\u0442\u0430 (3 cache lines). &#171;\u041b\u0438\u043d\u0438\u0438 \u043a\u044d\u0448\u0430&#187; &#8212; \u0431\u043b\u043e\u043a\u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 64 \u0431\u0430\u0439\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u044d\u0448\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043a\u043e\u043f\u0438\u044e \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>\u0412 PostgreSQL \u043c\u0430\u043a\u0440\u043e\u0441\u044b \u043d\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u044e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0441 \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u043c\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0438 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043e\u0434, \u0447\u0435\u043c \u0441 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u043a\u0441\u0442<\/summary>\n<div class=\"spoiler__content\">\n<p>As for turning the parameter into a GUC, that has a cost too. Either direct &#8212; a compiler can do far more optimizations with compile-time constants than with values that may change during execution, for example. Or indirect &#8212; if we can&#8217;t give users any guidance how\/when to tune the GUC, it can easily lead to misconfiguration (I can&#8217;t even count how many times I had to deal with systems where the values were &#171;tuned&#187; following the logic that more is always better).<br \/>which just leads back to (1) and (2) even for this case.<\/p>\n<p>regards<br \/>&#8212; <br \/>Tomas Vondra<br \/>EnterpriseDB<br \/><a href=\"https:\/\/www.postgresql.org\/message-id\/flat\/779f2bd6-00f3-4aac-a792-b81f47e41abd%40enterprisedb.com\" rel=\"noopener noreferrer nofollow\">https:\/\/www.postgresql.org\/message-id\/flat\/779f2bd6-00f3-4aac-a792-b81f47e41abd%40enterprisedb.com<\/a><\/p>\n<\/div>\n<\/details>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043e\u043a \u043f\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u043c\u0443 \u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438<\/strong><\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 pgbench. \u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0435\u0442 \u043f\u0440\u0435\u0434\u0438\u043a\u0430\u0442\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u0438 \u0438\u0437 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043d\u0435\u0442 \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0432 \u043a\u043b\u044e\u0447 \u0441\u0435\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<pre><code>echo \"explain (analyze, costs false) select abalance from pgbench_accounts where bid=1 limit 1;\" &gt; fast.sql<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 7 \u0441\u0435\u043a\u0446\u0438\u044f\u043c\u0438 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0442\u0435\u0441\u0442:<\/p>\n<pre><code class=\"sql\">pgbench -i -s 1 --partitions=7 pgbench -T 100 -P 5 -f fast.sql pgbench (17.4 (Ubuntu 17.4-1.pgdg22.04+2)) starting vacuum...end. progress: 5.0 s, 2610.9 tps, lat 0.376 ms stddev 0.194, 0<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-452398","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/452398","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=452398"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/452398\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=452398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=452398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=452398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}