{"id":253035,"date":"2015-03-13T18:33:03","date_gmt":"2015-03-13T14:33:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=253035"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=253035","title":{"rendered":"\u041e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 Postgres"},"content":{"rendered":"<p> \t\t\t\u0422\u0430\u043a \u0443\u0436 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c. \u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0437\u0430\u0434\u0430\u0447 \u0431\u044b\u043b\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 PostgreSQL. \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0411\u0414? \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043c\u043e\u0442\u0440\u044f\u0442 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u043a\u0430\u043a\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u043c\u0430\u043b\u043e\u0439 \u043a\u0440\u043e\u0432\u044c\u044e \u043d\u0435 \u0432\u044b\u0448\u043b\u043e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f\u0442 \u043a \u043d\u0430\u0440\u0430\u0449\u0438\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0432\u044b\u043d\u043e\u0441\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u0438\u0441\u043a, \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044e \u0442\u0430\u0431\u043b\u0438\u0446 \u043d\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0438 \u043a \u0432\u0441\u044f\u043a\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0443 \u0438 \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438. \u0418 \u0432\u043e\u0442 \u0443\u0436\u0435 \u0432\u0441\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e, \u043d\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0442\u0435\u043b\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435? \u0413\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0448\u0430\u0440\u0434\u0438\u043d\u0433 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/fa9\/f33\/091\/fa9f330913c0462c8f576393f4135ec6.jpg\"\/><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0425\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u043d\u0430 \u0421\u0423\u0411\u0414 Postgres-XL.<\/p>\n<p>  <b>Postgres-XL<\/b> \u2014 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u0432 PostgreSQL \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431 \u043e\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043a\u0430\u043a \u043e\u0434\u0438\u043d \u0438\u043d\u0441\u0442\u0430\u043d\u0441 \u0411\u0414. \u0414\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0435, \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u044b, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043d \u0441 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0430\u043d\u0441\u043e\u043c PostgreSQL \u0438\u043b\u0438 \u0441 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u043e\u043c Postgres-XL. Postgres-XL \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 2 \u0440\u0435\u0436\u0438\u043c\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u043e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0443: \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0438 \u0448\u0430\u0440\u0434\u0438\u043d\u0433. \u041f\u0440\u0438 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438 \u0432\u0441\u0435 \u0443\u0437\u043b\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0443\u044e \u043a\u043e\u043f\u0438\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0430 \u043f\u0440\u0438 \u0448\u0430\u0440\u0434\u0438\u043d\u0433\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0440\u0435\u0434\u0438 \u0447\u043b\u0435\u043d\u043e\u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u0422\u0435\u043a\u0443\u0449\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 PostgreSQL-9.2. \u0422\u0430\u043a \u0447\u0442\u043e \u0432\u0430\u043c \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0444\u0438\u0447\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 9.2.<\/p>\n<h4>\u0422\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044f<\/h4>\n<p>  Postgres-XL \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0442\u0440\u0435\u0445 \u0442\u0438\u043f\u043e\u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432: \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u043d\u0438\u0442\u043e\u0440 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0439 (<abbr title=\"Global Transaction Manager\">GTM<\/abbr>), \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440 (coordinator) \u0438 \u0443\u0437\u0435\u043b \u0434\u0430\u043d\u043d\u044b\u0445 (datanode).<\/p>\n<p>  <abbr title=\"Global Transaction Manager\"><b>GTM<\/b><\/abbr> \u2014 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 ACID. \u041e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u0435\u043d \u0437\u0430 \u0432\u044b\u0434\u0430\u0447\u0443 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432. \u0422\u0430\u043a \u043a\u0430\u043a \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u043e\u0442\u043a\u0430\u0437\u0430, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043f\u0438\u0440\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e GTM Standby. \u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f GTM \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u0438\u0434\u0435\u0435\u0439. \u0414\u043b\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u043e\u0442 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u0443\u0437\u043b\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c GTM-Proxy. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043d\u0430 GTM \u0442\u0430\u043a \u043a\u0430\u043a \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441 \u043d\u0438\u043c.<\/p>\n<p>  <b>\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440<\/b> \u2014 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u0418\u043c\u0435\u043d\u043d\u043e \u0441 \u043d\u0438\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0423\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c\u0438 \u0441\u0435\u0441\u0441\u0438\u044f\u043c\u0438 \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 GTM \u0438 \u0443\u0437\u043b\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0430\u0440\u0441\u0438\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0441\u0442\u0440\u043e\u0438\u0442 \u043f\u043b\u0430\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u043e\u0442\u0441\u044b\u043b\u0430\u0435\u0442 \u0435\u0433\u043e \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0438 \u043e\u0442\u0441\u044b\u043b\u0430\u0435\u0442 \u0438\u0445 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440 \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u043d \u0445\u0440\u0430\u043d\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043a\u0430\u043a \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0443\u0437\u043b\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u0441\u0442\u0440\u043e\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439. <\/p>\n<p>  <b>\u0423\u0437\u0435\u043b \u0434\u0430\u043d\u043d\u044b\u0445<\/b> \u2014 \u043c\u0435\u0441\u0442\u043e \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u044b. \u0421\u0432\u044f\u0437\u044c \u0441 \u0443\u0437\u043b\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440\u044b. \u0414\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043f\u0435\u0440\u0435\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0443\u0437\u043b\u043e\u0432 stanby \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/53f\/a77\/c46\/53fa77c4683c4f08837eeb944a84ff56.jpg\"\/><\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/www.pgpool.net\">pgpool-II<\/a>. \u041e \u0435\u0433\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0443\u0436\u0435 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u0445\u0430\u0431\u0440\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <a href=\"http:\/\/habrahabr.ru\/post\/188096\/\">\u0442\u0443\u0442<\/a> \u0438 <a href=\"http:\/\/habrahabr.ru\/post\/213409\/\">\u0442\u0443\u0442<\/a> \u0425\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440\u0430 \u0438 \u0443\u0437\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0431\u043e\u0442\u0438\u0442\u044c\u0441\u044f \u043e \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 \u0431\u0435\u0437 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e \u0441\u0435\u0442\u0438.<\/p>\n<h4>\u0421\u0445\u0435\u043c\u0430 \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430<\/h4>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/4ae\/376\/a10\/4ae376a10a144adb84408975d5201861.png\"\/><\/p>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0443\u0437\u0435\u043b \u044d\u0442\u043e \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u0430\u0448\u0438\u043d\u0430 \u0441\u043e \u0441\u043a\u0440\u043e\u043c\u043d\u044b\u043c \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u044b\u043c \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u0435\u043c: MemTotal: 501284 kB, cpu MHz: 2604.<\/p>\n<h4>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/h4>\n<p>  \u0422\u0443\u0442 \u0432\u0441\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e: \u043a\u0430\u0447\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0441 <a href=\"http:\/\/www.postgres-xl.org\/download\/\">\u043e\u0444\u0441\u0430\u0439\u0442\u0430<\/a>, \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c. \u0421\u043e\u0431\u0438\u0440\u0430\u043b \u043d\u0430 Ubuntu server 14.10.<\/p>\n<pre><code class=\"bash\">$ sudo apt-get install flex bison docbook-dsssl jade iso8879 docbook libreadline-dev zlib1g-dev $ .\/configure --prefix=\/home\/${USER}\/Develop\/utils\/postgres-xl --disable-rpath $ make world <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043f\u0430\u043a\u0435\u0442 \u0441\u043e\u0431\u0440\u0430\u043d \u0437\u0430\u043b\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u0443\u0437\u043b\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 GTM<\/h4>\n<p>  \u0414\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u043a\u0430\u0437\u043e\u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 \u0434\u0432\u0443\u0445 GTM \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432. \u041d\u0430 \u043e\u0431\u043e\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0434\u043b\u044f GTM \u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e.<\/p>\n<pre><code class=\"bash\">$ mkdir ~\/gtm $ initgtm -Z gtm -D ~\/gtm\/ <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u043e\u0432:<\/p>\n<p>  <b>gtm1<\/b>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">gtm.conf<\/b><\/p>\n<div class=\"spoiler_text\">\u2026<br \/>  nodename = &#8216;gtm_master&#8217; <br \/>  listen_addresses = &#8216;*&#8217;<br \/>  port = 6666<br \/>  startup = ACT<br \/>  log_file = &#8216;gtm.log&#8217;<br \/>  \u2026  <\/div>\n<\/div>\n<p>  <b>gtm2<\/b>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">gtm.conf<\/b><\/p>\n<div class=\"spoiler_text\">\u2026<br \/>  nodename = &#8216;gtm_slave&#8217; <br \/>  listen_addresses = &#8216;*&#8217; <br \/>  port = 6666<br \/>  startup = STANDBY<br \/>  active_host = &#8216;gtm1&#8217;<br \/>  active_port = 6666<br \/>  log_file = &#8216;gtm.log&#8217;<br \/>  \u2026  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c, \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u043c:<\/p>\n<pre><code class=\"bash\">$ gtm_ctl start -Z gtm -D ~\/gtm\/ <\/code><\/pre>\n<p>  \u0412 \u043b\u043e\u0433\u0430\u0445 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0438:<br \/>  <i>LOG: Started to run as GTM-Active.<br \/>  LOG: Started to run as GTM-Standby.<\/i><\/p>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 GTM-Proxy<\/h4>\n<p>  <\/p>\n<pre><code class=\"bash\">$ mkdir gtm_proxy $ initgtm -Z gtm_proxy -D ~\/gtm_proxy\/ $ nano gtm_proxy\/gtm_proxy.conf  <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">gtm_proxy.conf<\/b><\/p>\n<div class=\"spoiler_text\">\u2026<br \/>  nodename = &#8216;gtmproxy1&#8217; # \u0438\u043c\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e<br \/>  listen_addresses = &#8216;*&#8217;<br \/>  port = 6666<br \/>  gtm_host = &#8216;gtm1&#8217; #\u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c ip \u0438\u043b\u0438 \u0438\u043c\u044f \u0445\u043e\u0441\u0442\u0430 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442 GTM \u043c\u0430\u0441\u0442\u0435\u0440<br \/>  gtm_port = 6666<br \/>  log_file = &#8216;gtm_proxy.log&#8217;<br \/>  \u2026  <\/div>\n<\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u0430\u0432\u043a\u0438 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c:<\/p>\n<pre><code class=\"bash\">$ gtm_ctl start -Z gtm_proxy -D ~\/gtm_proxy\/ <\/code><\/pre>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440\u043e\u0432<\/h4>\n<p>  <\/p>\n<pre><code class=\"bash\">$ mkdir coordinator $ initdb -D ~\/coordinator\/ -E UTF8 --locale=C -U postgres -W --nodename coordinator1 $ nano ~\/coordinator\/postgresql.conf <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">coordinator\/postgresql.conf<\/b><\/p>\n<div class=\"spoiler_text\">\u2026<br \/>  listen_addresses = &#8216;*&#8217;<br \/>  port = 15432<br \/>  pooler_port = 16667<br \/>  gtm_host = &#8216;127.0.0.1&#8217;<br \/>  pgxc_node_name = &#8216;coordinator1&#8217;<br \/>  \u2026  <\/div>\n<\/div>\n<p>  <\/p>\n<h4>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0443\u0437\u043b\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>  <\/p>\n<pre><code class=\"bash\">$ mkdir ~\/datanode $ initdb -D ~\/datanode\/ -E UTF8 --locale=C -U postgres -W --nodename datanode1 $ nano ~\/datanode\/postgresql.conf  <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">datanode\/postgresql.conf<\/b><\/p>\n<div class=\"spoiler_text\">\u2026<br \/>  listen_addresses = &#8216;*&#8217; <br \/>  port = 25432 <br \/>  pooler_port = 26667<br \/>  gtm_host = &#8216;127.0.0.1&#8217; <br \/>  pgxc_node_name = &#8216;datanode1&#8217;<br \/>  \u2026  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0437\u043b\u043e\u0432 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0430\u0432\u0438\u043c pg_hba.conf:<\/p>\n<pre><code class=\"bash\">echo &quot;host all all 192.168.1.0\/24 trust&quot; &gt;&gt; ~\/datanode\/pg_hba.conf echo &quot;host all all 192.168.1.0\/24 trust&quot; &gt;&gt; ~\/coordinator\/pg_hba.conf <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0417\u0430\u043f\u0443\u0441\u043a \u0438 \u0434\u043e\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430<\/h4>\n<p>  \u0412\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e \u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c.<\/p>\n<pre><code class=\"bash\">$ pg_ctl start -Z datanode -D ~\/datanode\/ -l ~\/datanode\/datanode.log $ pg_ctl start -Z coordinator -D ~\/coordinator\/ -l ~\/coordinator\/coordinator.log <\/code><\/pre>\n<p>  \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440:<\/p>\n<pre><code class=\"bash\">psql -p15432 <\/code><\/pre>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"sql\">select * from pgxc_node; <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043a\u0430\u043a \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u0438\u0434\u0438\u0442 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0442\u0435\u0440.<br \/>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430:<\/p>\n<pre><code class=\"sql\"> node_name   | node_type | node_port | node_host | nodeis_primary | nodeis_preferred |  node_id    -------------+-----------+-----------+-----------+----------------+------------------+------------ coordinator1 | C         |    5432   | localhost | f              | f                | 1938253334 <\/code><\/pre>\n<p>  \u042d\u0442\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043d\u0435\u0432\u0435\u0440\u043d\u044b \u0438 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u0435\u043b\u043e \u0443\u0434\u0430\u043b\u044f\u0442\u044c.<\/p>\n<pre><code class=\"sql\">delete from pgxc_node;  <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430:<\/p>\n<pre><code class=\"sql\">create node coordinator1 with (type=coordinator, host='192.168.1.151', port=15432); create node coordinator2 with (type=coordinator, host='192.168.1.152', port=15432); create node coordinator3 with (type=coordinator, host='192.168.1.161', port=15432); create node datanode1 with (type=datanode, host='192.168.1.151', primary=true, port=25432); create node datanode2 with (type=datanode, host='192.168.1.152', primary=false, port=25432); create node datanode3 with (type=datanode, host='192.168.1.161', primary=false, port=25432); SELECT pgxc_pool_reload(); select * from pgxc_node;   node_name   | node_type | node_port |   node_host   | nodeis_primary | nodeis_preferred |   node_id    --------------+-----------+-----------+---------------+----------------+------------------+-------------  datanode1    | D         |     25432 | 192.168.1.151 | t              | f                |   888802358  coordinator1 | C         |     15432 | 192.168.1.151 | f              | f                |  1938253334  coordinator2 | C         |     15432 | 192.168.1.152 | f              | f                | -2089598990  coordinator3 | C         |     15432 | 192.168.1.161 | f              | f                | -1483147149  datanode2    | D         |     25432 | 192.168.1.152 | f              | f                |  -905831925  datanode3    | D         |     25432 | 192.168.1.161 | f              | f                | -1894792127 <\/code><\/pre>\n<p>  \u041d\u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0437\u043b\u0430\u0445 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435. <br \/>  \u0423\u0437\u0435\u043b \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043d\u043e \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c:<\/p>\n<pre><code class=\"bash\">psql -p 25432 -c &quot;alter node datanode1 WITH ( TYPE=datanode, HOST ='192.168.1.151', PORT=25432, PRIMARY=true);&quot; <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<pre><code class=\"sql\">CREATE TABLE test1 ( id bigint NOT NULL, profile bigint NOT NULL,   status integer NOT NULL, switch_date timestamp without time zone NOT NULL, CONSTRAINT test1_id_pkey PRIMARY KEY (id) ) to node (datanode1, datanode2);  CREATE TABLE test2 ( id bigint NOT NULL, profile bigint NOT NULL,   status integer NOT NULL, switch_date timestamp without time zone NOT NULL, CONSTRAINT test2_id_pkey PRIMARY KEY (id) ) distribute by REPLICATION;  CREATE TABLE test3 ( id bigint NOT NULL, profile bigint NOT NULL,   status integer NOT NULL, switch_date timestamp without time zone NOT NULL, CONSTRAINT test3_id_pkey PRIMARY KEY (id) )  distribute by HASH(id);  CREATE TABLE test4 ( id bigint NOT NULL,  profile bigint NOT NULL,   status integer NOT NULL,  switch_date timestamp without time zone NOT NULL  ) distribute by MODULO(status); <\/code><\/pre>\n<p>  \u0411\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043e 4 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439, \u043d\u043e \u0440\u0430\u0437\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0443. <\/p>\n<p>  \u0414\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <i>test1<\/i> \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 2\u0445 \u0443\u0437\u043b\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 <i>datanode1<\/i> \u0438 <i>datanode2<\/i>, \u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 roundrobin. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u0441\u0435 \u0443\u0437\u043b\u044b. \u0422\u0430\u0431\u043b\u0438\u0446\u0430 <i>test2<\/i> \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u0438. \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0430 \u043a\u0430\u043a\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <i>test3<\/i> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e \u043f\u043e\u043b\u044e <i>id<\/i>, \u0430 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f <i>test4<\/i> \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c \u043f\u043e \u043f\u043e\u043b\u044e <i>status<\/i>. \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0438\u0445:<\/p>\n<pre><code class=\"sql\">insert into test1 (id, profile, status, switch_date) select a, round(random()*10000), round(random()*4), now() - '1 year'::interval * round(random() * 40) from generate_series(1,10) a; insert into test2 (id , profile,status, switch_date) select a, round(random()*10000), round(random()*4), now() - '1 year'::interval * round(random() * 40) from generate_series(1,10) a; insert into test3 (id , profile,status, switch_date) select a, round(random()*10000), round(random()*4), now() - '1 year'::interval * round(random() * 40) from generate_series(1,10) a; insert into test4 (id , profile,status, switch_date) select a, round(random()*10000), round(random()*4), now() - '1 year'::interval * round(random() * 40) from generate_series(1,10) a; <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441\u0438\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a<\/p>\n<pre><code class=\"sql\">explain analyze select count(*) from test1;                                                                QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------  Aggregate  (cost=27.50..27.51 rows=1 width=0) (actual time=0.649..0.649 rows=1 loops=1)    -&gt;  Remote Subquery Scan on all (datanode1,datanode2)  (cost=0.00..24.00 rows=1400 width=0) (actual time=0.248..0.635 rows=2 loops=1)  Total runtime: 3.177 ms  explain analyze select count(*) from test2;                                                                QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------  Remote Subquery Scan on all (datanode2)  (cost=27.50..27.51 rows=1 width=0) (actual time=0.711..0.711 rows=1 loops=1)  Total runtime: 2.833 ms  explain analyze select count(*) from test3;                                                                QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------  Aggregate  (cost=27.50..27.51 rows=1 width=0) (actual time=1.453..1.453 rows=1 loops=1)    -&gt;  Remote Subquery Scan on all (datanode1,datanode2,datanode3)  (cost=0.00..24.00 rows=1400 width=0) (actual time=0.465..1.430 rows=3 loops=1)  Total runtime: 3.014 ms <\/code><\/pre>\n<p>  \u041f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043d\u0430\u043c \u043e \u0442\u043e\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0437\u043b\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435. \u0422\u0430\u043a \u043a\u0430\u043a <i>table2<\/i> \u0440\u0435\u043f\u043b\u0438\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0432\u0441\u0435 \u0443\u0437\u043b\u044b, \u0442\u043e \u043f\u0440\u043e\u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e 1 \u0443\u0437\u0435\u043b. \u041a\u0441\u0442\u0430\u0442\u0438 \u043d\u0435\u044f\u0441\u043d\u043e \u043f\u043e \u043a\u0430\u043a\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0435 \u043e\u043d \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f. \u041b\u043e\u0433\u0438\u0447\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b, \u0447\u0442\u043e\u0431 \u043e\u043d \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u043b \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0442\u043e\u0433\u043e \u0436\u0435 \u0443\u0437\u043b\u0430 \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u043e\u0440.<\/p>\n<p>  \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0432\u0448\u0438\u0441\u044c \u043a \u0443\u0437\u043b\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043d\u0430 \u043f\u043e\u0440\u0442 25432) \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043a\u0430\u043a \u0431\u044b\u043b\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043e\u0431\u044a\u0435\u043c\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441\u043e standalone PostgreSQL.<\/p>\n<pre><code class=\"sql\">insert into test3 (id , profile,status, switch_date) select a, round(random()*10000), round(random()*4), now() - '1 year'::interval * round(random() * 40) from generate_series(1,1000000) a; <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435 Postgres-XL:<\/p>\n<pre><code class=\"sql\">explain analyze  select  profile, count(status) from test3                         where status&lt;&gt;2                          and switch_date between '1970-01-01' and '2015-01-01'  group by profile;                                                                QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------  HashAggregate  (cost=34.53..34.54 rows=1 width=12) (actual time=266.319..268.246 rows=10001 loops=1)    -&gt;  Remote Subquery Scan on all (datanode1,datanode2,datanode3)  (cost=0.00..34.50 rows=7 width=12) (actual time=172.894..217.644 rows=30003 loops=1)  Total runtime: 276.690 ms <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0441 PostgreSQL:<\/p>\n<pre><code class=\"sql\">explain analyze  select  profile, count(status) from test                         where status&lt;&gt;2                         and switch_date between '1970-01-01' and '2015-01-01'  group by profile;                                                                QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------  HashAggregate  (cost=28556.44..28630.53 rows=7409 width=12) (actual time=598.448..600.495 rows=10001 loops=1)    -&gt;  Seq Scan on test  (cost=0.00..24853.00 rows=740688 width=12) (actual time=0.418..329.145 rows=740579 loops=1)          Filter: ((status &lt;&gt; 2) AND (switch_date &gt;= '1970-01-01 00:00:00'::timestamp without time zone) AND (switch_date &lt;= '2015-01-01 00:00:00'::timestamp without time zone))          Rows Removed by Filter: 259421  Total runtime: 601.572 ms <\/code><\/pre>\n<p>  \u041d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c \u0434\u0432\u0443\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438. \u041d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043f\u043b\u043e\u0445\u043e, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432 \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043c\u0430\u0448\u0438\u043d, \u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u043e.<\/p>\n<p>  P.S. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0441\u0442 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c. \u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442\u0441\u044f! \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/253017\/\"> http:\/\/habrahabr.ru\/post\/253017\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> \t\t\t\u0422\u0430\u043a \u0443\u0436 \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c. \u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0437\u0430\u0434\u0430\u0447 \u0431\u044b\u043b\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 PostgreSQL. \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0411\u0414? \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0441\u043c\u043e\u0442\u0440\u044f\u0442 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u043a\u0430\u043a\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c. \u0415\u0441\u043b\u0438 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u043c\u0430\u043b\u043e\u0439 \u043a\u0440\u043e\u0432\u044c\u044e \u043d\u0435 \u0432\u044b\u0448\u043b\u043e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044f\u0442 \u043a \u043d\u0430\u0440\u0430\u0449\u0438\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0432\u044b\u043d\u043e\u0441\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 \u0436\u0443\u0440\u043d\u0430\u043b\u0430 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u0438\u0441\u043a, \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044e \u0442\u0430\u0431\u043b\u0438\u0446 \u043d\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0438 \u043a \u0432\u0441\u044f\u043a\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0443 \u0438 \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0434\u0435\u043b\u0438. \u0418 \u0432\u043e\u0442 \u0443\u0436\u0435 \u0432\u0441\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043e, \u043d\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u0442\u0435\u043b\u043e\u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435? \u0413\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0448\u0430\u0440\u0434\u0438\u043d\u0433 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/fa9\/f33\/091\/fa9f330913c0462c8f576393f4135ec6.jpg\"\/>  <\/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-253035","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253035","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=253035"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253035\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=253035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=253035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=253035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}