{"id":501928,"date":"2026-11-06T11:50:12","date_gmt":"2026-11-06T08:50:12","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=501928"},"modified":"2026-11-06T11:50:12","modified_gmt":"2026-11-06T08:50:12","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=501928","title":{"rendered":"\u041e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441: 4\u00a0\u043c\u0441 \u0441\u00a0\u043b\u0438\u0442\u0435\u0440\u0430\u043b\u0430\u043c\u0438 \u0438 3\u00a0\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u0438\u0437\u00a0Laravel. \u041a\u0430\u043a\u00a0\u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u044b \u0432\u00a0IN \u0432\u044b\u043a\u043b\u044e\u0447\u0430\u044e\u0442 loose index scan \u0432\u00a0MySQL"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/07\/42\/7c\/07427c4b68932cbf6b0a74983909a9d0.png\" width=\"1600\" height=\"900\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/07\/42\/7c\/07427c4b68932cbf6b0a74983909a9d0.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/07\/42\/7c\/07427c4b68932cbf6b0a74983909a9d0.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u0430\u0448\u0430 \u043f\u0430\u043d\u0435\u043b\u044c \u0434\u043b\u044f\u00a0\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 \u0445\u0440\u0430\u043d\u0438\u0442 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0435 <code>server_metrics<\/code>. \u0412\u00a0\u043e\u043a\u0442\u044f\u0431\u0440\u0435 \u0432\u00a0\u043d\u0435\u0439 \u0431\u044b\u043b\u043e 2,26\u00a0\u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a, \u0438 \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u00a0\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434. \u0412\u0438\u043d\u043e\u0432\u0430\u0442\u044b\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441. \u0421\u00a0\u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u0437\u0430 4\u20138\u00a0\u043c\u0441, \u0430\u00a0\u0441\u00a0\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438, \u043a\u0430\u043a\u00a0\u0435\u0433\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0437\u0430 2,3\u20133,3\u00a0\u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0438 \u0432\u00a0\u0442\u0435\u0441\u0442\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u0432\u0438\u0434\u043d\u043e \u043d\u0435\u00a0\u0431\u044b\u043b\u043e. \u0422\u0435\u0441\u0442\u044b \u0433\u043e\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u00a0SQLite, \u0430\u00a0\u0432\u00a0\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u043c\u0430\u043b\u043e \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/0d\/c4\/5e\/0dc45e7ef25912a0eb7c7e93b47f03de.png\" alt=\"\u0422\u043e\u0442 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0442\u0435\u043d\u0434\u0435, 50 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 IN\" title=\"\u0422\u043e\u0442 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u0442\u0435\u043d\u0434\u0435, 50 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 IN\" width=\"1560\" height=\"552\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/0d\/c4\/5e\/0dc45e7ef25912a0eb7c7e93b47f03de.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/0d\/c4\/5e\/0dc45e7ef25912a0eb7c7e93b47f03de.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0422\u043e\u0442\u00a0\u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u00a0\u0441\u0442\u0435\u043d\u0434\u0435, 50\u00a0\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u00a0IN<\/figcaption><\/div>\n<\/figure>\n<h2>\u041e\u0442\u043a\u0443\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u0430\u043b\u0430\u0441\u044c \u0447\u0435\u0440\u0435\u0437 <code>latestOfMany<\/code>:<\/p>\n<pre><code class=\"php\">public function latestMetric(){    return $this-&gt;hasOne(ServerMetric::class)-&gt;latestOfMany();}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper\"><\/span><\/a><\/div><\/pre>\n<p>\u041d\u0430\u00a0\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0433\u0440\u0443\u0437\u044f\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u00a0\u043d\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 <code>with('latestMetric')<\/code>. \u0414\u043b\u044f\u00a0\u0442\u0430\u043a\u043e\u0439 \u0436\u0430\u0434\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 (eager loading) Laravel \u0441\u0442\u0440\u043e\u0438\u0442 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441 \u0441 <code>MAX<\/code> \u0438 <code>GROUP BY server_id<\/code>, \u0430\u00a0id \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0441\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0443\u0445\u043e\u0434\u044f\u0442 \u0432 <code>where server_id in (...)<\/code>. \u041d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435 <code>latestOfMany<\/code> \u043c\u0435\u0440\u0438\u043b\u0438 \u0438 \u043f\u043e <code>id<\/code>, \u0438 \u043f\u043e <code>created_at<\/code>. \u041e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0441\u0442\u043e\u0438\u043b\u0438 \u043e\u0442 0,5\u00a0\u0434\u043e 2,3\u00a0\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043d\u0430\u00a0\u043a\u0430\u0436\u0434\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443\u0431\u0440\u0430\u0442\u044c \u043e\u0431\u0432\u044f\u0437\u043a\u0443 Laravel, \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u0447\u0442\u043e:<\/p>\n<pre><code class=\"sql\">select max(created_at), server_idfrom server_metricswhere server_id in (?, ?, ?)group by server_id<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041d\u0430\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0435\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 <code>(server_id, created_at)<\/code>. \u0414\u043b\u044f\u00a0\u0442\u0430\u043a\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 MySQL \u0443\u043c\u0435\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c loose index scan. \u0414\u043b\u044f\u00a0\u043a\u0430\u0436\u0434\u043e\u0433\u043e <code>server_id<\/code> \u043e\u043d \u0431\u0435\u0440\u0435\u0442 \u0438\u0437\u00a0\u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043e\u0434\u043d\u0443 \u043a\u0440\u0430\u0439\u043d\u044e\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0435\u00a0\u0447\u0438\u0442\u0430\u0435\u0442. \u0412\u00a0EXPLAIN \u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043f\u043e <code>Using index for group-by<\/code><\/p>\n<h2>\u0413\u0434\u0435 \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f loose index scan<\/h2>\n<p>\u0421\u00a0\u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u0441\u0435 \u0442\u0430\u043a \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u2011\u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u0412\u00a0Laravel \u044d\u043c\u0443\u043b\u044f\u0446\u0438\u044f prepared statements \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0430, \u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0432 <code>Illuminate\/Database\/Connectors\/Connector.php<\/code>:<\/p>\n<pre><code class=\"php\">protected $options = [    PDO::ATTR_CASE =&gt; PDO::CASE_NATURAL,    PDO::ATTR_ERRMODE =&gt; PDO::ERRMODE_EXCEPTION,    PDO::ATTR_ORACLE_NULLS =&gt; PDO::NULL_NATURAL,    PDO::ATTR_STRINGIFY_FETCHES =&gt; false,    PDO::ATTR_EMULATE_PREPARES =&gt; false,];<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>PDO \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u00a0\u0441\u0435\u0440\u0432\u0435\u0440 \u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u00a0\u0432\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u043a\u0430\u043c\u0438, \u0430\u00a0\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u0421\u00a0\u0432\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 <code>IN<\/code> \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 loose index scan \u0443\u0436\u0435 \u043d\u0435\u00a0\u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442.<\/p>\n<p>\u042d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043f\u0440\u044f\u043c\u043e \u0432\u00a0\u043a\u043e\u043d\u0441\u043e\u043b\u0438 MySQL. \u0414\u043b\u044f\u00a0\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0434\u043d\u044f\u0442 \u0441\u0442\u0435\u043d\u0434, MySQL 8.0.46\u00a0\u0432\u00a0Docker \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043d\u0430 2,25\u00a0\u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a, 50\u00a0\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u043e 45\u202f000\u00a0\u043c\u0435\u0442\u0440\u0438\u043a. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043f\u043e\u0442\u043e\u043c \u0442\u043e\u0442\u00a0\u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u0447\u0435\u0440\u0435\u0437 <code>PREPARE<\/code> \u0441\u00a0\u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u0430\u043c\u0438:<\/p>\n<pre><code class=\"sql\">SELECT id INTO @a FROM servers ORDER BY id LIMIT 0, 1;SELECT id INTO @b FROM servers ORDER BY id LIMIT 1, 1;EXPLAIN SELECT MAX(created_at), server_id FROM server_metricsWHERE server_id IN (@a, @b) GROUP BY server_id;-- type: range, rows: 399, Extra: Using where; Using index for group-byPREPARE s FROM 'EXPLAIN SELECT MAX(created_at), server_id FROM server_metricsWHERE server_id IN (?, ?) GROUP BY server_id';EXECUTE s USING @a, @b;-- type: range, rows: 181170, Extra: Using where; Using index<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0412\u043e\u00a0\u0432\u0442\u043e\u0440\u043e\u043c \u043f\u043b\u0430\u043d\u0435 <code>Using index for group-by<\/code> \u043f\u0440\u043e\u043f\u0430\u043b, \u0438 MySQL \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0432\u0441\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043e\u0431\u043e\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u043e\u0434\u0440\u044f\u0434.<\/p>\n<p>\u0421\u0430\u043c <code>PREPARE<\/code> \u0442\u0443\u0442 \u043d\u0438 \u043f\u0440\u0438\u00a0\u0447\u0435\u043c. \u0415\u0441\u043b\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441, \u0433\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u043f\u0438\u0441\u0430\u043d\u044b \u0432\u00a0\u0442\u0435\u043a\u0441\u0442, loose index scan \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f. \u041d\u0435\u00a0\u043c\u0435\u0448\u0430\u0435\u0442 \u0438 \u043e\u0434\u0438\u043d \u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440, <code>IN (?)<\/code> \u0441\u00a0\u043e\u0434\u043d\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438 <code>server_id = ?<\/code> \u0442\u043e\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 <code>Using index for group-by<\/code>. \u041f\u043b\u0430\u043d \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432 <code>IN<\/code> \u0434\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0431\u043e\u043b\u044c\u0448\u0435. \u041f\u0440\u0438 40\u00a0\u0438 50\u00a0\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 MySQL \u0443\u0436\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0432\u00a0EXPLAIN \u044d\u0442\u043e <code>type: index<\/code> \u0438 2,24\u00a0\u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>\u041f\u043e\u00a0\u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430\u00a0\u0441\u0442\u0435\u043d\u0434\u0435 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 2\u00a0\u043c\u0441 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u00a0\u0442\u0435\u043a\u0441\u0442\u0435 \u0438 1,6\u00a0\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u0441\u00a0\u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u0430\u043c\u0438. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 800\u00a0\u0440\u0430\u0437. \u0421\u00a0\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439 \u044d\u043c\u0443\u043b\u044f\u0446\u0438\u0435\u0439 PDO \u0441\u0430\u043c \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u00a0\u0442\u0435\u043a\u0441\u0442, \u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043d\u043e\u0432\u0430 \u0438\u0434\u0435\u0442 \u0437\u0430 2\u00a0\u043c\u0441. \u041d\u0430\u00a0MySQL 9.2\u00a0\u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0442\u0430\u043a\u0430\u044f\u00a0\u0436\u0435.<\/p>\n<p>\u041f\u043e\u0445\u043e\u0436\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0432\u00a0\u0431\u0430\u0433\u2011\u0442\u0440\u0435\u043a\u0435\u0440\u0435 MySQL \u0435\u0441\u0442\u044c, \u044d\u0442\u043e <a href=\"https:\/\/bugs.mysql.com\/bug.php?id=115227\" rel=\"noopener nofollow\">\u0431\u0430\u0433 #115227<\/a>. \u0422\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0447\u0435\u0440\u0435\u0437 prepared statement \u0432\u043c\u0435\u0441\u0442\u043e range scan \u0448\u0435\u043b \u043f\u043e\u00a0ref, \u0447\u0438\u0442\u0430\u043b 123\u00a0\u0442\u044b\u0441\u044f\u0447\u0438 \u0441\u0442\u0440\u043e\u043a \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f 270\u00a0\u043c\u0441 \u0432\u043c\u0435\u0441\u0442\u043e 0,26. \u0415\u0433\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0432\u00a0MySQL 9.1, \u0430\u00a0\u043f\u043b\u0430\u043d \u0441\u00a0\u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u0430\u043c\u0438 \u0432 <code>IN<\/code> \u043d\u0430 9.2\u00a0\u0432\u0441\u0435 \u0442\u043e\u0442\u00a0\u0436\u0435. \u041e\u0442\u0447\u0435\u0442\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u00a0\u044d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439 \u044f \u043d\u0435\u00a0\u043d\u0430\u0448\u0435\u043b.<\/p>\n<h2>\u041f\u043e\u0447\u0435\u043c\u0443 \u0441\u00a0\u0446\u0435\u043b\u044b\u043c\u0438 id \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u00a0\u0432\u0438\u0434\u043d\u043e<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043b\u044e\u0447\u0438 \u0443\u00a0\u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0446\u0435\u043b\u044b\u0435, Laravel \u043e\u0431\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441\u0430\u043c. \u041a\u0430\u043a\u00a0\u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c id \u0432\u00a0\u0436\u0430\u0434\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443, \u0440\u0435\u0448\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 <code>Illuminate\/Database\/Eloquent\/Relations\/Relation.php<\/code>:<\/p>\n<pre><code class=\"php\">protected function whereInMethod(Model $model, $key){    return $model-&gt;getKeyName() === last(explode('.', $key))        &amp;&amp; in_array($model-&gt;getKeyType(), ['int', 'integer'])            ? 'whereIntegerInRaw'            : 'whereIn';}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0426\u0435\u043b\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0432\u00a0\u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 <code>whereIntegerInRaw<\/code>, \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u0443\u0445\u043e\u0434\u044f\u0442 \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438. \u0423\u00a0\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0432\u00a0\u043f\u0430\u043d\u0435\u043b\u0438 \u043a\u043b\u044e\u0447\u0438 UUID, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043f\u043e\u043f\u0430\u043b \u043f\u043e\u0434\u00a0\u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u044b.<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/fd\/39\/e3\/fd39e35163e71ef52379993c70d3109c.png\" width=\"1600\" height=\"780\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/fd\/39\/e3\/fd39e35163e71ef52379993c70d3109c.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/fd\/39\/e3\/fd39e35163e71ef52379993c70d3109c.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041d\u0430\u00a0\u0442\u043e\u043c\u00a0\u0436\u0435 \u0441\u0442\u0435\u043d\u0434\u0435 \u0434\u0432\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f <code>hasOne()-&gt;latestOfMany('created_at')<\/code>\u0423\u00a0\u043e\u0434\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0441\u00a0UUID, \u0443\u00a0\u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0441\u00a0\u0446\u0435\u043b\u044b\u043c id. \u0416\u0430\u0434\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 50\u00a0\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0437\u0430\u043d\u044f\u043b\u0430 1\u202f643\u00a0\u043c\u0441 \u0441 50\u00a0\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438 \u043f\u0440\u043e\u0442\u0438\u0432 7\u00a0\u043c\u0441 \u0431\u0435\u0437\u00a0\u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430<\/p>\n<p>\u041f\u043e\u0434\u00a0\u0443\u0434\u0430\u0440 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u00a0MySQL, \u0433\u0434\u0435 \u0443\u00a0\u043c\u043e\u0434\u0435\u043b\u0435\u0439 UUID \u0438\u043b\u0438\u00a0ULID, \u0430\u00a0\u043d\u0430\u00a0\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441\u0442\u043e\u0438\u0442 <code>latestOfMany<\/code>, <code>oldestOfMany<\/code> \u0438\u043b\u0438 <code>ofMany<\/code>. \u0422\u043e\u00a0\u0436\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 <code>whereIn<\/code> \u043d\u0430\u00a0\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, <code>groupBy<\/code> \u0438 <code>max<\/code> \u0438\u043b\u0438 <code>min<\/code><\/p>\n<h2>\u041a\u0430\u043a\u00a0\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0443\u00a0\u0441\u0435\u0431\u044f<\/h2>\n<p>\u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u0437\u044f\u0442\u044c \u0441\u0432\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 <code>GROUP BY<\/code> \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0434\u0432\u0430 EXPLAIN, \u043a\u0430\u043a\u00a0\u0432\u044b\u0448\u0435. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0447\u0435\u0440\u0435\u0437 <code>SET @a<\/code>, \u043f\u043e\u0442\u043e\u043c \u0442\u043e\u0442\u00a0\u0436\u0435 \u0442\u0435\u043a\u0441\u0442 \u0447\u0435\u0440\u0435\u0437 <code>PREPARE<\/code> \u0438 <code>EXECUTE ... USING<\/code>. \u0415\u0441\u043b\u0438 <code>Using index for group-by<\/code> \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u00a0\u043f\u0435\u0440\u0432\u043e\u043c, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u00a0\u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u043b\u0430\u043d\u0443.<\/p>\n<p>\u041c\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435 \u0442\u043e\u0436\u0435 \u043d\u0430\u0434\u043e \u0441\u00a0\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438. EXPLAIN \u0441\u00a0\u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u043b\u0430\u043d, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0442. \u0421\u0442\u0435\u043d\u0434 \u0438\u0437\u00a0\u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043a\u0440\u0438\u043f\u0442 \u0441\u0442\u0435\u043d\u0434\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"sql\">CREATE TABLE servers (id CHAR(36) PRIMARY KEY);CREATE TABLE server_metrics (  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,  server_id CHAR(36) NOT NULL,  cpu DECIMAL(5,2) NOT NULL,  created_at TIMESTAMP NOT NULL,  KEY server_metrics_server_id_created_at_index (server_id, created_at));INSERT INTO serversSELECT UUID() FROM (WITH RECURSIVE n AS (SELECT 1 i UNION ALL SELECT i + 1 FROM n WHERE i &lt; 50) SELECT i FROM n) t;SET SESSION cte_max_recursion_depth = 100000;INSERT INTO server_metrics (server_id, cpu, created_at)SELECT s.id, RAND() * 100, NOW() - INTERVAL n.i MINUTEFROM servers sCROSS JOIN (WITH RECURSIVE n AS (SELECT 1 i UNION ALL SELECT i + 1 FROM n WHERE i &lt; 45000) SELECT i FROM n) n;ANALYZE TABLE server_metrics;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<h2>\u0427\u0442\u043e\u00a0\u0441\u0434\u0435\u043b\u0430\u043b\u0438<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 id \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043b\u0435\u0436\u0438\u0442 \u0443\u00a0\u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0432 <code>servers.latest_metric_id<\/code>. \u0415\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0445\u0443\u043a <code>created<\/code> \u0443\u00a0\u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0430 <code>latestMetric()<\/code> \u0441\u0442\u0430\u043b \u043e\u0431\u044b\u0447\u043d\u044b\u043c <code>belongsTo<\/code>:<\/p>\n<pre><code class=\"php\">\/\/ ServerMetricprotected static function booted(): void{    static::created(function (ServerMetric $metric): void {        Server::whereKey($metric-&gt;server_id)-&gt;toBase()-&gt;update(['latest_metric_id' =&gt; $metric-&gt;id]);    });}\/\/ Serverpublic function latestMetric(): BelongsTo{    return $this-&gt;belongsTo(ServerMetric::class, 'latest_metric_id');}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p><code>toBase()<\/code> \u0437\u0434\u0435\u0441\u044c \u043d\u0443\u0436\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u00a0\u043a\u0430\u0436\u0434\u0443\u044e \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u043d\u0435\u00a0\u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0438 \u0436\u0443\u0440\u043d\u0430\u043b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u043e\u0431\u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0438 <code>updated_at<\/code> \u0443\u00a0\u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u043f\u043e\u00a0\u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u0441\u00a0\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438 \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435 \u0438\u0434\u0435\u0442 \u0437\u0430 1\u20133\u00a0\u043c\u0441. \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043a\u0430\u0442\u043a\u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430 0,23\u00a0\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u0432\u043c\u0435\u0441\u0442\u043e 1,7<\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/ea\/36\/6c\/ea366cefb7f667deafa042f18c0af83d.png\" width=\"1600\" height=\"680\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/ea\/36\/6c\/ea366cefb7f667deafa042f18c0af83d.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/ea\/36\/6c\/ea366cefb7f667deafa042f18c0af83d.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c <code>ATTR_EMULATE_PREPARES<\/code>, \u0441\u00a0\u043d\u0435\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043d\u043e\u0432\u0430 \u0438\u0434\u0435\u0442 \u0437\u0430 2\u00a0\u043c\u0441. \u0422\u043e\u0433\u0434\u0430 \u0434\u043e\u00a0\u044d\u043c\u0443\u043b\u044f\u0446\u0438\u0438 \u043d\u0435\u00a0\u0434\u043e\u0434\u0443\u043c\u0430\u043b\u0438\u0441\u044c. \u042d\u0442\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c \u0443\u0436\u0435 \u043d\u0430\u00a0\u0441\u0442\u0435\u043d\u0434\u0435 \u0434\u043b\u044f\u00a0\u0441\u0442\u0430\u0442\u044c\u0438, \u0430\u00a0\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043a\u00a0\u0442\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435.<\/p>\n<h2>\u041a\u0430\u043a\u00a0\u0437\u0430\u043c\u0435\u0440 \u0443\u0440\u043e\u043d\u0438\u043b \u043f\u0440\u043e\u0434 \u043d\u0430 13\u00a0\u043c\u0438\u043d\u0443\u0442<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435, \u0437\u0430\u043f\u0440\u043e\u0441 \u0433\u043e\u043d\u044f\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 PDO \u0441\u00a0\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438. \u041e\u0434\u0438\u043d \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e <code>server_metrics<\/code> \u043e\u0442\u043c\u0435\u043d\u0438\u043b\u0438, \u043d\u043e\u00a0\u043e\u0442\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0435\u0433\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0430. \u0412\u00a0MySQL \u043e\u043d \u043f\u0440\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0435\u0449\u0435 93\u00a0\u043c\u0438\u043d\u0443\u0442\u044b. \u0412\u00a0processlist \u043e\u043d \u0432\u0438\u0441\u0435\u043b \u0441 <code>command = Execute<\/code>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u00a0\u043f\u0440\u0438\u0448\u0435\u043b \u043a\u0430\u043a\u00a0prepared statement. \u0418\u0441\u043a\u0430\u043b\u0438 \u0435\u0433\u043e \u0441\u0440\u0435\u0434\u0438 <code>command = 'Query'<\/code><\/p>\n<p>\u0412\u00a0\u0442\u0443\u00a0\u0436\u0435 \u043d\u043e\u0447\u044c \u0432\u044b\u043a\u0430\u0442\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0441 <code>latest_metric_id<\/code>, \u0442\u043e \u0435\u0441\u0442\u044c <code>ALTER TABLE servers<\/code>. \u041f\u0440\u043e\u0431\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0447\u0438\u0442\u0430\u043b \u0434\u0440\u0443\u0433\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043d\u043e\u00a0\u0443 <code>server_metrics<\/code> \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 <code>servers<\/code>. \u0412\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 MySQL \u043f\u0440\u043e\u00a0metadata locks \u0442\u0430\u043a \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u043f\u0440\u0438\u00a0\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438 \u043d\u0430\u00a0\u0434\u043e\u0447\u0435\u0440\u043d\u044e\u044e. ALTER \u0432\u0441\u0442\u0430\u043b \u0436\u0434\u0430\u0442\u044c, \u0437\u0430\u00a0\u043d\u0438\u043c \u0432\u00a0\u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432\u0441\u0442\u0430\u043b\u0438 \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a <code>servers<\/code>, \u0438 \u0441 00:36\u00a0\u0434\u043e 00:49\u00a0\u043f\u0430\u043d\u0435\u043b\u044c \u043d\u0435\u00a0\u043e\u0442\u0432\u0435\u0447\u0430\u043b\u0430, \u043f\u043e\u043a\u0430 \u043f\u043e\u0442\u043e\u043a \u0441\u00a0\u043f\u0440\u043e\u0431\u043d\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043d\u0435\u00a0\u0441\u043d\u044f\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 <code>KILL<\/code><\/p>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/0c\/92\/20\/0c9220c0f3500dc1c85d5ae178998145.png\" width=\"1600\" height=\"632\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/0c\/92\/20\/0c9220c0f3500dc1c85d5ae178998145.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/0c\/92\/20\/0c9220c0f3500dc1c85d5ae178998145.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0431\u043d\u044b\u0435 <code>SELECT<\/code> \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435 \u0438\u0434\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u00a0\u0445\u0438\u043d\u0442\u043e\u043c<\/p>\n<p> <code>\/*+ MAX_EXECUTION_TIME(5000) *\/<\/code><\/p>\n<p>\u0447\u0435\u0440\u0435\u0437 5\u00a0\u0441\u0435\u043a\u0443\u043d\u0434 MySQL \u043e\u0431\u0440\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0441\u0430\u043c. \u0410\u00a0\u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043c\u0435\u043d\u044b <code>processlist<\/code> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u00a0\u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0431\u0435\u0437\u00a0\u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u043f\u043e\u00a0\u0442\u0438\u043f\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"sql\">SELECT id, command, time, LEFT(info, 80) AS queryFROM information_schema.processlistWHERE command NOT IN ('Sleep', 'Daemon') AND time &gt; 20;<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0418 \u043f\u0435\u0440\u0435\u0434 \u0434\u0435\u043f\u043b\u043e\u0435\u043c \u0441\u00a0ALTER \u043f\u043e\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043d\u0430\u00a0\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0438, \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043d\u0435\u0442\u00a0\u043b\u0438 \u0434\u043e\u043b\u0433\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a\u00a0\u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c.<\/p>\n<hr\/>\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/extt\/bf\/1e\/d4\/bf1ed4ef1a3836e2f2735629a861a652.png\" width=\"1600\" height=\"660\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/extt\/bf\/1e\/d4\/bf1ed4ef1a3836e2f2735629a861a652.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/extt\/bf\/1e\/d4\/bf1ed4ef1a3836e2f2735629a861a652.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0410\u00a0\u0443 \u0432\u0430\u0441 \u043f\u0440\u043e\u0434 \u0440\u043e\u043d\u044f\u043b \u043a\u0430\u043a\u043e\u0439\u2011\u043d\u0438\u0431\u0443\u0434\u044c \u0447\u0443\u0434\u043e\u2011\u0437\u0430\u043f\u0440\u043e\u0441? \u0420\u0430\u0441\u0441\u043a\u0430\u0436\u0438\u0442\u0435 \u0432\u00a0\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043a\u0430\u043a\u00a0\u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0438 \u0447\u0435\u043c \u043a\u043e\u043d\u0447\u0438\u043b\u043e\u0441\u044c.<\/p>\n<\/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=\"https:\/\/habr.com\/ru\/articles\/1104364\/\">https:\/\/habr.com\/ru\/articles\/1104364\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041d\u0430\u0448\u0430 \u043f\u0430\u043d\u0435\u043b\u044c \u0434\u043b\u044f\u00a0\u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u043c\u0438 \u0445\u0440\u0430\u043d\u0438\u0442 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0432\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0435 server_metrics. \u0412\u00a0\u043e\u043a\u0442\u044f\u0431\u0440\u0435 \u0432\u00a0\u043d\u0435\u0439 \u0431\u044b\u043b\u043e 2,26\u00a0\u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a, \u0438 \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u043e\u00a0\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u043a\u0443\u043d\u0434. \u0412\u0438\u043d\u043e\u0432\u0430\u0442\u044b\u043c \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441. \u0421\u00a0\u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u0437\u0430 4\u20138\u00a0\u043c\u0441, \u0430\u00a0\u0441\u00a0\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438, \u043a\u0430\u043a\u00a0\u0435\u0433\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0437\u0430 2,3\u20133,3\u00a0\u0441\u0435\u043a\u0443\u043d\u0434\u044b.\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0438 \u0432\u00a0\u0442\u0435\u0441\u0442\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u0432\u0438\u0434\u043d\u043e \u043d\u0435\u00a0\u0431\u044b\u043b\u043e. \u0422\u0435\u0441\u0442\u044b \u0433\u043e\u043d\u044f\u044e\u0442\u0441\u044f \u043d\u0430\u00a0SQLite, \u0430\u00a0\u0432\u00a0\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0431\u0430\u0437\u0435 \u043c\u0430\u043b\u043e \u0434\u0430\u043d\u043d\u044b\u0445.\u0422\u043e\u0442\u00a0\u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430\u00a0\u0441\u0442\u0435\u043d\u0434\u0435, 50\u00a0\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u00a0IN\u041e\u0442\u043a\u0443\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043c\u0435\u0442\u0440\u0438\u043a\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043e\u0441\u0442\u0430\u0432\u0430\u043b\u0430\u0441\u044c \u0447\u0435\u0440\u0435\u0437 latestOfMany:public function latestMetric(){    return $this-&gt;hasOne(ServerMetric::class)-&gt;latestOfMany();}\u041d\u0430\u00a0\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0433\u0440\u0443\u0437\u044f\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u00a0\u043d\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 with(&#8216;latestMetric&#8217;). \u0414\u043b\u044f\u00a0\u0442\u0430\u043a\u043e\u0439 \u0436\u0430\u0434\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 (eager loading) Laravel \u0441\u0442\u0440\u043e\u0438\u0442 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441 \u0441 MAX \u0438 GROUP BY server_id, \u0430\u00a0id \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0441\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0443\u0445\u043e\u0434\u044f\u0442 \u0432 where server_id in (&#8230;). \u041d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435 latestOfMany \u043c\u0435\u0440\u0438\u043b\u0438 \u0438 \u043f\u043e id, \u0438 \u043f\u043e created_at. \u041e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0441\u0442\u043e\u0438\u043b\u0438 \u043e\u0442 0,5\u00a0\u0434\u043e 2,3\u00a0\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u043d\u0430\u00a0\u043a\u0430\u0436\u0434\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443.\u0415\u0441\u043b\u0438 \u0443\u0431\u0440\u0430\u0442\u044c \u043e\u0431\u0432\u044f\u0437\u043a\u0443 Laravel, \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u0447\u0442\u043e:select max(created_at), server_idfrom server_metricswhere server_id in (?, ?, ?)group by server_id\u041d\u0430\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0435\u0441\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 (server_id, created_at). \u0414\u043b\u044f\u00a0\u0442\u0430\u043a\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 MySQL \u0443\u043c\u0435\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c loose index scan. \u0414\u043b\u044f\u00a0\u043a\u0430\u0436\u0434\u043e\u0433\u043e server_id \u043e\u043d \u0431\u0435\u0440\u0435\u0442 \u0438\u0437\u00a0\u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043e\u0434\u043d\u0443 \u043a\u0440\u0430\u0439\u043d\u044e\u044e \u0437\u0430\u043f\u0438\u0441\u044c \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0435\u00a0\u0447\u0438\u0442\u0430\u0435\u0442. \u0412\u00a0EXPLAIN \u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043f\u043e Using index for group-by\u0413\u0434\u0435 \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f loose index scan\u0421\u00a0\u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u0441\u0435 \u0442\u0430\u043a \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u2011\u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u0412\u00a0Laravel \u044d\u043c\u0443\u043b\u044f\u0446\u0438\u044f prepared statements \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u043a\u043b\u044e\u0447\u0435\u043d\u0430, \u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0432 Illuminate\/Database\/Connectors\/Connector.php:protected $options = [    PDO::ATTR_CASE =&gt; PDO::CASE_NATURAL,    PDO::ATTR_ERRMODE =&gt; PDO::ERRMODE_EXCEPTION,    PDO::ATTR_ORACLE_NULLS =&gt; PDO::NULL_NATURAL,    PDO::ATTR_STRINGIFY_FETCHES =&gt; false,    PDO::ATTR_EMULATE_PREPARES =&gt; false,];PDO \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u00a0\u0441\u0435\u0440\u0432\u0435\u0440 \u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u00a0\u0432\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u043a\u0430\u043c\u0438, \u0430\u00a0\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u0421\u00a0\u0432\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 IN \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 loose index scan \u0443\u0436\u0435 \u043d\u0435\u00a0\u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442.\u042d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043f\u0440\u044f\u043c\u043e \u0432\u00a0\u043a\u043e\u043d\u0441\u043e\u043b\u0438 MySQL. \u0414\u043b\u044f\u00a0\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0434\u043d\u044f\u0442 \u0441\u0442\u0435\u043d\u0434, MySQL 8.0.46\u00a0\u0432\u00a0Docker \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043d\u0430 2,25\u00a0\u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a, 50\u00a0\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u043e 45\u202f000\u00a0\u043c\u0435\u0442\u0440\u0438\u043a. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043f\u043e\u0442\u043e\u043c \u0442\u043e\u0442\u00a0\u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u0447\u0435\u0440\u0435\u0437 PREPARE \u0441\u00a0\u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u0430\u043c\u0438:SELECT id INTO @a FROM servers ORDER BY id LIMIT 0, 1;SELECT id INTO @b FROM servers ORDER BY id LIMIT 1, 1;EXPLAIN SELECT MAX(created_at), server_id FROM server_metricsWHERE server_id IN (@a, @b) GROUP BY server_id;&#8212; type: range, rows: 399, Extra: Using where; Using index for group-byPREPARE s FROM &#8216;EXPLAIN SELECT MAX(created_at), server_id FROM server_metricsWHERE server_id IN (?, ?) GROUP BY server_id&#8217;;EXECUTE s USING @a, @b;&#8212; type: range, rows: 181170, Extra: Using where; Using index\u0412\u043e\u00a0\u0432\u0442\u043e\u0440\u043e\u043c \u043f\u043b\u0430\u043d\u0435 Using index for group-by \u043f\u0440\u043e\u043f\u0430\u043b, \u0438 MySQL \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0432\u0441\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u043e\u0431\u043e\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u043e\u0434\u0440\u044f\u0434.\u0421\u0430\u043c PREPARE \u0442\u0443\u0442 \u043d\u0438 \u043f\u0440\u0438\u00a0\u0447\u0435\u043c. \u0415\u0441\u043b\u0438 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441, \u0433\u0434\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u043f\u0438\u0441\u0430\u043d\u044b \u0432\u00a0\u0442\u0435\u043a\u0441\u0442, loose index scan \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f. \u041d\u0435\u00a0\u043c\u0435\u0448\u0430\u0435\u0442 \u0438 \u043e\u0434\u0438\u043d \u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440, IN (?) \u0441\u00a0\u043e\u0434\u043d\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438 server_id = ? \u0442\u043e\u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 Using index for group-by. \u041f\u043b\u0430\u043d \u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0432 IN \u0434\u0432\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438 \u0431\u043e\u043b\u044c\u0448\u0435. \u041f\u0440\u0438 40\u00a0\u0438 50\u00a0\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 MySQL \u0443\u0436\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0438\u043d\u0434\u0435\u043a\u0441 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0432\u00a0EXPLAIN \u044d\u0442\u043e type: index \u0438 2,24\u00a0\u043c\u043b\u043d \u0441\u0442\u0440\u043e\u043a.\u041f\u043e\u00a0\u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430\u00a0\u0441\u0442\u0435\u043d\u0434\u0435 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 2\u00a0\u043c\u0441 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432\u00a0\u0442\u0435\u043a\u0441\u0442\u0435 \u0438 1,6\u00a0\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u0441\u00a0\u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u0430\u043c\u0438. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0432 800\u00a0\u0440\u0430\u0437. \u0421\u00a0\u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439 \u044d\u043c\u0443\u043b\u044f\u0446\u0438\u0435\u0439 PDO \u0441\u0430\u043c \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u00a0\u0442\u0435\u043a\u0441\u0442, \u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043d\u043e\u0432\u0430 \u0438\u0434\u0435\u0442 \u0437\u0430 2\u00a0\u043c\u0441. \u041d\u0430\u00a0MySQL 9.2\u00a0\u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0442\u0430\u043a\u0430\u044f\u00a0\u0436\u0435.\u041f\u043e\u0445\u043e\u0436\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0432\u00a0\u0431\u0430\u0433\u2011\u0442\u0440\u0435\u043a\u0435\u0440\u0435 MySQL \u0435\u0441\u0442\u044c, \u044d\u0442\u043e \u0431\u0430\u0433 #115227. \u0422\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0447\u0435\u0440\u0435\u0437 prepared statement \u0432\u043c\u0435\u0441\u0442\u043e range scan \u0448\u0435\u043b \u043f\u043e\u00a0ref, \u0447\u0438\u0442\u0430\u043b 123\u00a0\u0442\u044b\u0441\u044f\u0447\u0438 \u0441\u0442\u0440\u043e\u043a \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f 270\u00a0\u043c\u0441 \u0432\u043c\u0435\u0441\u0442\u043e 0,26. \u0415\u0433\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u0432\u00a0MySQL 9.1, \u0430\u00a0\u043f\u043b\u0430\u043d \u0441\u00a0\u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u0430\u043c\u0438 \u0432 IN \u043d\u0430 9.2\u00a0\u0432\u0441\u0435 \u0442\u043e\u0442\u00a0\u0436\u0435. \u041e\u0442\u0447\u0435\u0442\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u00a0\u044d\u0442\u043e\u0442 \u0441\u043b\u0443\u0447\u0430\u0439 \u044f \u043d\u0435\u00a0\u043d\u0430\u0448\u0435\u043b.\u041f\u043e\u0447\u0435\u043c\u0443 \u0441\u00a0\u0446\u0435\u043b\u044b\u043c\u0438 id \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u00a0\u0432\u0438\u0434\u043d\u043e\u0415\u0441\u043b\u0438 \u043a\u043b\u044e\u0447\u0438 \u0443\u00a0\u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0446\u0435\u043b\u044b\u0435, Laravel \u043e\u0431\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441\u0430\u043c. \u041a\u0430\u043a\u00a0\u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c id \u0432\u00a0\u0436\u0430\u0434\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443, \u0440\u0435\u0448\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 Illuminate\/Database\/Eloquent\/Relations\/Relation.php:protected function whereInMethod(Model $model, $key){    return $model-&gt;getKeyName() === last(explode(&#8216;.&#8217;, $key))        &amp;&amp; in_array($model-&gt;getKeyType(), [&#8216;int&#8217;, &#8216;integer&#8217;])            ? &#8216;whereIntegerInRaw&#8217;            : &#8216;whereIn&#8217;;}\u0426\u0435\u043b\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0432\u00a0\u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 whereIntegerInRaw, \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u0443\u0445\u043e\u0434\u044f\u0442 \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438. \u0423\u00a0\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0432\u00a0\u043f\u0430\u043d\u0435\u043b\u0438 \u043a\u043b\u044e\u0447\u0438 UUID, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043f\u043e\u043f\u0430\u043b \u043f\u043e\u0434\u00a0\u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u044b.\u041d\u0430\u00a0\u0442\u043e\u043c\u00a0\u0436\u0435 \u0441\u0442\u0435\u043d\u0434\u0435 \u0434\u0432\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f hasOne()-&gt;latestOfMany(&#8216;created_at&#8217;)\u0423\u00a0\u043e\u0434\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c \u0441\u00a0UUID, \u0443\u00a0\u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0441\u00a0\u0446\u0435\u043b\u044b\u043c id. \u0416\u0430\u0434\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 50\u00a0\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u0437\u0430\u043d\u044f\u043b\u0430 1\u202f643\u00a0\u043c\u0441 \u0441 50\u00a0\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438 \u043f\u0440\u043e\u0442\u0438\u0432 7\u00a0\u043c\u0441 \u0431\u0435\u0437\u00a0\u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u041f\u043e\u0434\u00a0\u0443\u0434\u0430\u0440 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u00a0MySQL, \u0433\u0434\u0435 \u0443\u00a0\u043c\u043e\u0434\u0435\u043b\u0435\u0439 UUID \u0438\u043b\u0438\u00a0ULID, \u0430\u00a0\u043d\u0430\u00a0\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441\u0442\u043e\u0438\u0442 latestOfMany, oldestOfMany \u0438\u043b\u0438 ofMany. \u0422\u043e\u00a0\u0436\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 whereIn \u043d\u0430\u00a0\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, groupBy \u0438 max \u0438\u043b\u0438 min\u041a\u0430\u043a\u00a0\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0443\u00a0\u0441\u0435\u0431\u044f\u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u0437\u044f\u0442\u044c \u0441\u0432\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 GROUP BY \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0434\u0432\u0430 EXPLAIN, \u043a\u0430\u043a\u00a0\u0432\u044b\u0448\u0435. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0447\u0435\u0440\u0435\u0437 SET @a, \u043f\u043e\u0442\u043e\u043c \u0442\u043e\u0442\u00a0\u0436\u0435 \u0442\u0435\u043a\u0441\u0442 \u0447\u0435\u0440\u0435\u0437 PREPARE \u0438 EXECUTE &#8230; USING. \u0415\u0441\u043b\u0438 Using index for group-by \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u00a0\u043f\u0435\u0440\u0432\u043e\u043c, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u00a0\u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u043b\u0430\u043d\u0443.\u041c\u0435\u0440\u0438\u0442\u044c \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435 \u0442\u043e\u0436\u0435 \u043d\u0430\u0434\u043e \u0441\u00a0\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438. EXPLAIN \u0441\u00a0\u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043f\u043b\u0430\u043d, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u00a0\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0435\u0442. \u0421\u0442\u0435\u043d\u0434 \u0438\u0437\u00a0\u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a:\u0421\u043a\u0440\u0438\u043f\u0442 \u0441\u0442\u0435\u043d\u0434\u0430CREATE TABLE servers (id CHAR(36) PRIMARY KEY);CREATE TABLE server_metrics (  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,  server_id CHAR(36) NOT NULL,  cpu DECIMAL(5,2) NOT NULL,  created_at TIMESTAMP NOT NULL,  KEY server_metrics_server_id_created_at_index (server_id, created_at));INSERT INTO serversSELECT UUID() FROM (WITH RECURSIVE n AS (SELECT 1 i UNION ALL SELECT i + 1 FROM n WHERE i &lt; 50) SELECT i FROM n) t;SET SESSION cte_max_recursion_depth = 100000;INSERT INTO server_metrics (server_id, cpu, created_at)SELECT s.id, RAND() * 100, NOW() &#8212; INTERVAL n.i MINUTEFROM servers sCROSS JOIN (WITH RECURSIVE n AS (SELECT 1 i UNION ALL SELECT i + 1 FROM n WHERE i &lt; 45000) SELECT i FROM n) n;ANALYZE TABLE server_metrics;\u0427\u0442\u043e\u00a0\u0441\u0434\u0435\u043b\u0430\u043b\u0438\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 id \u043c\u0435\u0442\u0440\u0438\u043a\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043b\u0435\u0436\u0438\u0442 \u0443\u00a0\u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0432 servers.latest_metric_id. \u0415\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u0445\u0443\u043a created \u0443\u00a0\u043c\u0435\u0442\u0440\u0438\u043a\u0438, \u0430 latestMetric() \u0441\u0442\u0430\u043b \u043e\u0431\u044b\u0447\u043d\u044b\u043c belongsTo:\/\/ ServerMetricprotected static function booted(): void{    static::created(function (ServerMetric $metric): void {        Server::whereKey($metric-&gt;server_id)-&gt;toBase()-&gt;update([&#8216;latest_metric_id&#8217; =&gt; $metric-&gt;id]);    });}\/\/ Serverpublic function latestMetric(): BelongsTo{    return $this-&gt;belongsTo(ServerMetric::class, &#8216;latest_metric_id&#8217;);}toBase() \u0437\u0434\u0435\u0441\u044c \u043d\u0443\u0436\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u00a0\u043a\u0430\u0436\u0434\u0443\u044e \u043c\u0435\u0442\u0440\u0438\u043a\u0443 \u043d\u0435\u00a0\u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0438 \u0436\u0443\u0440\u043d\u0430\u043b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u043e\u0431\u0441\u0435\u0440\u0432\u0435\u0440\u044b \u0438 updated_at \u0443\u00a0\u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u043f\u043e\u00a0\u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u0441\u00a0\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438 \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435 \u0438\u0434\u0435\u0442 \u0437\u0430 1\u20133\u00a0\u043c\u0441. \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u043a\u0430\u0442\u043a\u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430 0,23\u00a0\u0441\u0435\u043a\u0443\u043d\u0434\u044b \u0432\u043c\u0435\u0441\u0442\u043e 1,7\u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c ATTR_EMULATE_PREPARES, \u0441\u00a0\u043d\u0435\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043d\u043e\u0432\u0430 \u0438\u0434\u0435\u0442 \u0437\u0430 2\u00a0\u043c\u0441. \u0422\u043e\u0433\u0434\u0430 \u0434\u043e\u00a0\u044d\u043c\u0443\u043b\u044f\u0446\u0438\u0438 \u043d\u0435\u00a0\u0434\u043e\u0434\u0443\u043c\u0430\u043b\u0438\u0441\u044c. \u042d\u0442\u043e \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c \u0443\u0436\u0435 \u043d\u0430\u00a0\u0441\u0442\u0435\u043d\u0434\u0435 \u0434\u043b\u044f\u00a0\u0441\u0442\u0430\u0442\u044c\u0438, \u0430\u00a0\u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043a\u00a0\u0442\u043e\u043c\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435.\u041a\u0430\u043a\u00a0\u0437\u0430\u043c\u0435\u0440 \u0443\u0440\u043e\u043d\u0438\u043b \u043f\u0440\u043e\u0434 \u043d\u0430 13\u00a0\u043c\u0438\u043d\u0443\u0442\u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435, \u0437\u0430\u043f\u0440\u043e\u0441 \u0433\u043e\u043d\u044f\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 PDO \u0441\u00a0\u0431\u0438\u043d\u0434\u0438\u043d\u0433\u0430\u043c\u0438. \u041e\u0434\u0438\u043d \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0431\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e server_metrics \u043e\u0442\u043c\u0435\u043d\u0438\u043b\u0438, \u043d\u043e\u00a0\u043e\u0442\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0435\u0433\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0430. \u0412\u00a0MySQL \u043e\u043d \u043f\u0440\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0435\u0449\u0435 93\u00a0\u043c\u0438\u043d\u0443\u0442\u044b. \u0412\u00a0processlist \u043e\u043d \u0432\u0438\u0441\u0435\u043b \u0441 command = Execute, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e\u00a0\u043f\u0440\u0438\u0448\u0435\u043b \u043a\u0430\u043a\u00a0prepared statement. \u0418\u0441\u043a\u0430\u043b\u0438 \u0435\u0433\u043e \u0441\u0440\u0435\u0434\u0438 command = &#8216;Query&#8217;\u0412\u00a0\u0442\u0443\u00a0\u0436\u0435 \u043d\u043e\u0447\u044c \u0432\u044b\u043a\u0430\u0442\u044b\u0432\u0430\u043b\u0430\u0441\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u0441 latest_metric_id, \u0442\u043e \u0435\u0441\u0442\u044c ALTER TABLE servers. \u041f\u0440\u043e\u0431\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0447\u0438\u0442\u0430\u043b \u0434\u0440\u0443\u0433\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043d\u043e\u00a0\u0443 server_metrics \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u043a\u043b\u044e\u0447 \u043d\u0430 servers. \u0412\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 MySQL \u043f\u0440\u043e\u00a0metadata locks \u0442\u0430\u043a \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u043f\u0440\u0438\u00a0\u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438 \u043d\u0430\u00a0\u0434\u043e\u0447\u0435\u0440\u043d\u044e\u044e. ALTER \u0432\u0441\u0442\u0430\u043b \u0436\u0434\u0430\u0442\u044c, \u0437\u0430\u00a0\u043d\u0438\u043c \u0432\u00a0\u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0432\u0441\u0442\u0430\u043b\u0438 \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a servers, \u0438 \u0441 00:36\u00a0\u0434\u043e 00:49\u00a0\u043f\u0430\u043d\u0435\u043b\u044c \u043d\u0435\u00a0\u043e\u0442\u0432\u0435\u0447\u0430\u043b\u0430, \u043f\u043e\u043a\u0430 \u043f\u043e\u0442\u043e\u043a \u0441\u00a0\u043f\u0440\u043e\u0431\u043d\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043d\u0435\u00a0\u0441\u043d\u044f\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 KILL\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0431\u043d\u044b\u0435 SELECT \u043d\u0430\u00a0\u043f\u0440\u043e\u0434\u0435 \u0438\u0434\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u00a0\u0445\u0438\u043d\u0442\u043e\u043c \/*+ MAX_EXECUTION_TIME(5000) *\/\u0447\u0435\u0440\u0435\u0437 5\u00a0\u0441\u0435\u043a\u0443\u043d\u0434 MySQL \u043e\u0431\u0440\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0441\u0430\u043c. \u0410\u00a0\u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u043c\u0435\u043d\u044b processlist \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u00a0\u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0431\u0435\u0437\u00a0\u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u043f\u043e\u00a0\u0442\u0438\u043f\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:SELECT id, command, time, LEFT(info, 80) AS queryFROM information_schema.processlistWHERE command NOT IN (&#8216;Sleep&#8217;, &#8216;Daemon&#8217;) AND time &gt; 20;\u0418 \u043f\u0435\u0440\u0435\u0434 \u0434\u0435\u043f\u043b\u043e\u0435\u043c \u0441\u00a0ALTER \u043f\u043e\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043d\u0430\u00a0\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0438, \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043d\u0435\u0442\u00a0\u043b\u0438 \u0434\u043e\u043b\u0433\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a\u00a0\u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c.\u0410\u00a0\u0443 \u0432\u0430\u0441 \u043f\u0440\u043e\u0434 \u0440\u043e\u043d\u044f\u043b \u043a\u0430\u043a\u043e\u0439\u2011\u043d\u0438\u0431\u0443\u0434\u044c \u0447\u0443\u0434\u043e\u2011\u0437\u0430\u043f\u0440\u043e\u0441? \u0420\u0430\u0441\u0441\u043a\u0430\u0436\u0438\u0442\u0435 \u0432\u00a0\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445, \u043a\u0430\u043a\u00a0\u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0438 \u0447\u0435\u043c \u043a\u043e\u043d\u0447\u0438\u043b\u043e\u0441\u044c.\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 https:\/\/habr.com\/ru\/articles\/1104364\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-501928","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/501928","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=501928"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/501928\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=501928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=501928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=501928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}