{"id":353233,"date":"2024-05-20T22:23:54","date_gmt":"2024-05-20T22:23:54","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=353233"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-20T22:23:54","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=353233","title":{"rendered":"<span>\u041a\u0430\u043a \u043e\u0431\u0443\u0447\u0438\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0441\u0435\u0440\u0438\u044f\u043c\u0438<\/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<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043e \u0442\u043e\u043c, \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0439 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d\u0438 \u0443\u043c\u0443\u0434\u0440\u044f\u044e\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0435\u0436\u0435\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e. \u041f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0435\u0436\u0435\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 2-8 \u043d\u0435\u0434\u0435\u043b\u044c \u043f\u043e \u043f\u0430\u0440\u0435 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0439. \u041f\u0440\u0438\u0447\u0435\u043c \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437, \u0430 \u0441 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439 \u0438 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (ARIMA, \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0430\u044f \u0441\u0435\u0442\u044c, \u0438 \u0442.\u043f.).<\/p>\n<p>\u0418\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0432\u044b\u0448\u0435 \u0442\u0435\u0440\u0430\u0431\u0430\u0439\u0442\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438 \u0447\u0438\u0441\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0433\u043e\u043d\u044f\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0441\u0435\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<h2>\u041f\u0435\u0440\u0432\u044b\u0439 \u0431\u043b\u0438\u043d \u043a\u043e\u043c\u043e\u043c<\/h2>\n<p>\u041d\u0430 32-\u0445 \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 256 \u0413\u0411 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d MS SQL 2016 Standart \u0438 R service. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0432\u043c\u0435\u0441\u0442\u043e R \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Python \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 CLR. \u041d\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0430 auto.arima \u0432 Python \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043d\u0435 \u0431\u044b\u043b\u043e (\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0443\u0436\u0435?). \u0410 \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u0440\u0438\u0441\u043a\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b\u043d\u043e\u0441\u044f \u043a\u043e\u0434 \u0432 CLR \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0422\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043d\u044f\u043b\u0430 \u043d\u0430 \u043d\u0435\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0430 6 \u0447\u0430\u0441\u043e\u0432. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e, \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 sp_execute_external_script \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0441\u044f \u043a\u043e\u0434 \u043d\u0430 R, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u0443\u0436\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 \u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u044f\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c \u041a\u0430\u043b\u043c\u0430\u043d\u0430, \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0432\u044b\u0438\u0433\u0440\u0430\u0432\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043e\u0437\u043d\u0438\u043a \u0446\u0435\u043b\u044b\u0439 \u0440\u044f\u0434 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<ol>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c sp_execute_external_script, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0435\u043c\u0443 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438, \u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 \u043b\u044e\u0431\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u0443\u0445\u043e\u0434\u0438\u043b\u043e \u043e\u043a\u043e\u043b\u043e 30 \u043c\u0441. \u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u0434\u043b\u044f \u043f\u0430\u0440\u044b \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u043e\u0441\u044c \u0443\u0436\u0435 \u0441\u0432\u044b\u0448\u0435 16 \u0447\u0430\u0441\u043e\u0432. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0446\u0438\u044f MS SQL Standard \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 2 \u044f\u0434\u0440\u0430 \u043f\u0440\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 R.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c sp_execute_external_script, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0435\u043c\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0439. \u041d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 PIVOT \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u0447\u0442\u043e MS SQL \u0434\u0435\u043b\u0430\u043b \u043e\u0447\u0435\u043d\u044c \u0438 \u043e\u0447\u0435\u043d\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 R \u0442\u0430\u043a \u0438 \u043d\u0435 \u0443\u0432\u0435\u043d\u0447\u0430\u043b\u0430\u0441\u044c \u0443\u0441\u043f\u0435\u0445\u043e\u043c. \u041a\u0430\u043a\u0438\u043c\u0438 \u0431\u044b \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u044f \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f, \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u0440\u0430\u0431\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0432\u0430\u043b\u0438\u0432\u0430\u043b\u0441\u044f. \u0410 \u043d\u0430 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 &#8212; \u043e\u0442\u0432\u0430\u043b\u0438\u0432\u0430\u043b\u0441\u044f \u0432\u0441\u0435\u0433\u0434\u0430. \u0414\u0430\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044f\u0434\u0440\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 auto.arima \u043e\u043f\u044f\u0442\u044c \u0442\u0430\u043a\u0438, \u0440\u0430\u0437 \u0432 ~100 \u0442\u044b\u0441. \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u043e \u043a \u043c\u043e\u043b\u0447\u0430\u043b\u0438\u0432\u043e\u043c\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0443 \u043d\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043d\u0430 \u0434\u0432\u0443\u0445 \u044f\u0434\u0440\u0430\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u044b \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0439 \u043d\u0435 \u0443\u0441\u043f\u0435\u0432\u0430\u043b \u0443\u043b\u043e\u0436\u0438\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0434\u0435\u043b\u044e, \u043f\u0440\u0438 \u0442\u043e\u043c \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0434\u043e \u0435\u0436\u0435\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<h2>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u043e\u0440\u0430<\/h2>\n<p>\u041f\u0435\u0440\u0432\u043e\u0439 \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0435\u0439 \u043c\u044b\u0441\u043b\u044c\u044e \u0431\u044b\u043b \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 MS SQL Enterprise. \u0411\u044b\u043b\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u043e \u0434\u0430\u0436\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u043e\u043a\u0430\u0437\u0430\u0432\u0448\u0435\u0435, \u0447\u0442\u043e \u043d\u0430 MS SQL Developer \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e, \u0437\u0430 \u0442\u0440\u043e\u0435 \u0441\u0443\u0442\u043e\u043a. \u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u043e\u043b\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0431\u044e\u0434\u0436\u0435\u0442\u0430 (Enterprise \u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0440\u043e\u0436\u0435 Standard) \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h2>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 T-SQL \u0438 \u043a\u043e\u0434 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043d\u0430 R, \u0442\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f PostgreSQL, \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0432 \u0441\u0432\u043e\u0435\u0439 \u0441\u0440\u0435\u0434\u0435, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0430 R. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u0442\u0443 \u0436\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443 \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d Oracle Linux, PostgreSQL \u0438 R.<\/p>\n<p>\u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 R \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0443 PostgreSQL \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043d\u0438\u0436\u0435 1 \u043c\u0441. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 R \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0441\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 R \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043d\u0430 R \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u044f\u0434\u0435\u0440 PostgreSQL \u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 dblink() \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044f\u0434\u0435\u0440.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0411\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430<\/p>\n<pre><code class=\"pgsql\">CREATE OR REPLACE PROCEDURE perform_query_async_sp (   slave_query text,   cursor_query text,   slaves smallint=16,   batch_size int=64 ) AS $proc$ &lt;&lt;proc>> DECLARE   dbname text=current_database();   batches_cur refcursor;    slave_list text[];   slave_connection text;   conn_status text;   is_not_dispatched boolean;   in_list text; BEGIN   FOR i IN 1..slaves LOOP     slave_connection='Slave'||i::text;     conn_status=dblink_connect(slave_connection,'dbname='||dbname);     IF conn_status&lt;>'OK' THEN       INSERT INTO PBD_ExecutionLog (LogLevel, SourceName, LogMessage, LogCharData)       VALUES (32, 'perform_query_async_sp', format('Slave %s connection error',slave_connection), slave_connection);       COMMIT AND CHAIN;       RAISE EXCEPTION 'Slave % connection error', slave_connection;     END IF;     slave_list=array_append(slave_list,slave_connection);   END LOOP;    OPEN batches_cur FOR EXECUTE cursor_query USING batch_size;   &lt;&lt;cursor_loop>>   LOOP     FETCH batches_cur INTO in_list;      EXIT cursor_loop WHEN NOT FOUND;       is_not_dispatched=TRUE;     WHILE is_not_dispatched LOOP       &lt;&lt;slaves_loop>>       FOREACH slave_connection IN ARRAY slave_list LOOP         IF dblink_is_busy(slave_connection)=0 THEN           conn_status='';           WHILE conn_status IS NOT NULL LOOP            SELECT res FROM dblink_get_result(slave_connection) AS R (res text) INTO conn_status;           END LOOP;           IF dblink_send_query(slave_connection,format(slave_query,in_list))=0 THEN             INSERT INTO PBD_ExecutionLog (LogLevel, SourceName, LogMessage, LogCharData)             VALUES (32, `{OBJECT_NAME`}, format('Slave %s send query error',slave_connection), slave_connection);             COMMIT AND CHAIN;             RAISE EXCEPTION 'Slave % send query error', slave_connection;           END IF;           is_not_dispatched=FALSE;           EXIT slaves_loop;         END IF;       END LOOP;       IF is_not_dispatched THEN         PERFORM pg_sleep(0.01);       END IF;     END LOOP;   END LOOP;   CLOSE batches_cur;    FOREACH slave_connection IN ARRAY slave_list LOOP     WHILE dblink_is_busy(slave_connection)=1 LOOP       PERFORM pg_sleep(0.01);     END LOOP;     conn_status='';     WHILE conn_status IS NOT NULL LOOP       SELECT res FROM dblink_get_result(slave_connection) AS R (res text) INTO conn_status;     END LOOP;     SELECT res FROM dblink_get_result(slave_connection) AS R (res text) INTO conn_status;     conn_status=dblink_disconnect(slave_connection);   END LOOP; END; $proc$ LANGUAGE plpgsql;<\/code><\/pre>\n<p>\u0412 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 slave_query \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 SQL \u0437\u0430\u043f\u0440\u043e\u0441, \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d placeholder %s. \u041e\u0431\u044b\u0447\u043d\u043e, \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 IN (%s). \u0412 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 cursor_query \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u043a\u0443\u0440\u0441\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044f\u0437\u0430\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 (varchar), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u043e %s \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u0437 slave_query \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u043c\u0443 \u0440\u0430\u0431\u0443. \u0422\u0435\u043a\u0441\u0442 \u043a\u0443\u0440\u0441\u043e\u0440\u0430 \u043e\u0431\u044f\u0437\u0430\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c placeholder $1, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 batch_size. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0449\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c \u0432 \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 cursor_query:<\/p>\n<pre><code class=\"pgsql\">SELECT array_to_string(array_agg(Q.VectorId),',') AS in_list FROM (   SELECT V.VectorId, ROW_NUMBER() OVER (ORDER BY V.VectorId) AS rn   FROM tmp_global_statistics_data_time_series_arrays V   ORDER BY V.VectorId) Q GROUP BY Q.rn\/$1 ORDER BY Q.rn\/$1 DESC;<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b perform_query_async_sp \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u043e\u043b\u0438. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043c\u043e\u0433\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 SECURITY DEFINER. \u0412\u0441\u0435 \u0436\u0435 \u0447\u0435\u0440\u0435\u0437 dblink() \u0431\u0435\u0437 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0438 \u044d\u0442\u043e \u043d\u0430\u0434\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0425\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u043c \u043f\u0443\u0442\u0435\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0440\u0430\u0431\u043e\u0432 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0442\u043e \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435\u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u0443\u0435\u043c\u0430\u044f (UNLOGGED). \u0415\u0441\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u0436\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b, \u0442\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c COMMIT.<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432 PostgreSQL \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0432 \u0440\u0430\u0437\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043c\u044b \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u0432\u044b\u0448\u0435 \u0434\u0432\u0443\u0445 \u0441 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043e\u0439 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e, \u0437\u0430 16 \u0447\u0430\u0441\u043e\u0432 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 24 \u044f\u0434\u0435\u0440. \u0422\u0430\u043a \u043a\u0430\u043a \u0437\u0430 \u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430 \u0438 8 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u044f\u0434\u0435\u0440 \u0438\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0442\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043a\u0430\u043a \u0442\u043e \u0441\u0430\u043c \u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/757102\/\"> https:\/\/habr.com\/ru\/articles\/757102\/<\/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<h2>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u041d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043e \u0442\u043e\u043c, \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0439 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u043e\u043d\u0438 \u0443\u043c\u0443\u0434\u0440\u044f\u044e\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0435\u0436\u0435\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e. \u041f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u0435\u0436\u0435\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u043d\u043e\u0437 \u043d\u0430 2-8 \u043d\u0435\u0434\u0435\u043b\u044c \u043f\u043e \u043f\u0430\u0440\u0435 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0439. \u041f\u0440\u0438\u0447\u0435\u043c \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437, \u0430 \u0441 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439 \u0438 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (ARIMA, \u043d\u0435\u0439\u0440\u043e\u043d\u043d\u0430\u044f \u0441\u0435\u0442\u044c, \u0438 \u0442.\u043f.).<\/p>\n<p>\u0418\u043c\u0435\u0435\u0442\u0441\u044f \u0441\u0432\u044b\u0448\u0435 \u0442\u0435\u0440\u0430\u0431\u0430\u0439\u0442\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438 \u0447\u0438\u0441\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0433\u043e\u043d\u044f\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u0441\u0435\u0442\u0438 \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<h2>\u041f\u0435\u0440\u0432\u044b\u0439 \u0431\u043b\u0438\u043d \u043a\u043e\u043c\u043e\u043c<\/h2>\n<p>\u041d\u0430 32-\u0445 \u044f\u0434\u0435\u0440\u043d\u044b\u0439 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 256 \u0413\u0411 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d MS SQL 2016 Standart \u0438 R service. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0432\u043c\u0435\u0441\u0442\u043e R \u0432\u043f\u043e\u043b\u043d\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Python \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 CLR. \u041d\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0430 auto.arima \u0432 Python \u0442\u043e\u0433\u0434\u0430 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043d\u0435 \u0431\u044b\u043b\u043e (\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u044f\u0432\u0438\u043b\u0441\u044f \u0443\u0436\u0435?). \u0410 \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438, \u0440\u0438\u0441\u043a\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0435\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b\u043d\u043e\u0441\u044f \u043a\u043e\u0434 \u0432 CLR \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c.<\/p>\n<p>\u0422\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043d\u044f\u043b\u0430 \u043d\u0430 \u043d\u0435\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0430 6 \u0447\u0430\u0441\u043e\u0432. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e, \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 sp_execute_external_script \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0441\u044f \u043a\u043e\u0434 \u043d\u0430 R, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0449\u0438\u0439 \u0443\u0436\u0435 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 \u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u044f\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c \u041a\u0430\u043b\u043c\u0430\u043d\u0430, \u043e\u0431\u0443\u0447\u0430\u044e\u0449\u0438\u0439 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438\u0445 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0430 \u0432\u044b\u0438\u0433\u0440\u0430\u0432\u0448\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043e\u0437\u043d\u0438\u043a \u0446\u0435\u043b\u044b\u0439 \u0440\u044f\u0434 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e.<\/p>\n<ol>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c sp_execute_external_script, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0435\u043c\u0443 \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438, \u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 \u043b\u044e\u0431\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u0443\u0445\u043e\u0434\u0438\u043b\u043e \u043e\u043a\u043e\u043b\u043e 30 \u043c\u0441. \u0412\u0440\u043e\u0434\u0435 \u0431\u044b \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u043d\u043e \u0434\u043b\u044f \u043f\u0430\u0440\u044b \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u043e\u0441\u044c \u0443\u0436\u0435 \u0441\u0432\u044b\u0448\u0435 16 \u0447\u0430\u0441\u043e\u0432. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0446\u0438\u044f MS SQL Standard \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 2 \u044f\u0434\u0440\u0430 \u043f\u0440\u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 R.<\/p>\n<\/li>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c sp_execute_external_script, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0435\u043c\u0443 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0439. \u041d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 PIVOT \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443, \u0447\u0442\u043e MS SQL \u0434\u0435\u043b\u0430\u043b \u043e\u0447\u0435\u043d\u044c \u0438 \u043e\u0447\u0435\u043d\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0432 R \u0442\u0430\u043a \u0438 \u043d\u0435 \u0443\u0432\u0435\u043d\u0447\u0430\u043b\u0430\u0441\u044c \u0443\u0441\u043f\u0435\u0445\u043e\u043c. \u041a\u0430\u043a\u0438\u043c\u0438 \u0431\u044b \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 \u044f \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f, \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u0440\u0430\u0431\u043e\u0432 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0432\u0430\u043b\u0438\u0432\u0430\u043b\u0441\u044f. \u0410 \u043d\u0430 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 &#8212; \u043e\u0442\u0432\u0430\u043b\u0438\u0432\u0430\u043b\u0441\u044f \u0432\u0441\u0435\u0433\u0434\u0430. \u0414\u0430\u0436\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u044f\u0434\u0440\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 auto.arima \u043e\u043f\u044f\u0442\u044c \u0442\u0430\u043a\u0438, \u0440\u0430\u0437 \u0432 ~100 \u0442\u044b\u0441. \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b\u043e \u043a \u043c\u043e\u043b\u0447\u0430\u043b\u0438\u0432\u043e\u043c\u0443 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0443 \u043d\u0435 \u043e\u0431\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u0430\u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043d\u0430 \u0434\u0432\u0443\u0445 \u044f\u0434\u0440\u0430\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u044b \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0438\u0439 \u043d\u0435 \u0443\u0441\u043f\u0435\u0432\u0430\u043b \u0443\u043b\u043e\u0436\u0438\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0434\u0435\u043b\u044e, \u043f\u0440\u0438 \u0442\u043e\u043c \u0447\u0442\u043e \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0434\u043e \u0435\u0436\u0435\u043d\u0435\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<h2>\u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0431\u043e\u0440\u0430<\/h2>\n<p>\u041f\u0435\u0440\u0432\u043e\u0439 \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0435\u0439 \u043c\u044b\u0441\u043b\u044c\u044e \u0431\u044b\u043b \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 MS SQL Enterprise. \u0411\u044b\u043b\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u043e \u0434\u0430\u0436\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043f\u043e\u043a\u0430\u0437\u0430\u0432\u0448\u0435\u0435, \u0447\u0442\u043e \u043d\u0430 MS SQL Developer \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e, \u0437\u0430 \u0442\u0440\u043e\u0435 \u0441\u0443\u0442\u043e\u043a. \u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u043e\u043b\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0431\u044e\u0434\u0436\u0435\u0442\u0430 (Enterprise \u0441\u0442\u043e\u0438\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0434\u043e\u0440\u043e\u0436\u0435 Standard) \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c.<\/p>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/h2>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 T-SQL \u0438 \u043a\u043e\u0434 \u043e\u0431\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0438 \u043a\u0440\u043e\u0441\u0441\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u043d\u0430 R, \u0442\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f PostgreSQL, \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0432 \u0441\u0432\u043e\u0435\u0439 \u0441\u0440\u0435\u0434\u0435, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0430 R. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430 \u0442\u0443 \u0436\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443 \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d Oracle Linux, PostgreSQL \u0438 R.<\/p>\n<p>\u0418 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 R \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0443 PostgreSQL \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u043d\u0438\u0436\u0435 1 \u043c\u0441. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 R \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0441\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 R \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 \u043d\u0430 R \u043d\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u044f\u0434\u0435\u0440 PostgreSQL \u043d\u0435 \u0437\u0430\u0445\u043e\u0442\u0435\u043b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 dblink() \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044f\u0434\u0435\u0440.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0411\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430<\/p>\n<pre><code class=\"pgsql\">CREATE OR REPLACE PROCEDURE perform_query_async_sp (   slave_query text,   cursor_query text,   slaves smallint=16,   batch_size int=64 ) AS $proc$ &lt;&lt;proc>> DECLARE   dbname text=current_database();   batches_cur refcursor;    slave_list text[];   slave_connection text;   conn_status text;   is_not_dispatched boolean;   in_list text; BEGIN   FOR i IN 1..slaves LOOP     slave_connection='Slave'||i::text;     conn_status=dblink_connect(slave_connection,'dbname='||dbname);     IF conn_status&lt;>'OK' THEN       INSERT INTO PBD_ExecutionLog (LogLevel, SourceName, LogMessage, LogCharData)       VALUES (32, 'perform_query_async_sp', format('Slave %s connection error',slave_connection), slave_connection);       COMMIT AND CHAIN;       RAISE EXCEPTION 'Slave % connection error', slave_connection;     END IF;     slave_list=array_append(slave_list,slave_connection);   END LOOP;    OPEN batches_cur FOR EXECUTE cursor_query USING batch_size;   &lt;&lt;cursor_loop>>   LOOP     FETCH batches_cur INTO in_list;      EXIT cursor_loop WHEN NOT FOUND;       is_not_dispatched=TRUE;     WHILE is_not_dispatched LOOP       &lt;&lt;slaves_loop>>       FOREACH slave_connection IN ARRAY slave_list LOOP         IF dblink_is_busy(slave_connection)=0 THEN           conn_status='';           WHILE conn_status IS NOT NULL LOOP            SELECT res FROM dblink_get_result(slave_connection) AS R (res text) INTO conn_status;           END LOOP;           IF dblink_send_query(slave_connection,format(slave_query,in_list))=0 THEN             INSERT INTO PBD_ExecutionLog (LogLevel, SourceName, LogMessage, LogCharData)             VALUES (32, `{OBJECT_NAME`}, format('Slave %s send query error',slave_connection), slave_connection);             COMMIT AND CHAIN;             RAISE EXCEPTION 'Slave % send query error', slave_connection;           END IF;           is_not_dispatched=FALSE;           EXIT slaves_loop;         END IF;       END LOOP;       IF is_not_dispatched THEN         PERFORM pg_sleep(0.01);       END IF;     END LOOP;   END LOOP;   CLOSE batches_cur;    FOREACH slave_connection IN ARRAY slave_list LOOP     WHILE dblink_is_busy(slave_connection)=1 LOOP       PERFORM pg_sleep(0.01);     END LOOP;     conn_status='';     WHILE conn_status IS NOT NULL LOOP       SELECT res FROM dblink_get_result(slave_connection) AS R (res text) INTO conn_status;     END LOOP;     SELECT res FROM dblink_get_result(slave_connection) AS R (res text) INTO conn_status;     conn_status=dblink_disconnect(slave_connection);   END LOOP; END; $proc$ LANGUAGE plpgsql;<\/code><\/pre>\n<p>\u0412 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 slave_query \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 SQL \u0437\u0430\u043f\u0440\u043e\u0441, \u043e\u0431\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d placeholder %s. \u041e\u0431\u044b\u0447\u043d\u043e, \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 IN (%s). \u0412 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0435 cursor_query \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u043a\u0443\u0440\u0441\u043e\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u044f\u0437\u0430\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 (varchar), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u043e %s \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438\u0437 slave_query \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u043c\u0443 \u0440\u0430\u0431\u0443. \u0422\u0435\u043a\u0441\u0442 \u043a\u0443\u0440\u0441\u043e\u0440\u0430 \u043e\u0431\u044f\u0437\u0430\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c placeholder $1, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 batch_size. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0449\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u043f\u0438\u0441\u043a\u0430, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 \u043a\u0443\u0440\u0441\u043e\u0440\u043e\u043c \u0432 \u0441\u0442\u0440\u043e\u043a\u0435.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 cursor_query:<\/p>\n<pre><code class=\"pgsql\">SELECT array_to_string(array_agg(Q.VectorId),',') AS in_list FROM (   SELECT V.VectorId, ROW_NUMBER() OVER (ORDER BY V.VectorId) AS rn   FROM tmp_global_statistics_data_time_series_arrays V   ORDER BY V.VectorId) Q GROUP BY Q.rn\/$1 ORDER BY Q.rn\/$1 DESC;<\/code><\/pre>\n<p>\u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0432\u044b\u0437\u043e\u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b perform_query_async_sp \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0443 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u043e\u043b\u0438. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 \u043c\u043e\u0433\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439 SECURITY DEFINER. \u0412\u0441\u0435 \u0436\u0435 \u0447\u0435\u0440\u0435\u0437 dblink() \u0431\u0435\u0437 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0438 \u044d\u0442\u043e \u043d\u0430\u0434\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c.<\/p>\n<p>\u0425\u043e\u0447\u0443 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u043c \u043f\u0443\u0442\u0435\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u0440\u0430\u0431\u043e\u0432 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0442\u043e \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435\u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0440\u0443\u0435\u043c\u0430\u044f (UNLOGGED). \u0415\u0441\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c \u0436\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b, \u0442\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c COMMIT.<\/p>\n<\/div>\n<\/details>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0432 PostgreSQL \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0432 \u0440\u0430\u0437\u044b \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043c\u044b \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u0432\u044b\u0448\u0435 \u0434\u0432\u0443\u0445 \u0441 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u043e\u0439 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u043f\u0440\u043e\u0433\u043d\u043e\u0437\u043e\u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e, \u0437\u0430 16 \u0447\u0430\u0441\u043e\u0432 \u0441 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 24 \u044f\u0434\u0435\u0440. \u0422\u0430\u043a \u043a\u0430\u043a \u0437\u0430 \u0432\u043e\u0441\u043a\u0440\u0435\u0441\u0435\u043d\u044c\u0435, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430 \u0438 8 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u044f\u0434\u0435\u0440 \u0438\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u043f\u043e\u043b\u043d\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439, \u0442\u043e \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043a\u0430\u043a \u0442\u043e \u0441\u0430\u043c \u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0441\u044f \u0432 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/757102\/\"> https:\/\/habr.com\/ru\/articles\/757102\/<\/a><br \/><\/br><\/br><\/p>\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-353233","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/353233","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=353233"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/353233\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=353233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=353233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=353233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}