{"id":342198,"date":"2022-12-06T09:00:31","date_gmt":"2022-12-06T09:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=342198"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2022-12-06T09:00:31","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=342198","title":{"rendered":"<span>\u041e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 ClickHouse \u0431\u0435\u0437 UPDATE: \u043a\u0435\u0439\u0441 IBS<\/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<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c22\/2e3\/bbd\/c222e3bbdac4f3ccd1325de9b9a4a6dc.jpg\" width=\"1625\" height=\"917\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c22\/2e3\/bbd\/c222e3bbdac4f3ccd1325de9b9a4a6dc.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043d\u0442\u043e\u043d, \u044f \u2013 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043e\u0442\u0434\u0435\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 IBS. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0431\u044b\u043b\u0430 \u0440\u0435\u0448\u0435\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u0432 <em>ClickHouse<\/em> \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c, \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435, \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u0432\u0440\u044f\u0434 \u043b\u0438 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435. \u041d\u043e \u043d\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u0441\u043e\u0431\u043e\u0439 \u0440\u044f\u0434 \u043d\u044e\u0430\u043d\u0441\u043e\u0432: \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0443\u0431\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u0434\u0443\u0431\u043b\u0438 (\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f), \u0435\u0441\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0410 \u044d\u0442\u043e \u0443\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f ClickHouse, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0438 \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f.<\/p>\n<h3>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h3>\n<p>\u041d\u0430\u0434 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043d\u0430\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u2013 \u044f \u0438 \u0434\u0432\u0430 \u0431\u044d\u043a\u0435\u043d\u0434\u0435\u0440\u0430 \u2013 \u043d\u0430\u0447\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u0440\u0443\u043f\u043d\u043e\u0433\u043e \u0433\u043e\u0441\u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u0441\u043e\u0431\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u043a\u0443\u0447\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c\u0438. \u041d\u0438\u0436\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0435\u0449\u0451 \u0434\u043e \u043d\u0430\u0448\u0435\u0433\u043e \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0443\u044e \u0437\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432. <\/p>\n<p>\u041f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u043c\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0443 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u044f\u0434 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 (\u043c\u0435\u0442\u0440\u0438\u043a), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430. \u0420\u0430\u043d\u0435\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043d\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u044d\u0442\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439, \u0447\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0438 \u0443\u0436\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u0440\u0438\u043a. \u0410\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u0445 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0444\u043e\u0440\u043c \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e, \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<h3>\u0418\u0442\u0430\u043a, \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0440\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0435<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/cc2\/82e\/231\/cc282e231ca41839832b526f03c35842.jpg\" width=\"1180\" height=\"538\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cc2\/82e\/231\/cc282e231ca41839832b526f03c35842.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<ol>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0434\u0443\u0431\u043b\u0435\u0439 \u043c\u0435\u0442\u0440\u0438\u043a.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u0432 \u0441\u0443\u0442\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u0445 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e (\u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434).<\/p>\n<\/li>\n<\/ol>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <em>Elasticsearch<\/em>. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0435\u0442\u0440\u0438\u043a \u0440\u043e\u0441\u043b\u043e, \u0438 \u0434\u0432\u0438\u0436\u043e\u043a \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u044c \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432\u044b\u0434\u0430\u0447\u0438 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e \u043d\u0435\u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0442.\u043a. \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 ES \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u0431\u044b\u043b \u0437\u0430\u043d\u043e\u0432\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043e\u0431\u044a\u0451\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u0443\u0447\u0435\u0441\u0442\u044c \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u041c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 <em>ClickHouse<\/em>. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u043c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0451\u043c\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043e\u043d \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u0418 \u0432\u0441\u0451 \u0431\u044b \u0445\u043e\u0440\u043e\u0448\u043e, \u0435\u0441\u043b\u0438 \u0431\u044b \u043d\u0435 \u043f.3 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0448\u0438\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u2013 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0412\u0435\u0434\u044c \u043a\u0430\u043a <a href=\"https:\/\/clickhouse.com\/docs\/ru\/sql-reference\/statements\/alter\/#mutations\">\u0441\u043a\u0430\u0437\u0430\u043d\u043e<\/a> \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f <em>UPDATE<\/em> \u0432 <em>ClickHouse<\/em> \u043d\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0430 \u0442\u044f\u0436\u0451\u043b\u0430\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043d\u0430\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b ClickHouse \u0438 \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0445\u043e\u0434\u0438\u043b\u043e \u044d\u0442\u0443 \u0435\u0433\u043e \u00ab\u0441\u043b\u0430\u0431\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443\u00bb. <\/p>\n<p>\u0422\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438. \u0422\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u00ab<em>\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c\u00bb<\/em>. \u00ab<em>\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u00bb, <\/em>\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 <em>UPDATE<\/em>-\u043e\u0432 \u0438\u0437-\u0437\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 <em>ClickHouse<\/em> \u043c\u044b \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u0445. \u0410 \u00ab<em>\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u00bb,<\/em> \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b \u043d\u0435 \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443 \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0432\u043d\u043e\u0432\u044c \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c. \u0410\u0433\u0440\u0435\u0433\u0430\u0442\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u043e\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <em>UPDATE<\/em>. \u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0442\u043e, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e.<\/p>\n<h3>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h3>\n<h4>\u0421\u0445\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h4>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0438\u0441\u044c 4 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 4 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (\u041c\u041f). \u041c\u041f \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u00ab\u0433\u0440\u044f\u0437\u043d\u044b\u0435\u00bb (\u0432 \u043f\u043b\u0430\u043d\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0434\u0443\u0431\u043b\u0435\u0439) \u043d\u0435\u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u0432\u044b\u0445\u043e\u0434\u044f\u0442 \u2013 \u043e\u0447\u0438\u0449\u0435\u043d\u043d\u044b\u0435 \u043e\u0442 \u0434\u0443\u0431\u043b\u0435\u0439, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435. \u0421\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u0430 \u0420\u0438\u0441. 1<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6cb\/674\/c94\/6cb674c94fc8b94eead339cba9f196da.png\" alt=\"\u0420\u0438\u0441.1. \u0421\u0445\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041d\u0430\u0431\u043e\u0440 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u041c\u041f \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.\" title=\"\u0420\u0438\u0441.1. \u0421\u0445\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041d\u0430\u0431\u043e\u0440 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u041c\u041f \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.\" width=\"271\" height=\"416\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6cb\/674\/c94\/6cb674c94fc8b94eead339cba9f196da.png\"\/><figcaption>\u0420\u0438\u0441.1. \u0421\u0445\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041d\u0430\u0431\u043e\u0440 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u041c\u041f \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/figcaption><\/figure>\n<h4>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 ClickHouse<\/h4>\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u041c\u041f \u0432 <em>ClickHouse<\/em>. \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c 2 \u0432\u0438\u0434\u0430 \u041c\u041f: \u043f\u0435\u0440\u0432\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442 \u0434\u0430\u043d\u043d\u044b\u0435; \u0432\u0442\u043e\u0440\u044b\u0435, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <strong><em>TO [db]. [destination_table],<\/em><\/strong> \u043d\u0435 \u0445\u0440\u0430\u043d\u044f\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f, \u043f\u043e \u0441\u0443\u0442\u0438, <em>after-insert<\/em> \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c (\u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0430 \u0435\u0433\u043e \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430).<\/p>\n<pre><code>CREATE MATERIALIZED VIEW [db.]view [ON CLUSTER] TO [db.] [destination_table] AS SELECT ... FROM [db.] [source_table]<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>source_table<\/strong> \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u041c\u041f, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <strong>SELECT<\/strong> \u043d\u0430\u0434 \u044d\u0442\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>destination_table<\/strong><em>.<\/em> \u0411\u0443\u0434\u0435\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>source_table<em> <\/em><\/strong>\u00ab\u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c\u00bb, \u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>destination_table<\/strong> \u2013 \u00ab\u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439-\u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a\u043e\u043c\u00bb. \u0412\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u041c\u041f \u0432\u0438\u0434\u0438\u0442 \u043d\u0435 \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0438\u0435. \u0412\u0441\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u044e\u0442 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 <strong>SELECT<\/strong>, \u043d\u043e \u043d\u0435 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <strong>FROM, <\/strong>\u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u041c\u041f \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043d\u0438\u0445 \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0432 \u0441\u0435\u043a\u0446\u0438\u044f\u0445 <strong>JOIN<\/strong> \u041c\u041f \u0432\u0438\u0434\u0438\u0442 \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0430\u043a \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c, \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<h4>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h4>\n<p>\u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0445\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code>{   RecId  String,     --\u041e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c   Time   DateTime64, --\u0412\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438   Sign   int8        --\u041f\u0440\u0438\u0437\u043d\u0430\u043a \u0437\u0430\u043f\u0438\u0441\u0438 }<\/code><\/pre>\n<p>\u0412 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0435\u0439 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435. \u0422\u043e, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u043e\u0434\u043d\u0438\u043c \u043f\u043e\u043b\u0435\u043c <strong>RecId,<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0438\u0437 8-\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439, \u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u044d\u0442\u043e \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong>RecId<\/strong> \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b.<\/p>\n<h4>\u041d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/h4>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>from_kafka_metrics<\/strong> \u0438\u0437 <em>Kafka<\/em>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0438\u043c\u0435\u044e\u0449\u0443\u044e\u0441\u044f \u0432 <em>ClickHouse<\/em> \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 <em>Kafka<\/em>, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u0434\u0432\u0438\u0436\u043a\u043e\u043c <em>ENGINE=Kafka<\/em>. \u0414\u0430\u043b\u0435\u0435 \u041c\u041f, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u043d\u0430\u0434 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439, \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>metrics_dirty<\/strong> (\u0440\u0438\u0441. 2).<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/66e\/019\/6c8\/66e0196c8cbad17a7561228c277efe77.png\" alt=\"\u0420\u0438\u0441. 2. \u0421\u0445\u0435\u043c\u0430 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 Kafka \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 metrics_dirty.\" title=\"\u0420\u0438\u0441. 2. \u0421\u0445\u0435\u043c\u0430 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 Kafka \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 metrics_dirty.\" width=\"384\" height=\"269\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/66e\/019\/6c8\/66e0196c8cbad17a7561228c277efe77.png\"\/><figcaption>\u0420\u0438\u0441. 2. \u0421\u0445\u0435\u043c\u0430 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 Kafka \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 metrics_dirty.<\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u044b\u043b \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u043a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441 \u0434\u0432\u0438\u0436\u043a\u043e\u043c <em>Kafka<\/em> \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u0447\u0435\u0437\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <strong>SELECT<\/strong>, \u0447\u0442\u043e \u043d\u0430\u0441 \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u043e. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <strong>metrics_dirty<\/strong> \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u0445. \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b <strong>from_kafka_metrics<\/strong> \u0438 \u041c\u041f <strong>from_kafka_metrics_mv,<\/strong> \u0442.\u043a. \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u043d\u0438 \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430; \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0441\u0440\u0430\u0437\u0443 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <strong>metrics_dirty<\/strong>.<\/p>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b <strong>metrics_dirty<\/strong> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>create table if not exists metrics_dirty on cluster some_cluster (   RecId   String,   Time    DateTime64(6) default toDateTime64(now64(), 6),   Sign    Int8 default 1    ) ENGINE = ReplicatedMergeTree() ORDER BY tuple();<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c <strong>RecId<\/strong> \u2013 \u044d\u0442\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438. <strong>Time<\/strong> \u2013 \u0432\u0440\u0435\u043c\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0438. \u041f\u043e\u043b\u0435 <strong>Sign<\/strong> (\u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0437\u0430\u043f\u0438\u0441\u0438) \u2013 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u0435, \u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435. \u0415\u0449\u0451 \u0440\u0430\u0437 \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0434\u0443\u0431\u043b\u0438 \u043c\u0435\u0442\u0440\u0438\u043a, \u0442.\u0435. \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e\u043b\u0435\u0439 <strong>RecId<\/strong> \u0438 <strong>Sign<\/strong>. <strong>Time<\/strong> \u0443 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c, \u0442\u0430\u043a \u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u043c\u0441\u044f; \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u043d\u0430\u0441 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0443\u0431\u043b\u044f\u043c\u0438.<\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u044d\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u043a\u0430\u043a \u0438 \u0432\u0441\u0435 \u0434\u0440\u0443\u0433\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0438\u0436\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0434 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446 \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (ENGINE = Distributed), \u0438 \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0438\u0445 \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043b\u043e\u0434\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043c\u043d\u0435 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f. \u041d\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u043a\u043e\u0434\u0435 \u0432\u0441\u0435\u0445 \u041c\u041f \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0441\u043a\u0430\u0436\u0443 \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435. \u0410 \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0441\u0443\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<h4>\u0423\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0443\u0431\u043b\u0435\u0439<\/h4>\n<p>\u0414\u043b\u044f \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0443\u0431\u043b\u0435\u0439 \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <strong>metrics_uniq<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u043b\u0438 \u0438\u0437 <strong>metrics_dirty<\/strong>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u041c\u041f <strong>metrics_uniq_mv<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <strong>metrics_dirty<\/strong>, \u0430 \u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a\u043e\u043c \u2013 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <strong>metrics_uniq<\/strong>. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u041c\u041f \u0432\u0438\u0434\u0438\u0442 \u043b\u0438\u0448\u044c \u0442\u043e\u0442 \u043a\u0443\u0441\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0432\u0451\u043b \u043a \u0435\u0433\u043e \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044e, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u0443\u0431\u043b\u0435\u0439 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435-\u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a\u0443, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>JOIN<\/strong>, \u0442.\u043a. \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0438\u0437 \u0441\u0435\u043a\u0446\u0438\u0438 <strong>JOIN<\/strong> \u041c\u041f \u0432\u0438\u0434\u0438\u0442 \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0415\u0441\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 <strong>RecId<\/strong>) \u0435\u0449\u0451 \u043d\u0435\u0442 \u0432 <strong>metrics_uniq,<\/strong> \u0437\u0430\u043f\u0440\u043e\u0441 <strong>SELECT<\/strong> \u0438\u0445 \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u0438\u0437 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0435\u0433\u043e \u043a\u0443\u0441\u043a\u0430 \u0438 \u043d\u0435 \u0432\u044b\u0431\u0435\u0440\u0435\u0442, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u0442\u0430\u043a\u0438\u043c <strong>RecId<\/strong> \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <strong>metrics_uniq<\/strong> \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e \u043d\u0430\u0431\u043e\u0440\u0443 \u043f\u043e\u043b\u0435\u0439 [<strong>RecId<\/strong>, <strong>Sign<\/strong>] \u0434\u0430\u043d\u043d\u044b\u0435. \u0422.\u0435., \u043a\u0430\u043a \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c <strong>RecId<\/strong>, \u043d\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c <strong>Sign<\/strong> (1 \u0438 -1).<\/p>\n<pre><code>create table if not exists metrics_uniq on cluster some_cluster (     RecId   String,     Time    DateTime64(6),     Sign    Int8 default 1 ) ENGINE = ReplicatedMergeTree() ORDER BY (Sign, RecId);<\/code><\/pre>\n<p>\u041c\u041f \u0434\u043b\u044f \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <strong>metrics_uniq<\/strong> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>create materialized view metrics_uniq_mv on cluster some_cluster to metrics_uniq as select RecId,        Time,        Sign                from (select metrics_dirty.RecId,                metrics_dirty.Time,                metrics_dirty.Sign,                               row_number() over(partition by metrics_dirty.RecId,                                               metrics_dirty.Sign                                      order by metrics_dirty.Time desc) as rn           from metrics_dirty \u2013-\u0422\u0430\u0431\u043b\u0438\u0446\u0430-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0441 \u0433\u0440\u044f\u0437\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438           left join metrics_uniq \u2013-\u0422\u0430\u0431\u043b\u0438\u0446\u0430-\u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0437\u0430\u043f\u0438\u0441\u044f\u043c\u0438             on metrics_uniq.RecId = metrics_dirty.RecId            and metrics_uniq.Sign = metrics_dirty.Sign          where coalesce(metrics_uniq.RecId, '') = '' \u2013-\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c, \u0435\u0441\u043b\u0438 \u0435\u0449\u0451 \u043d\u0435\u0442 \u0432 \u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a\u0435         )  where rn = 1; --\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c 1 \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u0443\u0431\u043b\u0435\u0439 <\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u0443\u0441\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0442\u0430\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043d\u0435\u0439 \u0441\u0430\u043c\u043e\u0439, \u0445\u043e\u0442\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u043b\u0430\u0441\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>metrics_dirty<\/strong>. \u041f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u0440\u043d\u0435\u043c \u0432\u0441\u0435\u0433\u043e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0432 \u044d\u0442\u043e\u043c \u041c\u041f \u0443\u0447\u0442\u0435\u043d\u043e, \u0447\u0442\u043e \u0434\u0443\u0431\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u043f\u0440\u0438\u0439\u0442\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u0443\u0441\u043a\u0435. \u0427\u0442\u043e\u0431\u044b \u043e\u0442\u0441\u0435\u044f\u0442\u044c \u0438\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e <strong>row_number()<\/strong> \u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 <strong>rn=1<\/strong>. \u0418 \u0442\u0443\u0442 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c: \u00ab\u0417\u0430\u0447\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u0443\u0431\u043b\u0435\u0439 \u0432 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0435\u043c \u043a\u0443\u0441\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b, \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0430? \u0412\u0435\u0434\u044c \u043a\u0430\u043a <a href=\"https:\/\/clickhouse.com\/docs\/en\/engines\/table-engines\/mergetree-family\/\">\u0441\u043a\u0430\u0437\u0430\u043d\u043e<\/a> \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430 <em>ReplicatedMergeTree<\/em> \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e\u00bb. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u0435\u0434\u0443\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0432 <em>ClickHouse<\/em> \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0430\u044f, \u0442.\u0435. \u043e\u043d\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441\u043e \u0412\u0421\u0415\u041c\u0418 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438, \u0442\u043e\u0433\u0434\u0430 \u043a\u0430\u043a \u0434\u043b\u044f \u043d\u0430\u0441 \u0434\u0443\u0431\u043b\u044f\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0430\u0436\u0435 \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043b\u0435 <strong>Time<\/strong>.<\/p>\n<p>\u041c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u0431\u043e\u0440\u044c\u0431\u044b \u0441 \u0434\u0443\u0431\u043b\u044f\u043c\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <strong>metrics_uniq <\/strong>\u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0430 \u043d\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f \u0432 ClickHouse \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u0432 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0434\u0432\u0438\u0436\u043e\u043a <strong>ReplacingMergeTree<\/strong>. \u0423\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0434\u0432\u0438\u0436\u043e\u043a \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0434\u0443\u0431\u043b\u0438 \u043f\u043e \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443 \u043f\u043e\u043b\u0435\u0439 \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0435\u0439 \u043b\u043e\u0433\u0438\u043a\u0438 \u0432 \u041c\u041f. \u041d\u043e \u044d\u0442\u043e \u0431\u044b \u043d\u0435 \u043f\u043e\u043c\u0435\u0448\u0430\u043b\u043e \u041c\u041f \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0434\u0443\u0431\u043b\u0438 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435\u043c \u041c\u041f, \u0432\u043d\u043e\u0441\u044f\u0449\u0435\u0435 \u0434\u0443\u0431\u043b\u0438 \u0434\u0430\u043b\u0435\u0435 \u043f\u043e \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422.\u0435. \u043c\u044b \u0431\u044b \u0434\u043e\u0431\u0438\u043b\u0438\u0441\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043d\u043e \u043d\u0435 \u0437\u0430\u0449\u0438\u0442\u0443 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0434\u0443\u0431\u043b\u0435\u0439. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u043e\u0442 \u0434\u0443\u0431\u043b\u0435\u0439, \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u201c\u043e\u0431\u044b\u0447\u043d\u044b\u0439\u201d \u0434\u0432\u0438\u0436\u043e\u043a <strong>MergeTree, <\/strong>\u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0443\u0431\u043b\u0435\u0439 \u0432 <strong>metrics_uniq<\/strong>.<\/p>\n<p>\u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0435 \u041c\u041f \u0438\u043c\u0435\u0435\u0442 \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u044b\u0439 \u0432\u0438\u0434 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u043e\u043c, \u0442.\u043a. \u043f\u0440\u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u043e\u043c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0451\u043c\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u043e \u0434\u043e\u043b\u0433\u043e. \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u044d\u0442\u043e\u0433\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e ClickHouse, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <strong>JOIN<\/strong>. \u042d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0448\u0438\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u0435\u043a\u0446\u0438\u0438 <strong>WITH<\/strong> \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c. \u041d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u0441\u043a\u0430\u0436\u0443 \u0442\u043e\u043b\u044c\u043a\u043e, \u0447\u0442\u043e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <strong>WITH<\/strong> \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430, \u0438 \u0434\u0430\u043b\u0435\u0435 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <strong>JOIN<\/strong>. \u0422.\u0435. \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <strong>JOIN<\/strong> \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u043d\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0430 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0435\u0439 <strong>WHERE<\/strong> \u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435, \u043a\u0430\u043a \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <strong>WITH. <\/strong>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u041c\u041f \u0441\u0442\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u041c\u041f, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u044b\u043b <strong>JOIN,<\/strong> \u043c\u044b \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043b\u0438 \u0432 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0444\u043e\u0440\u043c\u0435.<\/p>\n<h4>\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>\u0421\u0443\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043c\u0435\u0447\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u043c\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u2013 metrics_logic_upd, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0432 \u043d\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u043d\u0435 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438, \u0430 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438. \u0422.\u0435. \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0443\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0443\u0441\u043b\u043e\u0432\u043d\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u04101, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u04101\u2019 (A1 \u0448\u0442\u0440\u0438\u0445), \u043a\u0430\u043a \u0431\u044b \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u0443\u044f \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u04102, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u04101. \u041e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e \u043e\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438\u0445, \u043e\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0440\u044b\u0445. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e, \u0434\u0430\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0438 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u0442.\u0435. \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0445 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f \u2013 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u044e \u043b\u043e\u0433\u0438\u043a\u0438.<\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u043c \u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 <strong>Sign<\/strong>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0437\u0430\u043f\u0438\u0441\u0438. \u0414\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439 <em>\u04101<\/em> \u2013 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>Sign=1<\/strong>, \u0430 \u0434\u043b\u044f <em>\u04101\u2019<\/em> \u2013 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>Sign=-1<\/strong>; <strong>RecId<\/strong> \u0432 \u0437\u0430\u043f\u0438\u0441\u044f\u0445 <em>\u04101<\/em> \u0438 <em>\u04102<\/em> \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435, \u0430 <strong>Time<\/strong> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u044e\u0431\u044b\u043c, \u043e\u043d\u043e \u0434\u043b\u044f \u043d\u0430\u0441 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0438 <em>\u04101<\/em> \u0438 <em>\u04101\u2019<\/em>, \u0441\u0443\u043c\u043c\u0430 <strong>Sign<\/strong> \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0440\u0430\u0432\u043d\u043e\u0439 0, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 <em>A1<\/em>. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0432\u043a\u043b\u0430\u0434 \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u044c <em>\u04102<\/em>.<\/p>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b <strong>metrics_logic_upd<\/strong>:<\/p>\n<pre><code>create table metrics_logic_upd on cluster some_cluster (      RecId       String,      Time        DateTime64(6),      Total       Int8,      CreateTime  DateTime64(6) default toDateTime64(now64(), 6) ) ENGINE = ReplicatedMergeTree() ORDER BY (CreateTime, RecId);<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432 \u043f\u043e\u043b\u0435 <strong>Total<\/strong> \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0441\u0443\u043c\u043c\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u043f\u043e\u043b\u0435 <strong>Sign<\/strong> \u0437\u0430\u043f\u0438\u0441\u0435\u0439 <em>A1<\/em> \u0438 <em>A1\u2019<\/em>, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f. \u0422.\u0435. \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f 1 \u0434\u043b\u044f \u043d\u0435\u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 (\u043e\u0434\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c \u0441 <strong>Sign=1<\/strong>) \u0438 0 \u2013 \u0434\u043b\u044f \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 (\u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 <strong>Sign=1<\/strong> \u0438 <strong>Sign=-1<\/strong>).<\/p>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u041c\u041f \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u00ab\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e\u00bb \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f. <\/p>\n<pre><code>create materialized view metrics_logic_upd_mv on cluster some_cluster  to metrics_logic_upd as          select q.RecId,        q.Time,        q.Total,        toDateTime64(now64(), 6) as CreateTime   from (select uniq.RecId,                uniq.Time,                uniq.Sign + coalesce(logic_upd.Total, 0) as Total --\u0421\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c \u0434\u043b\u044f \u0443\u0447\u0451\u0442\u0430 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f           from (select metrics_uniq.RecId,                        metrics_uniq.Time,                        metrics_uniq.Sign                   from metrics_uniq                 ) uniq           left join (select metrics_logic_upd.RecId,                             metrics_logic_upd.Total                        from metrics_logic_upd                     ) logic_upd             on logic_upd.RecId = uniq.RecId                             ) q;<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <strong>FROM<\/strong> \u0443\u043a\u0430\u0437\u0430\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a <strong>metrics_uniq<\/strong>, \u043f\u0440\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u041c\u041f \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442; \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <strong>LEFT JOIN<\/strong> \u0443\u043a\u0430\u0437\u0430\u043d\u0430 \u0442\u0430 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0447\u0442\u043e \u0438 \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <strong>TO<\/strong> \u2013 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u00ab\u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c\u00bb \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 <strong>metrics_logic_upd,<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u043d\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438. <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u0441\u0442\u0430\u0440\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043d\u0435\u0439 \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0434\u0435\u0432\u0430\u044e\u0442\u0441\u044f, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u0442\u0435\u043c \u0436\u0435 <strong>RecId,<\/strong> \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0434\u0430\u0442\u043e\u0439 <strong>CreateTime<\/strong>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u044b\u0431\u0438\u0440\u0430\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <strong>CreateTime<\/strong> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e <strong>RecId,<\/strong> \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0434\u0430\u043d\u043d\u044b\u0435.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u041c\u041f, \u043e\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u041c\u041f \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u043d\u043e\u0432\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445, \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u044d\u0442\u043e\u043c \u041c\u041f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u044b\u043c. \u041c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0443\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <strong>LEFT JOIN<\/strong> \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u043e <strong>RecId<\/strong>, \u0430 \u043d\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c <strong>CreateTime<\/strong>? \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0434\u0440\u0443\u0433\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 <strong>RecId<\/strong> \u0432 \u043d\u0435\u0439 \u0431\u044b\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u043c\u044b \u0443\u0436\u0435 \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u0442 \u0434\u0443\u0431\u043b\u0435\u0439.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0430\u0433 \u2013 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u0432\u0438\u0436\u043a\u0430 \u043c\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 <strong>ENGINE = ReplicatedVersionedCollapsingMergeTree<\/strong>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0432 \u0444\u043e\u043d\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u201c\u043c\u0443\u0441\u043e\u0440\u0430\u201d \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u043e. \u041e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u0442\u0438\u043c \u0434\u0432\u0438\u0436\u043a\u043e\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 <a href=\"https:\/\/clickhouse.com\/docs\/ru\/engines\/table-engines\/mergetree-family\/versionedcollapsingmergetree\/\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a>, \u044f \u043d\u0430 \u044d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0443, \u043e\u0442\u043c\u0435\u0447\u0443 \u0442\u043e\u043b\u044c\u043a\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442.\u043a. \u0438\u0445 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<pre><code>create table metrics_agg on cluster some_cluster (     PeriodStart   DateTime64(6),  --\u041d\u0430\u0447\u0430\u043b\u043e 15-\u0438 \u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438     PeriodEnd     DateTime64(6),  --\u041a\u043e\u043d\u0435\u0446 15-\u0438 \u043c\u0438\u043d\u0443\u0442\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438     `Count`       UInt64,         --\u0412\u0441\u0435\u0433\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0437\u0430 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b     CreateTime    DateTime64(6),  --\u0412\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438     Sign          Int8,           --\u0422\u0438\u043f \u0441\u0442\u0440\u043e\u043a\u0438: 1\u2014\u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, -1\u2014\u0441\u0442\u0440\u043e\u043a\u0430 \u043e\u0442\u043c\u0435\u043d\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f     Version       UInt8           --\u0412\u0435\u0440\u0441\u0438\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0438 ) ENGINE = ReplicatedVersionedCollapsingMergeTree (Sign, Version) ORDER BY (PeriodStart);<\/code><\/pre>\n<p>\u0422\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u041c\u041f \u0434\u043b\u044f \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\/\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439, \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435. <\/p>\n<pre><code>create materialized view metrics_agg_mv on cluster some_cluster to metrics_agg as select q.PeriodStart,        q.PeriodEnd,        q.`Count`,        toDateTime64(now64(), 6) as CreateTime,        q.Sign,        q.Version          from (select new_batch.IncTotal + coalesce(last_agg.`Count`, 0) as `Count`,                new_batch.PeriodStart as PeriodStart,                new_batch.PeriodEnd as PeriodEnd,                coalesce(last_agg.Sign, 1) as Sign, --\u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0435\u0449\u0451 \u043d\u0435 \u0431\u044b\u043b\u043e, \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a 1                coalesce(last_agg.Version, 1) as Version --\u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0435\u0449\u0451 \u043d\u0435 \u0431\u044b\u043b\u043e, \u0431\u0443\u0434\u0435\u0442 \u0432\u0435\u0440\u0441\u0438\u044f 1                          from (select sum( Inc ) as IncTotal,                                                 PeriodStart,                        PeriodEnd                   from (select RecId,                                toDateTime64(toStartOfInterval( Time, interval 15 minute ), 6) as PeriodStart, --\u041d\u0430\u0447\u0430\u043b\u043e 15-\u0438 \u043c\u0438\u043d\u0443\u0442\u043a\u0438                                toDateTime64(toStartOfInterval( Time, interval 15 minute ) + interval 15 minute, 6) as PeriodEnd, --\u041a\u043e\u043d\u0435\u0446 15-\u0438 \u043c\u0438\u043d\u0443\u0442\u043a\u0438                                case                                     when Total = 1 then --Total = 1 (\u043f\u0440\u0438\u0445\u043e\u0434 \u043d\u043e\u0432\u043e\u0439)                                        1                                    else --Total = 0 (\u043f\u0440\u0438\u0448\u043b\u043e \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435)                                        -1                                end as Inc, --\u0421\u0447\u0438\u0442\u0430\u0435\u043c \u0438\u043d\u043a\u0440\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438                                row_number() over(partition by RecId                                                       order by Time desc) as rn                                                          from metrics_logic_upd                          where Total in (0, 1)                                                  )                  where rn = 1                  group by PeriodStart,                           PeriodEnd                 ) new_batch                                --\u041e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439           left join (select t.PeriodStart,                             t.PeriodEnd,                             t.`Count`,                             sgn.Sign,                             case                               when sgn.Sign = -1 then t.Version --\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u043b\u044f \u043e\u0442\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0439                               when sgn.Sign = 1 then t.Version + 1 --\u043d\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0439                             end as Version                                                    from (select PeriodStart,                                     PeriodEnd,                                     `Count`,                                     row_number() over(partition by PeriodStart, PeriodEnd                                                                                                    order by CreateTime desc) as rn                                from metrics_agg                             ) t                                         --\u0420\u0430\u0437\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a \u043d\u0430 2 \u0434\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:                       --  1-\u044f \u0434\u043b\u044f \u043e\u0442\u043c\u0435\u043d\u044b \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0442\u043e\u0447\u043d\u0430\u044f \u043a\u043e\u043f\u0438\u044f \u0441 Sign = -1                       --  2-\u044f - \u043d\u043e\u0432\u0430\u044f \u0441 Sign = 1                       cross join (select case                                             when number = 0 then -1 --\u0434\u043b\u044f \u043e\u0442\u043c\u0435\u043d\u044b \u0441\u0442\u0430\u0440\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438                                            when number = 1 then 1 --\u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438                                          end as Sign                                     from numbers(2)                                   ) sgn                                                                       where rn = 1                     ) last_agg                       on last_agg.PeriodStart = new_batch.PeriodStart             and last_agg.PeriodEnd = new_batch.PeriodEnd                          ) q; <\/code><\/pre>\n<p>\u0415\u0433\u043e \u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443 \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u0441\u0435\u043a\u0446\u0438\u0438 <strong>LEFT JOIN<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c <strong>CreateTime<\/strong> \u0434\u043b\u044f \u043d\u0430\u0431\u043e\u0440\u0430 \u0437\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434, \u0442.\u043a. \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u043d\u043e\u0433\u043e, \u0430 \u043d\u0430\u043c \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u044b \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u0438\u043c\u0435\u044e\u0449\u0438\u0435\u0441\u044f.<\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b XXX \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<pre><code>select q.PeriodStart,        q.PeriodEnd,        q.`Count`   from (select t.PeriodStart,                t.PeriodEnd,                t.`Count`                row_number() over(partition by t.PeriodStart,                                               t.PeriodEnd                                      order by t.Version desc) as rn           from metrics_agg t          where t.Sign = 1        ) q  where q.rn = 1 --\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0441 <strong>Sign = 1<\/strong> (\u043d\u0435\u043e\u0442\u043c\u0435\u043d\u0451\u043d\u043d\u044b\u0435) \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <strong>Version<\/strong> \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u0435\u0442\u0440\u0438\u043a\u0438.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0412\u0410\u0416\u041d\u041e\u0415 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435. \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0432 \u043a\u043e\u0434\u0435 \u0432\u0441\u0435\u0445 \u041c\u041f, \u0432 \u043d\u0438\u0445 \u043e\u0434\u0438\u043d \u043e\u0431\u0449\u0438\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u2013 \u043f\u043e\u0438\u0441\u043a \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u043d\u043e\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443, \u043a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, ClickHouse \u043d\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u044b\u0439, \u0430 Eventually Consistent, \u0442\u043e, \u0447\u0442\u043e \u0432\u044b \u0432 \u043d\u0435\u0433\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438, \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 SELECT, \u043d\u043e \u043d\u0435 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0430\u0431\u044b\u043c \u043c\u0435\u0441\u0442\u043e\u043c \u0432\u0441\u0435\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0435\u0433\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u0432\u044b \u0440\u0435\u0448\u0438\u0442\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0443 \u0441\u0435\u0431\u044f. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u0440\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u043f\u043e\u0432\u0442\u043e\u0440\u0430\u043c\u0438 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0441\u043f\u0435\u0432\u0430\u044e\u0442 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f. \u041c\u044b \u0437\u0430 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0448\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438 \u0438\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e, \u0430 \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435 \u0438\u043c\u0435\u0435\u043c \u0432 \u0432\u0438\u0434\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0432\u0441\u0442\u0430\u0432\u043a\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 <em>ClickHouse <\/em>\u0435\u0441\u0442\u044c: <\/p>\n<ol>\n<li>\n<p>\u043a\u043e\u043c\u0430\u043d\u0434\u0430 <a href=\"https:\/\/clickhouse.com\/docs\/ru\/sql-reference\/statements\/system\/#query_language-system-flush-distributed\">FLUSH DISTRIBUTED<\/a><\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <a href=\"https:\/\/clickhouse.com\/docs\/ru\/operations\/settings\/settings\/#insert_distributed_sync\">insert_distributed_sync<\/a><\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <a href=\"https:\/\/clickhouse.com\/docs\/en\/engines\/table-engines\/special\/distributed#fsync_after_insert\">fsync_after_insert<\/a><\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u043a\u0430 \u043d\u0438 \u0441 \u0447\u0435\u043c \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043d\u0435 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u043f\u044b\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0447\u0435\u0433\u043e-\u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e, \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0435\u0433\u043e \u0443\u0437\u043d\u0430\u0442\u044c.<\/p>\n<h3>\u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0435\u043f\u0435\u0440\u044c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/678\/17a\/338\/67817a3388e5637b55d700af337f7588.jpg\" width=\"1180\" height=\"538\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/678\/17a\/338\/67817a3388e5637b55d700af337f7588.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u043c \u043e\u0434\u043d\u0443 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>metrics_dirty<\/strong>:<\/p>\n<pre><code>insert into metrics_dirty values('A1', toDateTime64(now64(), 6), 1);<\/code><\/pre>\n<p>\u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432 \u043d\u0430\u0448\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<p>\u0432 <strong>metrics_dirty<\/strong> \u0438 <strong>metrics_uniq<\/strong>:<\/p>\n<pre><code>RecId|Time                   |Sign| -----+-----------------------+----+ A1   |2022-10-19 06:05:41:319|   1|<\/code><\/pre>\n<p>\u0432 <strong>metrics_logic_upd<\/strong>:<\/p>\n<pre><code>RecId|Time                   |Total|CreateTime             | -----+-----------------------+-----+-----------------------+ A1   |2022-10-19 06:05:41:319|    1|2022-10-19 06:05:41:329|<\/code><\/pre>\n<p>\u0432 <strong>metrics_agg<\/strong>:<\/p>\n<pre><code>PeriodStart          |PeriodEnd            |Count|CreateTime             |Sign|Version| ---------------------+---------------------+-----+-----------------------+----+-------+ 2022-10-19 06:00:00:0|2022-10-19 06:15:00:0|    1|2022-10-19 06:05:41:336|   1|      1|<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u0434\u0443\u0431\u043b\u0435\u0439; \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u044d\u0442\u0443 \u0432\u0441\u0442\u0430\u0432\u043a\u0443 \u0435\u0449\u0451 \u0440\u0430\u0437 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445<\/p>\n<p>\u0432 <strong>metrics_dirty<\/strong>:<\/p>\n<pre><code>RecId|Time                   |Sign| -----+-----------------------+----+ A1   |2022-10-19 06:05:41:319|   1| A1   |2022-10-19 06:08:42:103|   1|<\/code><\/pre>\n<p>\u0432 <strong>metrics_uniq<\/strong>:<\/p>\n<pre><code>RecId|Time                   |Sign| -----+-----------------------+----+ A1   |2022-10-19 06:05:41:319|   1|<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0434\u0443\u0431\u043b\u044c \u043d\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f, \u043a\u0430\u043a \u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 <strong>metrics_logic_upd<\/strong> \u0438 <strong>metrics_agg<\/strong>.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435: \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0432 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <strong>Sign<\/strong> \u043d\u0430 -1<\/p>\n<pre><code>insert into metrics_dirty values('A1', toDateTime64(now64(), 6), -1);<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438<\/p>\n<p>\u0432 <strong>metrics_dirty<\/strong>:<\/p>\n<pre><code>RecId|Time                   |Sign| -----+-----------------------+----+ A1   |2022-10-19 06:05:41:319|   1| A1   |2022-10-19 06:08:42:103|   1| A1   |2022-10-19 06:13:47:409|  -1|<\/code><\/pre>\n<p>\u0432 <strong>metrics_uniq:<\/strong><\/p>\n<pre><code>RecId|Time                   |Sign| -----+-----------------------+----+ A1   |2022-10-19 06:05:41:319|   1| A1   |2022-10-19 06:13:47:409|  -1| <\/code><\/pre>\n<p>\u0432 <strong>metrics_logic_upd:<\/strong><\/p>\n<pre><code>RecId|Time                   |Total|CreateTime             | -----+-----------------------+-----+-----------------------+ A1   |2022-10-19 06:05:41:319|    1|2022-10-19 06:05:41:329| A1   |2022-10-19 06:13:47:409|    0|2022-10-19 06:13:47:418|<\/code><\/pre>\n<p>\u0432 <strong>metrics_agg:<\/strong><\/p>\n<pre><code>PeriodStart          |PeriodEnd            |Count|CreateTime             |Sign|Version| ---------------------+---------------------+-----+-----------------------+----+-------+ 2022-10-19 06:00:00:0|2022-10-19 06:15:00:0|    1|2022-10-19 06:05:41:336|   1|      1| 2022-10-19 06:00:00:0|2022-10-19 06:15:00:0|    0|2022-10-19 06:13:47:426|  -1|      1| 2022-10-19 06:00:00:0|2022-10-19 06:15:00:0|    0|2022-10-19 06:13:47:426|   1|      2|<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <strong>metrics_dirty<\/strong> \u043a\u043e\u043f\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438; \u0432 <strong>metrics_uniq<\/strong> \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0432\u043e\u0439; \u0434\u0430\u043b\u0435\u0435 \u0432 <strong>metrics_logic_upd<\/strong> \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0438\u043c\u0435\u044e\u0449\u0430\u044f\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043b\u044f <em>A1<\/em> \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c <strong>Total=0<\/strong>, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c \u0435\u0451 \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0432 <strong>metrics_agg<\/strong> \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0437\u0430\u043f\u0438\u0441\u044c (\u0441 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0438\u043c <strong>VERSION <\/strong>\u0438<strong> Sign=1<\/strong>) \u0438\u043c\u0435\u0435\u0442 <strong>Count=0<\/strong>, \u0442.\u0435. \u043e\u043d\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0432\u043a\u043b\u0430\u0434 \u043f\u0440\u0438 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u043e <strong>Count<\/strong>, \u043a\u0430\u043a \u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0434\u043b\u044f \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0434\u043b\u044f <em>A1<\/em>, \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0435\u0451 <em>A2<\/em><\/p>\n<pre><code>insert into metrics_dirty values('A2', toDateTime64(now64(), 6), 1);<\/code><\/pre>\n<p>\u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b <strong>metrics_dirty<\/strong> \u0438 <strong>metrics_uniq<\/strong> \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432 \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f. \u0412 <strong>metrics_logic_upd<\/strong> \u0431\u0443\u0434\u0443\u0442 \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438:<\/p>\n<pre><code>RecId|Time                   |Total|CreateTime             | -----+-----------------------+-----+-----------------------+ A1   |2022-10-19 06:05:41:319|    1|2022-10-19 06:05:41:329| A1   |2022-10-19 06:13:47:409|    0|2022-10-19 06:13:47:418| A2   |2022-10-19 06:23:47:763|    1|2022-10-19 06:23:47:784|<\/code><\/pre>\n<p>\u0432 <strong>metrics_agg<\/strong>:<\/p>\n<pre><code>PeriodStart          |PeriodEnd            |Count| CreateTime            |Sign|Version| ---------------------+---------------------+-----+-----------------------+----+-------+ 2022-10-19 06:00:00:0|2022-10-19 06:15:00:0|    1|2022-10-19 06:05:41:336|   1|      1| 2022-10-19 06:00:00:0|2022-10-19 06:15:00:0|    0|2022-10-19 06:13:47:426|  -1|      1| 2022-10-19 06:00:00:0|2022-10-19 06:15:00:0|    0|2022-10-19 06:13:47:426|   1|      2| 2022-10-19 06:15:00:0|2022-10-19 06:30:00:0|    1|2022-10-19 06:23:47:795|  -1|      2| 2022-10-19 06:15:00:0|2022-10-19 06:30:00:0|    1|2022-10-19 06:23:47:795|   1|      3|<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0435\u0449\u0451 \u0440\u0430\u0437 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0431\u0443\u0434\u0443\u0442 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u043f\u0438\u0441\u044c<\/p>\n<pre><code>insert into metrics_dirty values('B1', toDateTime64(now64(), 6), 1);<\/code><\/pre>\n<p>\u0432 <strong>metrics_agg<\/strong>:<\/p>\n<pre><code>PeriodStart          |PeriodEnd            |Count| CreateTime            |Sign|Version| ---------------------+---------------------+-----+-----------------------+----+-------+ 2022-10-19 06:00:00:0|2022-10-19 06:15:00:0|    1|2022-10-19 06:05:41:336|   1|      1| 2022-10-19 06:00:00:0|2022-10-19 06:15:00:0|    0|2022-10-19 06:13:47:426|  -1|      1| 2022-10-19 06:00:00:0|2022-10-19 06:15:00:0|    0|2022-10-19 06:13:47:426|   1|      2| 2022-10-19 06:15:00:0|2022-10-19 06:30:00:0|    1|2022-10-19 06:23:47:795|  -1|      2| 2022-10-19 06:15:00:0|2022-10-19 06:30:00:0|    1|2022-10-19 06:23:47:795|   1|      3| 2022-10-19 06:15:00:0|2022-10-19 06:30:00:0|    2|2022-10-19 06:29:35:505|  -1|      3| 2022-10-19 06:15:00:0|2022-10-19 06:30:00:0|    2|2022-10-19 06:29:35:505|   1|      4|<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043f\u043e <strong>Version<\/strong> \u0437\u0430\u043f\u0438\u0441\u044c \u0438\u043c\u0435\u0435\u0442 <strong>Count=2<\/strong>, \u0442.\u0435. \u0437\u0430\u043f\u0438\u0441\u0438, \u043a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c, \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/1bc\/064\/6ef\/1bc0646efaf286e0b06f111d8813f091.jpg\" width=\"1180\" height=\"538\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1bc\/064\/6ef\/1bc0646efaf286e0b06f111d8813f091.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0434\u0432\u043e\u0434\u044f \u0438\u0442\u043e\u0433 \u0432\u044b\u0448\u0435\u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c\u0443, \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 4-\u0445 \u041c\u041f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u0430\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0431\u044b\u043b \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d 1 \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043a\u0443\u0441\u043a\u0430 \u0432 5 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0443\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u0432 5 \u043c\u0438\u043d\u0443\u0442, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0430\u0448\u0435\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 (\u0434\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0441\u0443\u0442\u043a\u0438) \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<p>\u0418\u0437 \u043c\u0438\u043d\u0443\u0441\u043e\u0432 \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0432\u0441\u0451 \u0431\u043e\u043b\u0435\u0435 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u043c \u043f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0434\u0435\u043b\u0438\u0432 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0435, \u0447\u0442\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0443\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f, \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0432 \u0438\u0445 \u0438\u0437 \u043f\u043e\u0438\u0441\u043a\u0430. \u041e\u0434\u043d\u0430\u043a\u043e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0435\u0441\u0442\u044c \u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u2013 \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0441\u043b\u044b\u0448\u0430\u0442\u044c \u043c\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u043e\u0432 ClickHouse \ud83d\ude42<\/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\/company\/ibs\/blog\/703124\/\"> https:\/\/habr.com\/ru\/company\/ibs\/blog\/703124\/<\/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<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043d\u0442\u043e\u043d, \u044f \u2013 \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 \u043e\u0442\u0434\u0435\u043b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 IBS. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043d\u0430\u0448\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0431\u044b\u043b\u0430 \u0440\u0435\u0448\u0435\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044e \u0432 <em>ClickHouse<\/em> \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c, \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435, \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u0432\u0440\u044f\u0434 \u043b\u0438 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435. \u041d\u043e \u043d\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u0441\u043e\u0431\u043e\u0439 \u0440\u044f\u0434 \u043d\u044e\u0430\u043d\u0441\u043e\u0432: \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0434\u0443\u0431\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u0434\u0443\u0431\u043b\u0438 (\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f), \u0435\u0441\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0410 \u044d\u0442\u043e \u0443\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f ClickHouse, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u044b \u0438 \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f.<\/p>\n<h3>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h3>\n<p>\u041d\u0430\u0434 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043d\u0430\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u2013 \u044f \u0438 \u0434\u0432\u0430 \u0431\u044d\u043a\u0435\u043d\u0434\u0435\u0440\u0430 \u2013 \u043d\u0430\u0447\u0430\u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u0440\u0443\u043f\u043d\u043e\u0433\u043e \u0433\u043e\u0441\u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430. \u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0434\u0443\u043a\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u0441\u043e\u0431\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u043a\u0443\u0447\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432. \u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c\u0438. \u041d\u0438\u0436\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u044b \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u0435\u0449\u0451 \u0434\u043e \u043d\u0430\u0448\u0435\u0433\u043e \u0432\u043c\u0435\u0448\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0443\u044e \u0437\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432. <\/p>\n<p>\u041f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u043c\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0443 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u044f\u0434 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 (\u043c\u0435\u0442\u0440\u0438\u043a), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430. \u0420\u0430\u043d\u0435\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043d\u0430 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u0443\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u044d\u0442\u043e\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439, \u0447\u0442\u043e \u043e\u0431\u0443\u0441\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0438 \u0443\u0436\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u0440\u0438\u043a. \u0410\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u0445 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0444\u043e\u0440\u043c \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e, \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434.<\/p>\n<h3>\u0418\u0442\u0430\u043a, \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0440\u043e\u0433\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0435<\/h3>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<ol>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0434\u0443\u0431\u043b\u0435\u0439 \u043c\u0435\u0442\u0440\u0438\u043a.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u0440\u0438\u043a \u0432 \u0441\u0443\u0442\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u0445 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e (\u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434).<\/p>\n<\/li>\n<\/ol>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 <em>Elasticsearch<\/em>. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0435\u0442\u0440\u0438\u043a \u0440\u043e\u0441\u043b\u043e, \u0438 \u0434\u0432\u0438\u0436\u043e\u043a \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0442\u044c \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0432\u044b\u0434\u0430\u0447\u0438 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e \u043d\u0435\u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0442.\u043a. \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 ES \u0432\u044b\u043d\u0443\u0436\u0434\u0435\u043d \u0431\u044b\u043b \u0437\u0430\u043d\u043e\u0432\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043e\u0431\u044a\u0451\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u0443\u0447\u0435\u0441\u0442\u044c \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f. \u041c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 <em>ClickHouse<\/em>. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u043c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u043e\u0432 \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0451\u043c\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043e\u043d \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u0418 \u0432\u0441\u0451 \u0431\u044b \u0445\u043e\u0440\u043e\u0448\u043e, \u0435\u0441\u043b\u0438 \u0431\u044b \u043d\u0435 \u043f.3 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0430\u0448\u0438\u0445 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u2013 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0412\u0435\u0434\u044c \u043a\u0430\u043a <a href=\"https:\/\/clickhouse.com\/docs\/ru\/sql-reference\/statements\/alter\/#mutations\">\u0441\u043a\u0430\u0437\u0430\u043d\u043e<\/a> \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f <em>UPDATE<\/em> \u0432 <em>ClickHouse<\/em> \u043d\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0430 \u0442\u044f\u0436\u0451\u043b\u0430\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043d\u0430\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u043e \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b ClickHouse \u0438 \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0445\u043e\u0434\u0438\u043b\u043e \u044d\u0442\u0443 \u0435\u0433\u043e \u00ab\u0441\u043b\u0430\u0431\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443\u00bb. <\/p>\n<p>\u0422\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430\u043c \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0439\u0442\u0438. \u0422\u043e, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u00ab<em>\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c\u00bb<\/em>. \u00ab<em>\u041b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u00bb, <\/em>\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 <em>UPDATE<\/em>-\u043e\u0432 \u0438\u0437-\u0437\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 <em>ClickHouse<\/em> \u043c\u044b \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0430\u043d\u043d\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u043e\u0431\u043d\u043e\u0432\u043b\u0451\u043d\u043d\u044b\u0445. \u0410 \u00ab<em>\u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u00bb,<\/em> \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0430\u0433\u0440\u0435\u0433\u0430\u0442\u044b \u043d\u0435 \u043f\u043e \u0432\u0441\u0435\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0443 \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0432\u043d\u043e\u0432\u044c \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c. \u0410\u0433\u0440\u0435\u0433\u0430\u0442\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u043e\u0436\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 <em>UPDATE<\/em>. \u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0442\u043e, \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e.<\/p>\n<h3>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h3>\n<h4>\u0421\u0445\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/h4>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0438\u0441\u044c 4 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 4 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f (\u041c\u041f). \u041c\u041f \u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430 \u043a\u043e\u043d\u0432\u0435\u0439\u0435\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u00ab\u0433\u0440\u044f\u0437\u043d\u044b\u0435\u00bb (\u0432 \u043f\u043b\u0430\u043d\u0435 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0434\u0443\u0431\u043b\u0435\u0439) \u043d\u0435\u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u0432\u044b\u0445\u043e\u0434\u044f\u0442 \u2013 \u043e\u0447\u0438\u0449\u0435\u043d\u043d\u044b\u0435 \u043e\u0442 \u0434\u0443\u0431\u043b\u0435\u0439, \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435. \u0421\u0445\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u0430 \u0420\u0438\u0441. 1<\/p>\n<figure class=\"\"><figcaption>\u0420\u0438\u0441.1. \u0421\u0445\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041d\u0430\u0431\u043e\u0440 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u041c\u041f \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/figcaption><\/figure>\n<h4>\u041c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 ClickHouse<\/h4>\n<p>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043e\u0442\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u041c\u041f \u0432 <em>ClickHouse<\/em>. \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c 2 \u0432\u0438\u0434\u0430 \u041c\u041f: \u043f\u0435\u0440\u0432\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442 \u0434\u0430\u043d\u043d\u044b\u0435; \u0432\u0442\u043e\u0440\u044b\u0435, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <strong><em>TO [db]. [destination_table],<\/em><\/strong> \u043d\u0435 \u0445\u0440\u0430\u043d\u044f\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f, \u043f\u043e \u0441\u0443\u0442\u0438, <em>after-insert<\/em> \u0442\u0440\u0438\u0433\u0433\u0435\u0440\u043e\u043c (\u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0430 \u0435\u0433\u043e \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430).<\/p>\n<pre><code>CREATE MATERIALIZED VIEW [db.]view [ON CLUSTER] TO [db.] [destination_table] AS SELECT ... FROM [db.] [source_table]<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>source_table<\/strong> \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u041c\u041f, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <strong>SELECT<\/strong> \u043d\u0430\u0434 \u044d\u0442\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>destination_table<\/strong><em>.<\/em> \u0411\u0443\u0434\u0435\u043c \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>source_table<em> <\/em><\/strong>\u00ab\u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c\u00bb, \u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>destination_table<\/strong> \u2013 \u00ab\u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439-\u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a\u043e\u043c\u00bb. \u0412\u0430\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u041c\u041f \u0432\u0438\u0434\u0438\u0442 \u043d\u0435 \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0435, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0438\u0435. \u0412\u0441\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u044e\u0442 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 <strong>SELECT<\/strong>, \u043d\u043e \u043d\u0435 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 <strong>FROM, <\/strong>\u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c\u0438, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u041c\u041f \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043d\u0438\u0445 \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0432 \u0441\u0435\u043a\u0446\u0438\u044f\u0445 <strong>JOIN<\/strong> \u041c\u041f \u0432\u0438\u0434\u0438\u0442 \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u0430\u043a \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c, \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443.<\/p>\n<h4>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/h4>\n<p>\u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0445\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code>{   RecId  String,     --\u041e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u0435\u0442 \u0437\u0430\u043f\u0438\u0441\u044c   Time   DateTime64, --\u0412\u0440\u0435\u043c\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438   Sign   int8        --\u041f\u0440\u0438\u0437\u043d\u0430\u043a \u0437\u0430\u043f\u0438\u0441\u0438 }<\/code><\/pre>\n<p>\u0412 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0435\u0439 \u0432\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435. \u0422\u043e, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u043e\u0434\u043d\u0438\u043c \u043f\u043e\u043b\u0435\u043c <strong>RecId,<\/strong> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0438\u0437 8-\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439, \u043d\u043e \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u044d\u0442\u043e \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong>RecId<\/strong> \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b.<\/p>\n<h4>\u041d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/h4>\n<p>\u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0442 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>from_kafka_metrics<\/strong> \u0438\u0437 <em>Kafka<\/em>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0438\u043c\u0435\u044e\u0449\u0443\u044e\u0441\u044f \u0432 <em>ClickHouse<\/em> \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 <em>Kafka<\/em>, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u0434\u0432\u0438\u0436\u043a\u043e\u043c <em>ENGINE=Kafka<\/em>. \u0414\u0430\u043b\u0435\u0435 \u041c\u041f, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u043d\u0430\u0434 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439, \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <strong>metrics_dirty<\/strong> (\u0440\u0438\u0441. 2).<\/p>\n<figure class=\"\"><figcaption>\u0420\u0438\u0441. 2. \u0421\u0445\u0435\u043c\u0430 \u043f\u043e\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 Kafka \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 metrics_dirty.<\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u043e\u0439 \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u044b\u043b \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u043a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441 \u0434\u0432\u0438\u0436\u043a\u043e\u043c <em>Kafka<\/em> \u0437\u0430\u043f\u0438\u0441\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u0447\u0435\u0437\u0430\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <strong>SELECT<\/strong>, \u0447\u0442\u043e \u043d\u0430\u0441 \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043b\u043e. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <strong>metrics_dirty<\/strong> \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043c\u0435\u0442\u0440\u0438\u043a\u0430\u0445. \u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b <strong>from_kafka_metrics<\/strong> \u0438 \u041c\u041f <strong>from_kafka_metrics_mv,<\/strong> \u0442.\u043a. \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u043e\u043d\u0438 \u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430; \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u0441\u0440\u0430\u0437\u0443 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <strong>metrics_dirty<\/strong>.<\/p>\n<p>\u0421\u043a\u0440\u0438\u043f\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b <strong>metrics_dirty<\/strong> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>create table if not exists metrics_dirty on cluster some_cluster (   RecId   String,   Time    DateTime64(6) default toDateTime64(now64(), 6),   Sign    Int8 default 1    ) ENGINE = ReplicatedMergeTree() ORDER BY tuple();<\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c <strong>RecId<\/strong> \u2013 \u044d\u0442\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0438. <strong>Time<\/strong> \u2013 \u0432\u0440\u0435\u043c\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0438. \u041f\u043e\u043b\u0435 <strong>Sign<\/strong> (\u043f\u0440\u0438\u0437\u043d\u0430\u043a \u0437\u0430\u043f\u0438\u0441\u0438) \u2013 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u043b\u0435, \u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435. \u0415\u0449\u0451 \u0440\u0430\u0437 \u043e\u0442\u043c\u0435\u0447\u0443, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0434\u0443\u0431\u043b\u0438 \u043c\u0435\u0442\u0440\u0438\u043a, \u0442.\u0435. \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e\u043b\u0435\u0439 <strong>RecId<\/strong> \u0438 <strong>Sign<\/strong>. <strong>Time<\/strong> \u0443 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c, \u0442\u0430\u043a \u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0449\u0438\u043c\u0441\u044f; \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u043b\u044f \u043d\u0430\u0441 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u0443\u0431\u043b\u044f\u043c\u0438.<\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u044d\u0442\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u043a\u0430\u043a \u0438 \u0432\u0441\u0435 \u0434\u0440\u0443\u0433\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0438\u0436\u0435, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430\u0434 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446 \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (ENGINE = Distributed), \u0438 \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0438\u0445 \u043d\u0435 \u0431\u0443\u0434\u0443 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u043b\u043e\u0434\u0438\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043c\u043d\u0435 \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f. \u041d\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u043a\u043e\u0434\u0435 \u0432\u0441\u0435\u0445 \u041c\u041f \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044f \u0441\u043a\u0430\u0436\u0443 \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435. \u0410 \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0441\u0443\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<h4>\u0423\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0443\u0431\u043b\u0435\u0439<\/h4>\n<p>\u0414\u043b\u044f \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0443\u0431\u043b\u0435\u0439 \u0431\u044b\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <strong>metrics_uniq<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u043b\u0438 \u0438\u0437 <strong>metrics_dirty<\/strong>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u041c\u041f <strong>metrics_uniq_mv<\/strong>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <strong>metrics_dirty<\/strong>, \u0430 \u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a\u043e\u043c \u2013 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 <strong>metrics_uniq<\/strong>. \u041d\u043e \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u041c\u041f \u0432\u0438\u0434\u0438\u0442 \u043b\u0438\u0448\u044c \u0442\u043e\u0442 \u043a\u0443\u0441\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0432\u0451\u043b \u043a \u0435\u0433\u043e \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044e, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0434\u0443\u0431\u043b\u0435\u0439 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435-\u043f\u0440\u0438\u0451\u043c\u043d\u0438\u043a\u0443, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <strong>JOIN<\/strong>, \u0442.\u043a. \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0438\u0437 \u0441\u0435\u043a\u0446\u0438\u0438 <strong>JOIN<\/strong> \u041c\u041f \u0432\u0438\u0434\u0438\u0442 \u0432\u0435\u0441\u044c \u043d\u0430\u0431\u043e\u0440 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0415\u0441\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 <strong>RecId<\/strong>) \u0435\u0449\u0451 \u043d\u0435\u0442 \u0432 <strong>metrics_uniq,<\/strong> \u0437\u0430\u043f\u0440\u043e\u0441 <strong>SELECT<\/strong> \u0438\u0445 \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u0438\u0437 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0435\u0433\u043e \u043a\u0443\u0441\u043a\u0430 \u0438 \u043d\u0435 \u0432\u044b\u0431\u0435\u0440\u0435\u0442, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441 \u0442\u0430\u043a\u0438\u043c <strong>RecId<\/strong> \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 <strong>metrics_uniq<\/strong> \u043d\u0430\u043a\u0430\u043f\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e \u043d\u0430\u0431\u043e\u0440\u0443 \u043f\u043e\u043b\u0435\u0439 [<strong>RecId<\/strong>, <strong>Sign<\/strong>] \u0434\u0430\u043d\u043d\u044b\u0435. \u0422.\u0435., \u043a\u0430\u043a \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c <strong>RecId<\/strong>, \u043d\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u043f\u0440\u0438\u0437\u043d\u0430\u043a\u043e\u043c <strong>Sign<\/strong> (1 \u0438 -1).<\/p>\n<pre><code>create table if not exists metrics_uniq on cluster some_cluster (     RecId   String,     Time    DateTime64(6),     Sign    Int8 default 1 ) ENGINE = ReplicatedMergeTree() ORDER BY (Sign, RecId);<\/code><\/pre>\n<p>\u041c\u041f \u0434\u043b\u044f \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <strong>metrics_uniq<\/strong> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code>create materialized view metrics_uniq_mv on cluster some_cluster to metrics_uniq as select RecId,        Time,        Sign                from (select metrics_dirty.RecId,                metrics_dirty.Time,                metrics_dirty.Sign,                               row_number() over(partition by metrics_dirty.RecId,                                               metrics_dirty.Sign                                      order by metrics_dirty.Time desc) as rn           from metrics_dirty \u2013-\u0422\u0430\u0431\u043b\u0438\u0446\u0430-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0441 \u0433\u0440\u044f\u0437\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438           left join <\/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-342198","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/342198","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=342198"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/342198\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=342198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=342198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=342198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}