{"id":354712,"date":"2024-05-20T22:53:49","date_gmt":"2024-05-20T22:53:49","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=354712"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=354712","title":{"rendered":"<span>\u0412\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u2026 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439??<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u0432\u0435\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c many-to-many \u0432 Postgres \u0432 \u0442\u0443\u043f\u0438\u043a, \u043a\u0430\u043a \u044d\u0442\u043e \u0437\u043b\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0432\u0435\u0440\u0436\u0435\u043d\u043e, \u0438 \u043a\u0430\u043a \u0442\u0443\u0442 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433 Clickhouse.<\/p>\n<p>\u041f\u043e\u0440\u043e\u0439 \u0431\u044b\u0432\u0430\u044e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0443 \u0431\u0443\u0434\u0442\u043e \u0441 \u043d\u0443\u043b\u044f \u0438 \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043e\u043f\u044b\u0442 \u0438 best practices. \u041f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432 \u0432\u043f\u0435\u0440\u0451\u0434. \u0418 \u043b\u0443\u0447\u0448\u0435 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u043e\u0433\u0434\u0430 \u0443\u0436\u0435 \u0432\u044b\u0448\u043b\u0438 \u0438\u0437 SLA \u0438\u043b\u0438 \u043d\u0430\u0445\u0432\u0430\u0442\u0430\u043b\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u0430 \u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0431\u0438\u0437\u043d\u0435\u0441\u0430. \u041e\u0431 \u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u044c\u043d\u043e \u0440\u0435\u0434\u0438\u0437\u0430\u0439\u043d\u0438\u0442\u044c, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u043e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c: \u044f &#8212; \u043f\u0440\u0438\u0432\u0435\u0440\u0436\u0435\u043d\u0435\u0446 \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041b\u0443\u0447\u0448\u0438\u0439 \u043a\u043e\u0434 &#8212; \u044d\u0442\u043e \u0435\u0433\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435. \u041b\u0443\u0447\u0448\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 &#8212; \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u043c\u043e\u0435 \u043c\u0430\u043d\u0443\u0430\u043b\u043e\u043c. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0451 \u0443\u0436\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d\u043e \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u043e, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. <\/p>\n<p>\u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \u0434\u043b\u044f Symfony-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u0441\u0445\u0435\u043c\u044b \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e maker-\u0431\u0430\u043d\u0434\u043b\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u044f \u0441\u0432\u044f\u0437\u0438?<\/p>\n<p>\u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 <s>\u0436\u0438\u0437\u043d\u044c<\/s> \u0440\u0430\u0431\u043e\u0442\u0430 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0438\u043c \u0443\u0433\u043b\u043e\u043c \u043d\u0430 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u0432\u0435\u0449\u0438.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f: \u0435\u0441\u0442\u044c \u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 &#8212; \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0442\u0435\u0433\u0430\u043c\u0438 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>merchant: someMerhcant, <br \/>provider: somePrivider, <br \/>customer: someCustomer<br \/>card: someCardToken,<br \/>country: RUS<\/p>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u043c\u0435\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043b\u0438\u043c\u0438\u0442\u044b \u0432 \u043b\u044e\u0431\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u0441\u0443\u043c\u043c\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0431\u043e\u043b\u0435\u0435 5\u043c\u043b\u043d.\u0440\u0443\u0431 \u043f\u043e someProvider \u0432 \u043c\u0435\u0441\u044f\u0446,<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a\u0430 \u0443 someMerchant \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 10 \u0432 \u0434\u0435\u043d\u044c,<\/p>\n<\/li>\n<li>\n<p>\u0441\u0443\u043c\u043c\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e someCardToken \u0438\u0437\u0432\u043d\u0435 \u0420\u043e\u0441\u0441\u0438\u0438 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 500\u0442\u044b\u0441.\u0440. \u0432 \u043d\u0435\u0434\u0435\u043b\u044e \u043f\u043e anotherMerchant,<\/p>\n<\/li>\n<li>\n<p>\u0438 \u0442.\u043f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0442\u0435\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439: PHP + Symfony\/Doctrine. \u041d\u0430 \u043d\u0451\u043c \u0441\u0445\u0435\u043c\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0442\u0430\u043a\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 \u043c\u043d\u043e\u0433\u043e-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/df4\/7c4\/ce3\/df47c4ce3c375d01e12e97b1de84d4f0.jpg\" width=\"1382\" height=\"293\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/df4\/7c4\/ce3\/df47c4ce3c375d01e12e97b1de84d4f0.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0418 \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 Symfony:<\/p>\n<pre><code class=\"php\">\/**  * @ORM\\Table(name=\"operation\")  * @ORM\\Entity()  *\/ class Operation {     \/\/ ......      \/**      * @var ArrayCollection|Tag[]      *      * @ORM\\ManyToMany(targetEntity=\"Tag\")      * @ORM\\JoinTable(      *     name=\"operation_tag\",      *     joinColumns={@ORM\\JoinColumn(name=\"operation_id\", referencedColumnName=\"operation_id\")},      *     inverseJoinColumns={@ORM\\JoinColumn(name=\"tag_id\", referencedColumnName=\"tag_id\")}      * )      *\/     private $tags;      \/\/ ...... }   \/**  * @ORM\\Table(name=\"tag\")  * @ORM\\Entity()  *\/ class Tag {     \/**      * @ORM\\Column(name=\"tag_id\", type=\"bigint\", nullable=false)      * @ORM\\Id      * ...      *\/     private int $tagId;      \/**      * @ORM\\Column(name=\"name\", type=\"string\", length=255, nullable=false)      *\/     private string $name;      \/**      * @ORM\\Column(name=\"value\", type=\"string\", length=255, nullable=false)      *\/     private string $value;      \/\/ ... } <\/code><\/pre>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0442\u0435\u0433\u0438 &#8212; \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0430 \u043f\u0430\u0440\u0430 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u043b\u0438\u043c\u0438\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443 someProvider \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a\u0430 \u0443 someMerchant \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">-- \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u043b\u0438\u043c\u0438\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f someProvider \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a\u0430 \u0443 someMerchant   SELECT     SUM(o.amount) FROM     operation o INNER JOIN     operation_tag ot1 ON ot1.operation_id = o.operation_id INNER JOIN     tags t1 ON ot1.tag_id = t1.tag_id INNER JOIN     operation_tag ot2 ON ot2.operation_id = o.operation_id INNER JOIN     tags t2 ON ot2.tag_id = t2.tag_id INNER JOIN     operation_tag ot3 ON ot3.operation_id = o.operation_id INNER JOIN     tags t3 ON ot3.tag_id = t3.tag_id WHERE     t1.name = 'provider'     AND t1.value = 'someProvider'     AND t2.name = 'merchant'     AND t2.value = 'someMerchant'     AND t3.name = 'customer_id'     AND t3.value = 'someUniqueCustomerId';     AND o.created_at BETWEEN '2023-08-01' AND '2023-08-31'<\/code><\/pre>\n<p>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: ~1.5 \u0441\u0435\u043a. <\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0432 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0435 3, \u0430 4 \u0442\u0435\u0433\u0430, \u0442\u043e \u0434\u0436\u043e\u0439\u043d\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e 8, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043d\u0435\u0442\u0440\u0443\u0434\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0438 \u043f\u0440\u043e \u043a\u0430\u043a\u0438\u0435 SLA \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0431\u044b\u043b\u0438 \u0443\u0431\u0435\u0436\u0434\u0435\u043d\u044b, \u0447\u0442\u043e \u0443\u043f\u0451\u0440\u043b\u0438\u0441\u044c \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u0430\u043c\u043e\u0433\u043e Postgres, \u0438 \u043f\u043e\u0441\u043b\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u0438\u0437\u044b\u0441\u043a\u0430\u043d\u0438\u0439 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0447\u0442\u043e-\u0442\u043e \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0435, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0441\u0442\u0443\u0449\u0435\u0433\u043e \u043e\u0431\u044a\u0451\u043c \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u0432\u044b\u0431\u043e\u0440\u0430 \u0431\u044b\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 SQL \u0438\u043b\u0438 \u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0431\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442.\u043a. \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043b\u044c\u0432\u0438\u043d\u0443\u044e \u0434\u043e\u043b\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0434\u043b\u044f php.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0434\u043e\u0440\u043e\u0433\u0430\u044f \u0446\u0435\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u0432\u0438\u0442\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e \u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>Nosql-\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043e\u0442\u043f\u0430\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442\u0435 1, Oracle \u043d\u0435 \u043f\u043e\u0434\u043e\u0448\u0451\u043b \u043f\u043e \u043f\u0443\u043d\u043a\u0442\u0430\u043c 4 \u0438 5. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 Clickhouse. \u041e\u043d \u0441\u043b\u0430\u0432\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0451\u043c\u0430\u0445, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439, \u0434\u0430 \u0438 \u0432\u0435\u043d\u0434\u043e\u0440 \u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u043e\u0432\u0435\u0440\u0438\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0440\u0435\u0448\u0435\u043d\u043e. <\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 Clickhouse \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 MySQL:<\/p>\n<pre><code class=\"sql\">CREATE TABLE IF NOT EXISTS ourdb.operation (     ...     amount UInt64,     tags Nested (         name String,         value String     ) )<\/code><\/pre>\n<p>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u041a\u043b\u0438\u043a\u0445\u0430\u0443\u0441\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u0441\u0438\u043b\u0451\u043d \u0432 \u0434\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0424\u0442\u043e\u043f\u043a\u0443 \u0434\u0436\u043e\u0439\u043d\u044b!<br \/>\u0415\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0442\u0438\u043f Nested, \u0433\u0434\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0446\u0435\u043b\u0438\u043a\u043e\u043c. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0432\u043e\u0451 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0433\u043e\u0432 \u043a\u043b\u044e\u0447 : \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0418 \u0442\u043e\u0433\u0434\u0430 \u0432 Clickhouse \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0435\u0439 \u0441\u0443\u043c\u043c\u044b \u0441\u0442\u0430\u043b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">SELECT SUM(amount) AS result FROM operation WHERE created_at >= '2023-08-01 00:00:00' AND created_at &lt;= '2023-08-31 23:59:59'  AND tags.value[indexOf(tags.name, 'provider')] = 'someProvider'  AND tags.value[indexOf(tags.name, 'merchant')] = 'someMerchant'  AND tags.value[indexOf(tags.name, 'customer_id')] = 'someUniqueCustomerId'<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441&#8230; \u0438&#8230; \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: 0.4\u0441\u0435\u043a! \u041f\u0440\u0438\u0447\u0435\u043c \u0441 \u043b\u044e\u0431\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0442\u0435\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438 many-to-many \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0438\u0441\u044c \u0431\u044b \u0432 \u0441\u043c\u0435\u0440\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0436\u043e\u0439\u043d\u044b.<\/p>\n<p>\u0417\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041d\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043c \u041a\u043b\u0438\u043a\u0445\u0430\u0443\u0441 \u043f\u0440\u0438\u0432\u043d\u0451\u0441 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043e\u043d \u0445\u043e\u0440\u043e\u0448 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u043d\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438, \u0438 \u0435\u0441\u0442\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0447\u043a\u0430\u043c\u0438 \u043e\u0442 1000 \u0441\u0442\u0440\u043e\u043a. \u041c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0435\u044e \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0447\u044c, \u043d\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c. \u041c\u043e\u0436\u043d\u043e \u0438 \u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u043f\u0430\u0447\u043a\u0430, \u043d\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u043e\u0432\u0440\u0435\u043c\u044f \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e, \u043f\u043e\u0432\u043b\u0435\u0447\u044c race condition \u0438 \u0442.\u0434. \u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 &#8212; \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0430\u043c\u0443\u044e \u0441\u0432\u0435\u0436\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c (\u0441\u043a\u0430\u0436\u0435\u043c, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0447\u0430\u0441) \u0432 Postgre, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u044a\u0451\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432 Clickhouse, \u0438 \u0437\u0430\u0442\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c. \u042d\u0444\u0444\u0435\u043a\u0442 \u0431\u044b\u043b, \u043d\u043e \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u044d\u0442\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e, \u0432\u0435\u0434\u044c \u0434\u043e\u0440\u043e\u0433\u0438\u0435 \u0434\u0436\u043e\u0439\u043d\u044b Postgres \u0434\u0430\u0436\u0435 \u043d\u0430 \u043c\u0430\u043b\u043e\u043c \u043e\u0431\u044a\u0451\u043c\u0435 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u0440\u043e\u0433\u0438\u043c\u0438 \u0434\u0436\u043e\u0439\u043d\u0430\u043c\u0438.<\/p>\n<p>\u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0430\u043c\u043e\u043c Postgres? \u041e\u043d \u0436\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 json. \u0421\u043a\u0430\u0437\u0430\u043d\u043e &#8212; \u0441\u0434\u0435\u043b\u0430\u043d\u043e.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u043e\u043b\u0431\u0435\u0446 tags_nested \u0442\u0438\u043f\u0430 jsonb, \u0430 \u0442\u0430\u043a\u0436\u0435 GIN-\u0438\u043d\u0434\u0435\u043a\u0441. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0438\u0441\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u043f\u043b\u043e\u0441\u043a\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438, \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 GIST-\u0438\u043d\u0434\u0435\u043a\u0441.<\/p>\n<pre><code class=\"sql\">ALTER TABLE operation     ADD tags_nested JSONB DEFAULT '{}' NOT NULL;  CREATE INDEX ix_operation_tags_nested ON operation     USING gin(tags_nested jsonb_path_ops);<\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c:<\/p>\n<pre><code class=\"sql\">SELECT     SUM(o.amount) FROM     operation o WHERE     o.tags_nested::jsonb @> '[{\"provider\":\"someProvider\"},{\"merchant\":\"someMerchant\"},{\"customer_id\":\"someUniqueCustomerId\"}]'     AND o.created_at BETWEEN '2023-08-01' AND '2023-08-31' <\/code><\/pre>\n<p>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u0433\u043e\u0432 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 0.3\u0441\u0435\u043a! \u0410 \u0447\u0442\u043e, \u0442\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e? <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 \u0432\u0441\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0435\u0433\u0438, \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 @>. <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0438 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0442\u0430\u043a\u043e\u0439 \u0441\u0445\u0435\u043c\u044b \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u0446\u0435\u043b\u043e\u043c &#8212; \u043c\u044b \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043b\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0421\u0423\u0411\u0414. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043c\u0443\u0441\u043a\u0443\u043b\u0435 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 JSON_CONTAINS(). <\/p>\n<p>\u041d\u043e \u043f\u043e\u043d\u044f\u0432, \u0447\u0442\u043e \u0431\u0430\u0437\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0441\u0435\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0438 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u043e\u0439 \u0432 \u043d\u0435\u043a\u043e\u0435\u043c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u043c \u0441\u0432\u0435\u0442\u043b\u043e\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0440\u0435\u0448\u0438\u043b\u0438, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u0441\u0442\u043e\u043f-\u0444\u0430\u043a\u0442\u043e\u0440.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/500\/99a\/511\/50099a5113554cabb9633955e80a1a91.jpg\" width=\"2130\" height=\"765\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/500\/99a\/511\/50099a5113554cabb9633955e80a1a91.jpg\" data-blurred=\"true\"\/><\/figure>\n<p><em>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/em>. Clickhouse \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u0440\u0438\u0431\u0435\u0440\u0435\u0447\u044c \u0434\u043e \u043b\u0443\u0447\u0448\u0438\u0445 \u0432\u0440\u0435\u043c\u0451\u043d, \u043a\u043e\u0433\u0434\u0430 Postgres \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438 \u043e\u0431\u044a\u0451\u043c\u0430\u043c\u0438. <\/p>\n<p>Spoiler: \u0441\u0435\u0439\u0447\u0430\u0441, \u0441\u043f\u0443\u0441\u0442\u044f 2 \u0433\u043e\u0434\u0430, \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0441\u0442\u0430\u043b\u043e, \u0447\u0442\u043e \u0438 \u043f\u043e\u0431\u0443\u0434\u0438\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043e\u043f\u044b\u0442 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435. \u041f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0430\u043a\u0442\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c Clickhouse \u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u0435\u043c \u043a \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c. \u0418 \u0445\u043e\u0440\u043e\u0448\u043e, \u0447\u0442\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 \u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u043f\u0438\u043b\u0438\u0432\u0430\u043b\u0438, \u0430 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0438. <\/p>\n<p>\u041f\u043b\u0430\u043d\u0430\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0440\u0435\u0448\u0438\u043b \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e, \u0434\u0430 \u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u044b &#8212; \u043e\u043d\u0438 c \u043a\u043e\u0441\u0442\u0430\u043c\u0438 \u0431\u044b\u043b\u0438 \u0431\u044b \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b.<\/p>\n<p>\u0412\u0441\u0435\u043c peace! \u041f\u0438\u0448\u0438\u0442\u0435, \u0443 \u043a\u043e\u0433\u043e \u0431\u044b\u043b \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043e\u043f\u044b\u0442, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438.  <\/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\/760606\/\"> https:\/\/habr.com\/ru\/articles\/760606\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u043a\u0430\u0437 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u0432\u0435\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c many-to-many \u0432 Postgres \u0432 \u0442\u0443\u043f\u0438\u043a, \u043a\u0430\u043a \u044d\u0442\u043e \u0437\u043b\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0432\u0435\u0440\u0436\u0435\u043d\u043e, \u0438 \u043a\u0430\u043a \u0442\u0443\u0442 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433 Clickhouse.<\/p>\n<p>\u041f\u043e\u0440\u043e\u0439 \u0431\u044b\u0432\u0430\u044e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0443 \u0431\u0443\u0434\u0442\u043e \u0441 \u043d\u0443\u043b\u044f \u0438 \u043e\u0442\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043e\u043f\u044b\u0442 \u0438 best practices. \u041f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0433\u043e\u0432 \u0432\u043f\u0435\u0440\u0451\u0434. \u0418 \u043b\u0443\u0447\u0448\u0435 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u043e\u0433\u0434\u0430 \u0443\u0436\u0435 \u0432\u044b\u0448\u043b\u0438 \u0438\u0437 SLA \u0438\u043b\u0438 \u043d\u0430\u0445\u0432\u0430\u0442\u0430\u043b\u0438 \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u0430 \u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0431\u0438\u0437\u043d\u0435\u0441\u0430. \u041e\u0431 \u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0431\u043e\u043b\u044c\u043d\u043e \u0440\u0435\u0434\u0438\u0437\u0430\u0439\u043d\u0438\u0442\u044c, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u043e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c: \u044f &#8212; \u043f\u0440\u0438\u0432\u0435\u0440\u0436\u0435\u043d\u0435\u0446 \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041b\u0443\u0447\u0448\u0438\u0439 \u043a\u043e\u0434 &#8212; \u044d\u0442\u043e \u0435\u0433\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435. \u041b\u0443\u0447\u0448\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 &#8212; \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u043c\u043e\u0435 \u043c\u0430\u043d\u0443\u0430\u043b\u043e\u043c. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0451 \u0443\u0436\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043d\u043e \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u043e, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c. <\/p>\n<p>\u0427\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \u0434\u043b\u044f Symfony-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0438 \u0441\u0445\u0435\u043c\u044b \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e maker-\u0431\u0430\u043d\u0434\u043b\u0430, \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u044f \u0441\u0432\u044f\u0437\u0438?<\/p>\n<p>\u041d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 <s>\u0436\u0438\u0437\u043d\u044c<\/s> \u0440\u0430\u0431\u043e\u0442\u0430 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0438\u043c \u0443\u0433\u043b\u043e\u043c \u043d\u0430 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u0432\u0435\u0449\u0438.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0437\u0430\u0434\u0430\u0447\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f: \u0435\u0441\u0442\u044c \u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 &#8212; \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0442\u0435\u0433\u0430\u043c\u0438 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>merchant: someMerhcant, <br \/>provider: somePrivider, <br \/>customer: someCustomer<br \/>card: someCardToken,<br \/>country: RUS<\/p>\n<p>\u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u043c\u0435\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043b\u0438\u043c\u0438\u0442\u044b \u0432 \u043b\u044e\u0431\u044b\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<ul>\n<li>\n<p>\u0441\u0443\u043c\u043c\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0431\u043e\u043b\u0435\u0435 5\u043c\u043b\u043d.\u0440\u0443\u0431 \u043f\u043e someProvider \u0432 \u043c\u0435\u0441\u044f\u0446,<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a\u0430 \u0443 someMerchant \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 10 \u0432 \u0434\u0435\u043d\u044c,<\/p>\n<\/li>\n<li>\n<p>\u0441\u0443\u043c\u043c\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e someCardToken \u0438\u0437\u0432\u043d\u0435 \u0420\u043e\u0441\u0441\u0438\u0438 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 500\u0442\u044b\u0441.\u0440. \u0432 \u043d\u0435\u0434\u0435\u043b\u044e \u043f\u043e anotherMerchant,<\/p>\n<\/li>\n<li>\n<p>\u0438 \u0442.\u043f.<\/p>\n<\/li>\n<\/ul>\n<p>\u0421\u0442\u0435\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439: PHP + Symfony\/Doctrine. \u041d\u0430 \u043d\u0451\u043c \u0441\u0445\u0435\u043c\u0430 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0442\u0430\u043a\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 \u043c\u043d\u043e\u0433\u043e-\u043a\u043e-\u043c\u043d\u043e\u0433\u0438\u043c:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0418 \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 Symfony:<\/p>\n<pre><code class=\"php\">\/**  * @ORM\\Table(name=\"operation\")  * @ORM\\Entity()  *\/ class Operation {     \/\/ ......      \/**      * @var ArrayCollection|Tag[]      *      * @ORM\\ManyToMany(targetEntity=\"Tag\")      * @ORM\\JoinTable(      *     name=\"operation_tag\",      *     joinColumns={@ORM\\JoinColumn(name=\"operation_id\", referencedColumnName=\"operation_id\")},      *     inverseJoinColumns={@ORM\\JoinColumn(name=\"tag_id\", referencedColumnName=\"tag_id\")}      * )      *\/     private $tags;      \/\/ ...... }   \/**  * @ORM\\Table(name=\"tag\")  * @ORM\\Entity()  *\/ class Tag {     \/**      * @ORM\\Column(name=\"tag_id\", type=\"bigint\", nullable=false)      * @ORM\\Id      * ...      *\/     private int $tagId;      \/**      * @ORM\\Column(name=\"name\", type=\"string\", length=255, nullable=false)      *\/     private string $name;      \/**      * @ORM\\Column(name=\"value\", type=\"string\", length=255, nullable=false)      *\/     private string $value;      \/\/ ... } <\/code><\/pre>\n<p>\u0421\u0445\u0435\u043c\u0430 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0442\u0435\u0433\u0438 &#8212; \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0430 \u043f\u0430\u0440\u0430 \u043a\u043b\u044e\u0447-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u043b\u0438\u043c\u0438\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443 someProvider \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a\u0430 \u0443 someMerchant \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">-- \u043f\u043e\u0434\u0441\u0447\u0451\u0442 \u043b\u0438\u043c\u0438\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f someProvider \u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u0442\u0435\u043b\u044c\u0449\u0438\u043a\u0430 \u0443 someMerchant   SELECT     SUM(o.amount) FROM     operation o INNER JOIN     operation_tag ot1 ON ot1.operation_id = o.operation_id INNER JOIN     tags t1 ON ot1.tag_id = t1.tag_id INNER JOIN     operation_tag ot2 ON ot2.operation_id = o.operation_id INNER JOIN     tags t2 ON ot2.tag_id = t2.tag_id INNER JOIN     operation_tag ot3 ON ot3.operation_id = o.operation_id INNER JOIN     tags t3 ON ot3.tag_id = t3.tag_id WHERE     t1.name = 'provider'     AND t1.value = 'someProvider'     AND t2.name = 'merchant'     AND t2.value = 'someMerchant'     AND t3.name = 'customer_id'     AND t3.value = 'someUniqueCustomerId';     AND o.created_at BETWEEN '2023-08-01' AND '2023-08-31'<\/code><\/pre>\n<p>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: ~1.5 \u0441\u0435\u043a. <\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0432 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043d\u0435 3, \u0430 4 \u0442\u0435\u0433\u0430, \u0442\u043e \u0434\u0436\u043e\u0439\u043d\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e 8, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435.<\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043d\u0435\u0442\u0440\u0443\u0434\u043d\u043e \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0431\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0438 \u043f\u0440\u043e \u043a\u0430\u043a\u0438\u0435 SLA \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0431\u044b\u043b\u0438 \u0443\u0431\u0435\u0436\u0434\u0435\u043d\u044b, \u0447\u0442\u043e \u0443\u043f\u0451\u0440\u043b\u0438\u0441\u044c \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u0430\u043c\u043e\u0433\u043e Postgres, \u0438 \u043f\u043e\u0441\u043b\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0445 \u0438\u0437\u044b\u0441\u043a\u0430\u043d\u0438\u0439 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u0447\u0442\u043e-\u0442\u043e \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0435, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0441\u0442\u0443\u0449\u0435\u0433\u043e \u043e\u0431\u044a\u0451\u043c \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u041a\u0440\u0438\u0442\u0435\u0440\u0438\u0438 \u0432\u044b\u0431\u043e\u0440\u0430 \u0431\u044b\u043b\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 SQL \u0438\u043b\u0438 \u0435\u0433\u043e \u043f\u043e\u0434\u043e\u0431\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u0442\u0440\u0430\u0433\u0438\u0432\u0430\u044f \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442.\u043a. \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043b\u044c\u0432\u0438\u043d\u0443\u044e \u0434\u043e\u043b\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0434\u043b\u044f php.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0434\u043e\u0440\u043e\u0433\u0430\u044f \u0446\u0435\u043d\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0437\u0432\u0438\u0442\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e \u0438 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u043d\u0435\u0434\u043e\u0440\u043e\u0433\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>Nosql-\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043e\u0442\u043f\u0430\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u043f\u0443\u043d\u043a\u0442\u0435 1, Oracle \u043d\u0435 \u043f\u043e\u0434\u043e\u0448\u0451\u043b \u043f\u043e \u043f\u0443\u043d\u043a\u0442\u0430\u043c 4 \u0438 5. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 Clickhouse. \u041e\u043d \u0441\u043b\u0430\u0432\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u0431\u044b\u0441\u0442\u0440\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435\u043c \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0451\u043c\u0430\u0445, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u0439, \u0434\u0430 \u0438 \u0432\u0435\u043d\u0434\u043e\u0440 \u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u043e\u0432\u0435\u0440\u0438\u0435.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0440\u0435\u0448\u0435\u043d\u043e. <\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 Clickhouse \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 MySQL:<\/p>\n<pre><code class=\"sql\">CREATE TABLE IF NOT EXISTS ourdb.operation (     ...     amount UInt64,     tags Nested (         name String,         value String     ) )<\/code><\/pre>\n<p>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u041a\u043b\u0438\u043a\u0445\u0430\u0443\u0441\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u0441\u0438\u043b\u0451\u043d \u0432 \u0434\u0435\u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0424\u0442\u043e\u043f\u043a\u0443 \u0434\u0436\u043e\u0439\u043d\u044b!<br \/>\u0415\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0442\u0438\u043f Nested, \u0433\u0434\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0446\u0435\u043b\u0438\u043a\u043e\u043c. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0432\u043e\u0451 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0442\u0435\u0433\u043e\u0432 \u043a\u043b\u044e\u0447 : \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0418 \u0442\u043e\u0433\u0434\u0430 \u0432 Clickhouse \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0435\u0439 \u0441\u0443\u043c\u043c\u044b \u0441\u0442\u0430\u043b \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"sql\">SELECT SUM(amount) AS result FROM operation WHERE created_at >= '2023-08-01 00:00:00' AND created_at &lt;= '2023-08-31 23:59:59'  AND tags.value[indexOf(tags.name, 'provider')] = 'someProvider'  AND tags.value[indexOf(tags.name, 'merchant')] = 'someMerchant'  AND tags.value[indexOf(tags.name, 'customer_id')] = 'someUniqueCustomerId'<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441&#8230; \u0438&#8230; \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f: 0.4\u0441\u0435\u043a! \u041f\u0440\u0438\u0447\u0435\u043c \u0441 \u043b\u044e\u0431\u044b\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0442\u0435\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438 many-to-many \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0438\u0441\u044c \u0431\u044b \u0432 \u0441\u043c\u0435\u0440\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0436\u043e\u0439\u043d\u044b.<\/p>\n<p>\u0417\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041d\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u043c \u041a\u043b\u0438\u043a\u0445\u0430\u0443\u0441 \u043f\u0440\u0438\u0432\u043d\u0451\u0441 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043e\u043d \u0445\u043e\u0440\u043e\u0448 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f, \u043d\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438, \u0438 \u0435\u0441\u0442\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u0447\u043a\u0430\u043c\u0438 \u043e\u0442 1000 \u0441\u0442\u0440\u043e\u043a. \u041c\u043e\u0436\u043d\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0435\u044e \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0447\u044c, \u043d\u043e \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c. \u041c\u043e\u0436\u043d\u043e \u0438 \u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0441\u044f \u0442\u0430\u043a\u0430\u044f \u043f\u0430\u0447\u043a\u0430, \u043d\u043e \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u043e\u0432\u0440\u0435\u043c\u044f \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e, \u043f\u043e\u0432\u043b\u0435\u0447\u044c race condition \u0438 \u0442.\u0434. \u041f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438 \u0433\u0438\u0431\u0440\u0438\u0434\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 &#8212; \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u0430\u043c\u0443\u044e \u0441\u0432\u0435\u0436\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c (\u0441\u043a\u0430\u0436\u0435\u043c, \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0447\u0430\u0441) \u0432 Postgre, \u0430 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u044a\u0451\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432 Clickhouse, \u0438 \u0437\u0430\u0442\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c. \u042d\u0444\u0444\u0435\u043a\u0442 \u0431\u044b\u043b, \u043d\u043e \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u044d\u0442\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e, \u0432\u0435\u0434\u044c \u0434\u043e\u0440\u043e\u0433\u0438\u0435 \u0434\u0436\u043e\u0439\u043d\u044b Postgres \u0434\u0430\u0436\u0435 \u043d\u0430 \u043c\u0430\u043b\u043e\u043c \u043e\u0431\u044a\u0451\u043c\u0435 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0434\u043e\u0440\u043e\u0433\u0438\u043c\u0438 \u0434\u0436\u043e\u0439\u043d\u0430\u043c\u0438.<\/p>\n<p>\u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0430\u043c\u043e\u043c Postgres? \u041e\u043d \u0436\u0435 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 json. \u0421\u043a\u0430\u0437\u0430\u043d\u043e &#8212; \u0441\u0434\u0435\u043b\u0430\u043d\u043e.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u043e\u043b\u0431\u0435\u0446 tags_nested \u0442\u0438\u043f\u0430 jsonb, \u0430 \u0442\u0430\u043a\u0436\u0435 GIN-\u0438\u043d\u0434\u0435\u043a\u0441. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0438\u0441\u043a \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e \u043f\u043b\u043e\u0441\u043a\u0438\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438, \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 GIST-\u0438\u043d\u0434\u0435\u043a\u0441.<\/p>\n<pre><code class=\"sql\">ALTER TABLE operation     ADD tags_nested JSONB DEFAULT '{}' NOT NULL;  CREATE INDEX ix_operation_tags_nested ON operation     USING gin(tags_nested jsonb_path_ops);<\/code><\/pre>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c:<\/p>\n<pre><code class=\"sql\">SELECT     SUM(o.amount) FROM     operation o WHERE     o.tags_nested::jsonb @> '[{\"provider\":\"someProvider\"},{\"merchant\":\"someMerchant\"},{\"customer_id\":\"someUniqueCustomerId\"}]'     AND o.created_at BETWEEN '2023-08-01' AND '2023-08-31' <\/code><\/pre>\n<p>\u0412\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u0435\u0433\u043e\u0432 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 0.3\u0441\u0435\u043a! \u0410 \u0447\u0442\u043e, \u0442\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e? <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0445 \u0432\u0441\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0442\u0435\u0433\u0438, \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 @>. <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0438 \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0442\u0430\u043a\u043e\u0439 \u0441\u0445\u0435\u043c\u044b \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432 \u0446\u0435\u043b\u043e\u043c &#8212; \u043c\u044b \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043b\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0439 \u0421\u0423\u0411\u0414. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043c\u0443\u0441\u043a\u0443\u043b\u0435 \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 JSON_CONTAINS(). <\/p>\n<p>\u041d\u043e \u043f\u043e\u043d\u044f\u0432, \u0447\u0442\u043e \u0431\u0430\u0437\u0443 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0441\u0435\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0438 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u043e\u0439 \u0432 \u043d\u0435\u043a\u043e\u0435\u043c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u043c \u0441\u0432\u0435\u0442\u043b\u043e\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0440\u0435\u0448\u0438\u043b\u0438, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u0441\u0442\u043e\u043f-\u0444\u0430\u043a\u0442\u043e\u0440.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p><em>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/em>. Clickhouse \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u0440\u0438\u0431\u0435\u0440\u0435\u0447\u044c \u0434\u043e \u043b\u0443\u0447\u0448\u0438\u0445 \u0432\u0440\u0435\u043c\u0451\u043d, \u043a\u043e\u0433\u0434\u0430 Postgres \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438 \u043e\u0431\u044a\u0451\u043c\u0430\u043c\u0438. <\/p>\n<p>Spoiler: \u0441\u0435\u0439\u0447\u0430\u0441, \u0441\u043f\u0443\u0441\u0442\u044f 2 \u0433\u043e\u0434\u0430, \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0441\u0442\u0430\u043b\u043e, \u0447\u0442\u043e \u0438 \u043f\u043e\u0431\u0443\u0434\u0438\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043e\u043f\u044b\u0442 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435. \u041f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0430\u043a\u0442\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c Clickhouse \u0438 \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u0443\u0435\u043c \u043a \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c. \u0418 \u0445\u043e\u0440\u043e\u0448\u043e, \u0447\u0442\u043e \u0438\u0437 \u043a\u043e\u0434\u0430 \u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u043f\u0438\u043b\u0438\u0432\u0430\u043b\u0438, \u0430 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u043b\u0438. <\/p>\n<p>\u041f\u043b\u0430\u043d\u0430\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0440\u0435\u0448\u0438\u043b \u043d\u0435 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e, \u0434\u0430 \u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u044b &#8212; \u043e\u043d\u0438 c \u043a\u043e\u0441\u0442\u0430\u043c\u0438 \u0431\u044b\u043b\u0438 \u0431\u044b \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b.<\/p>\n<p>\u0412\u0441\u0435\u043c peace! \u041f\u0438\u0448\u0438\u0442\u0435, \u0443 \u043a\u043e\u0433\u043e \u0431\u044b\u043b \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u043e\u043f\u044b\u0442, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e, \u0447\u0442\u043e \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438.  <\/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\/760606\/\"> https:\/\/habr.com\/ru\/articles\/760606\/<\/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-354712","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354712","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=354712"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354712\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=354712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=354712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=354712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}