{"id":211022,"date":"2014-02-01T01:46:03","date_gmt":"2014-01-31T21:46:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=211022"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=211022","title":{"rendered":"<span class=\"post_title\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 EXPLAIN. \u0423\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/span>"},"content":{"rendered":"<div class=\"content html_format\">       \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0435 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0437\u0430\u043f\u0440\u043e\u0441, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 MySQL \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043b\u0430\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u043f\u043b\u0430\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c EXPLAIN. EXPLAIN \u2013 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043c\u043e\u0449\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u0432\u0430\u0448\u0435 \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f MySQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0438\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u043e \u043f\u0435\u0447\u0430\u043b\u044c\u043d\u044b\u043c \u0444\u0430\u043a\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0440\u0435\u0434\u043a\u043e \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 EXPLAIN \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u0441\u044c \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<h4>\u0427\u0442\u043e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 EXPLAIN?<\/h4>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 EXPLAIN \u043f\u0440\u043e\u0441\u0442\u043e. \u0415\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0435\u0440\u0435\u0434 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u043c SELECT. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439.<\/p>\n<p>  ********************** 1. row **********************<br \/>  id: 1<br \/>  select_type: SIMPLE<br \/>  table: categories<br \/>  type: ALL<br \/>  possible_keys: NULL<br \/>  key: NULL<br \/>  key_len: NULL<br \/>  ref: NULL<br \/>  rows: 4<br \/>  Extra: <br \/>  1 row in set (0.00 sec)<\/p>\n<p>  \u0412\u044b\u0432\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u043e\u0447\u044c-\u0432-\u0442\u043e\u0447\u044c \u0442\u0430\u043a, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0432 \u043d\u0435\u043c \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u0442\u0435 \u0436\u0435 10 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432. \u0427\u0442\u043e \u0436\u0435 \u044d\u0442\u043e \u0437\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b?<\/p>\n<ul>\n<li>id \u2013 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e SELECT\u2019\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u043a\u043e\u0433\u0434\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432)<\/li>\n<li>select_type \u2013 \u0442\u0438\u043f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 SELECT.\n<ul>\n<li>SIMPLE \u2014 \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 SELECT \u0431\u0435\u0437 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u043b\u0438 UNION\u2019\u043e\u0432<\/li>\n<li>PRIMARY \u2013 \u0434\u0430\u043d\u043d\u044b\u0439 SELECT \u2013 \u0441\u0430\u043c\u044b\u0439 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 JOIN\u2019\u0435<\/li>\n<li>DERIVED \u2013 \u0434\u0430\u043d\u043d\u044b\u0439 SELECT \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 FROM <\/li>\n<li>SUBQUERY \u2013 \u043f\u0435\u0440\u0432\u044b\u0439 SELECT \u0432 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0435<\/li>\n<li>DEPENDENT SUBQUERY \u2013 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/li>\n<li>UNCACHABLE SUBQUERY \u2013 \u043d\u0435 \u043a\u0435\u0448\u0438\u0440\u0443\u0435\u043c\u044b\u0439 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441 (\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0440\u043e\u0441 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f)<\/li>\n<li>UNION \u2013 \u0432\u0442\u043e\u0440\u043e\u0439 \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 SELECT \u0432 UNION\u2019\u0435<\/li>\n<li>DEPENDENT UNION \u2013 \u0432\u0442\u043e\u0440\u043e\u0439 \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 SELECT \u0432 UNION\u2019\u0435, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439 \u043e\u0442 \u0432\u043d\u0435\u0448\u043d\u0435\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/li>\n<li>UNION RESULT \u2013 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 UNION\u2019\u0430<\/li>\n<\/ul>\n<p>  <\/li>\n<li>Table \u2013 \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430<\/li>\n<li>Type \u2014 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a MySQL \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u042d\u0442\u043e \u043e\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u043f\u043e\u043b\u0435\u0439 \u0432 \u0432\u044b\u0432\u043e\u0434\u0435 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043e\u0431 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0445 \u0438\u043b\u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u043d \u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u043d. <br \/>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f:\n<ul>\n<li>System \u2013 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443<\/li>\n<li>Const \u2013 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u043c\u0435\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u0430. \u042d\u0442\u043e \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u0442\u0438\u043f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u0445 \u043a\u0430\u043a \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430.<\/li>\n<li>Eq_ref \u2013 \u0432\u0441\u0435 \u0447\u0430\u0441\u0442\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b: PRIMARY KEY \u0438\u043b\u0438 UNIQUE NOT NULL. \u042d\u0442\u043e \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0438\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0442\u0438\u043f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f.<\/li>\n<li>Ref \u2013 \u0432\u0441\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u0441\u0442\u0440\u043e\u043a \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u042d\u0442\u043e\u0442 \u0442\u0438\u043f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 = \u0438\u043b\u0438 &lt; = &gt;<\/li>\n<li>Fulltext \u2013 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b<\/li>\n<li>Ref_or_null \u2013 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 ref, \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c null \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u0430<\/li>\n<li>Index_merge \u2013 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430. \u0421\u0442\u043e\u043b\u0431\u0435\u0446 key \u0432\u044b\u0432\u043e\u0434\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b EXPLAIN \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432.<\/li>\n<li>Unique_subquery \u2013 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441 IN \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447.<\/li>\n<li>Index_Subquery \u2013 \u0442\u043e\u0436\u0435, \u0447\u0442\u043e \u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439, \u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.<\/li>\n<li>Range \u2013 \u0438\u043d\u0434\u0435\u043a\u0441, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435, \u043e\u0431\u044b\u0447\u043d\u043e, \u043a\u043e\u0433\u0434\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043e\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u0432\u0440\u043e\u0434\u0435: BETWEEN, IN, &gt;, &gt;=, etc.<\/li>\n<li>Index \u2013 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u0435 \u0434\u0435\u0440\u0435\u0432\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0440\u043e\u043a.<\/li>\n<li>All \u2013 \u0414\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u042d\u0442\u043e \u043d\u0430\u0438\u0445\u0443\u0434\u0448\u0438\u0439 \u0442\u0438\u043f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435.<\/li>\n<\/ul>\n<p>  <\/li>\n<li>Possible_keys \u2013 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0430 \u043c\u043e\u0433\u0443\u0442 \u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u044d\u0442\u043e\u0442 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0441\u043b\u0443\u0436\u0438\u0442\u044c \u0434\u043e\u0431\u0440\u0443\u044e \u0441\u043b\u0443\u0436\u0431\u0443 \u0432 \u0434\u0435\u043b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0442.\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 NULL \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0438\u043d\u0434\u0435\u043a\u0441\u0430 .<\/li>\n<li>Key \u2013 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 MySQL, \u0438\u043d\u0434\u0435\u043a\u0441. \u042d\u0442\u043e\u0442 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441, \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 possible_keys. \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 MySQL \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0449\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u043a\u043b\u044e\u0447\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u044b \u0432 possible_keys, \u043d\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/li>\n<li>Key_len \u2013 \u0434\u043b\u0438\u043d\u0430 \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 MySQL \u0432\u044b\u0431\u0440\u0430\u043b \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 key_len, \u0440\u0430\u0432\u043d\u043e\u0435 4, \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f 4 \u0437\u043d\u0430\u043a\u043e\u0432. \u041d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u0432\u043e\u0442 \u0441\u0441\u044b\u043b\u043a\u0430 \u2014 vhttp:\/\/dev.mysql.com\/doc\/refman\/5.0\/en\/storage-requirements.html <\/li>\n<li>Ref \u2013 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0438\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0432 \u043f\u043e\u043b\u0435 key. MySQL \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u043b\u0438\u0431\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, \u043b\u0438\u0431\u043e \u0441\u0430\u043c\u043e \u043f\u043e\u043b\u0435, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u043f\u043b\u0430\u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/li>\n<li>Rows \u2013 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e\u0435 \u043f\u043e\u043b\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0434\u0430\u0435\u0442 \u043f\u043e\u0432\u043e\u0434 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 JOIN\u2019\u044b \u0438 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/li>\n<li>Extra \u2013 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0443\u044e\u0441\u044f \u043a \u043f\u043b\u0430\u043d\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0422\u0430\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043a \u201cUsing temporary\u201d, \u201cUsing filesort\u201d \u0438 \u0442.\u0434 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0421 \u043f\u043e\u043b\u043d\u044b\u043c \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0437\u0434\u0435\u0441\u044c \u2014 <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.6\/en\/explain-output.html#explain-extra-information\">dev.mysql.com\/doc\/refman\/5.6\/en\/explain-output.html#explain-extra-information<\/a><\/li>\n<\/ul>\n<p>  \u041f\u043e\u0441\u043b\u0435 EXPLAIN \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e EXTENDED \u0438 MySQL \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0432\u0430\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441. \u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 EXTENDED \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 SHOW WARNINGS. \u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>  <code>EXPLAIN EXTENDED SELECT City.Name FROM City JOIN Country ON (City.CountryCode = Country.Code) WHERE City.CountryCode = 'IND' AND Country.Continent = 'Asia'<\/code><\/p>\n<p>  ********************** 1. row **********************<br \/>  id: 1<br \/>  select_type: SIMPLE<br \/>  table: Country<br \/>  type: const<br \/>  possible_keys: PRIMARY<br \/>  key: PRIMARY<br \/>  key_len: 3<br \/>  ref: const<br \/>  rows: 1<br \/>  filtered: 100.00<br \/>  Extra: <br \/>  ********************** 2. row **********************<br \/>   id: 1<br \/>   select_type: SIMPLE<br \/>   table: City<br \/>   type: ALL<br \/>  possible_keys: NULL<br \/>   key: NULL<br \/>   key_len: NULL<br \/>   ref: NULL<br \/>   rows: 4079<br \/>   filtered: 100.00<br \/>   Extra: Using where<br \/>  2 rows in set, 1 warning (0.00 sec)<\/p>\n<p>  <code>SHOW WARNINGS<\/code><\/p>\n<p>  ********************** 1. row **********************<br \/>   Level: Note<br \/>   Code: 1003<br \/>  Message: select `World`.`City`.`Name` AS `Name` from `World`.`City` join `World`.`Country` where ((`World`.`City`.`CountryCode` = &#8216;IND&#8217;))<br \/>  1 row in set (0.00 sec)<\/p>\n<h4>\u041f\u043e\u0438\u0441\u043a \u0438 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e EXPLAIN.<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u043e, \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0448\u0443\u0441\u0442\u0440\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044f \u0432\u044b\u0432\u043e\u0434 \u043a\u043e\u043c\u0430\u043d\u0434\u044b EXPLAIN. \u041d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u044f\u0434 \u0442\u0430\u0431\u043b\u0438\u0446 \u0441\u043e \u043c\u043d\u043e\u0433\u0438\u043c\u0438 \u0441\u0432\u044f\u0437\u044f\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>  \u042f \u0441\u043e\u0437\u0434\u0430\u043b \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u0442\u043e\u0440\u0433\u043e\u0432\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438\u043b\u0438 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439, \u0438 \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u201c\u0441\u0442\u0440\u0430\u0448\u043d\u044b\u0445\u201d \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0414\u0430\u043c\u043f \u044d\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u2014 <a href=\"https:\/\/github.com\/phpmasterdotcom\/UsingExplainToWriteBetterMySQLQueries\">github.com\/phpmasterdotcom\/UsingExplainToWriteBetterMySQLQueries<\/a> <\/p>\n<p>  EXPLAIN SELECT * FROM<br \/>  orderdetails d<br \/>  INNER JOIN orders o ON d.orderNumber = o.orderNumber<br \/>  INNER JOIN products p ON p.productCode = d.productCode<br \/>  INNER JOIN productlines l ON p.productLine = l.productLine<br \/>  INNER JOIN customers c on c.customerNumber = o.customerNumber<br \/>  WHERE o.orderNumber = 10101<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 (\u043d\u0430 \u043d\u0435\u0433\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435, \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0432\u044b\u0448\u0435 \u043b\u0435\u0436\u0438\u0442 \u0434\u0430\u043c\u043f \u0441 \u0443\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438), \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432\u0441\u0435 \u0441\u0438\u043c\u043f\u0442\u043e\u043c\u044b \u043f\u043b\u043e\u0445\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041d\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044f \u043d\u0430\u043f\u0438\u0448\u0443 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043b\u0443\u0447\u0448\u0435, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0442\u0435\u043c \u0436\u0435 \u0441\u0430\u043c\u044b\u043c, \u043f\u043e\u043a\u0430 \u044f \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044e \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. \u0423\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f ALL (\u0445\u0443\u0434\u0448\u0438\u0439), \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e MySQL \u043d\u0435 \u0441\u043c\u043e\u0433 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u043c\u043e\u0433 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438. \u041e\u0442\u0441\u044e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438 \u0442\u043e, \u0447\u0442\u043e possible_keys \u0438 key \u0438\u043c\u0435\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 NULL. \u0421\u0430\u043c\u044b\u043c \u0432\u0430\u0436\u043d\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0435 rows \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e MySQL \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u0430 \u043f\u0440\u043e\u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 7 \u00d7 110 \u00d7 122 \u00d7 326 \u00d7 2996 = 91,750,822,240 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 (\u0443\u0431\u0435\u0440\u0438\u0442\u0435 \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 EXPLAIN, \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0441\u0430\u043c\u0438). \u042d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u0445\u043e\u0440\u043e\u0448\u043e \u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u044d\u0442\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u044d\u043a\u0441\u043f\u043e\u043d\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043c\u0435\u0440\u0435 \u0440\u043e\u0441\u0442\u0430 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u0442\u0430\u043a\u0438\u0435, \u043a\u0430\u043a \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0435\u0449\u0435 \u0440\u0430\u0437. \u0412\u0437\u044f\u0432 \u044d\u0442\u043e \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u0432 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 JOIN\u2019\u0430\u0445, \u0442.\u043a. MySQL \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0438\u0445 \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439.<\/p>\n<p>  ALTER TABLE customers<br \/>   ADD PRIMARY KEY (customerNumber);<br \/>  ALTER TABLE employees<br \/>   ADD PRIMARY KEY (employeeNumber);<br \/>  ALTER TABLE offices<br \/>   ADD PRIMARY KEY (officeCode);<br \/>  ALTER TABLE orderdetails<br \/>   ADD PRIMARY KEY (orderNumber, productCode);<br \/>  ALTER TABLE orders<br \/>   ADD PRIMARY KEY (orderNumber),<br \/>   ADD KEY (customerNumber);<br \/>  ALTER TABLE payments<br \/>   ADD PRIMARY KEY (customerNumber, checkNumber);<br \/>  ALTER TABLE productlines<br \/>   ADD PRIMARY KEY (productLine);<br \/>  ALTER TABLE products <br \/>   ADD PRIMARY KEY (productCode),<br \/>   ADD KEY (buyPrice),<br \/>   ADD KEY (productLine);<br \/>  ALTER TABLE productvariants <br \/>   ADD PRIMARY KEY (variantId),<br \/>   ADD KEY (buyPrice),<br \/>   ADD KEY (productCode);<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043d\u0430\u0448 \u043f\u0440\u0435\u0436\u043d\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u044d\u0442\u043e:<\/p>\n<p>  ********************** 1. row **********************<br \/>   id: 1<br \/>   select_type: SIMPLE<br \/>   table: o<br \/>   type: const<br \/>  possible_keys: PRIMARY,customerNumber<br \/>   key: PRIMARY<br \/>   key_len: 4<br \/>   ref: const<br \/>   rows: 1<br \/>   Extra: <br \/>  ********************** 2. row **********************<br \/>   id: 1<br \/>   select_type: SIMPLE<br \/>   table: c<br \/>   type: const<br \/>  possible_keys: PRIMARY<br \/>   key: PRIMARY<br \/>   key_len: 4<br \/>   ref: const<br \/>   rows: 1<br \/>   Extra: <br \/>  ********************** 3. row **********************<br \/>   id: 1<br \/>   select_type: SIMPLE<br \/>   table: d<br \/>   type: ref<br \/>  possible_keys: PRIMARY<br \/>   key: PRIMARY<br \/>   key_len: 4<br \/>   ref: const<br \/>   rows: 4<br \/>   Extra: <br \/>  ********************** 4. row **********************<br \/>   id: 1<br \/>   select_type: SIMPLE<br \/>   table: p<br \/>   type: eq_ref<br \/>  possible_keys: PRIMARY,productLine<br \/>   key: PRIMARY<br \/>   key_len: 17<br \/>   ref: classicmodels.d.productCode<br \/>   rows: 1<br \/>   Extra: <br \/>  ********************** 5. row **********************<br \/>   id: 1<br \/>   select_type: SIMPLE<br \/>   table: l<br \/>   type: eq_ref<br \/>  possible_keys: PRIMARY<br \/>   key: PRIMARY<br \/>   key_len: 52<br \/>   ref: classicmodels.p.productLine<br \/>   rows: 1<br \/>   Extra: <br \/>  5 rows in set (0.00 sec)<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0447\u0438\u0441\u043b\u043e \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0443\u043f\u0430\u043b\u043e \u0434\u043e 1 \u00d7 1 \u00d7 4 \u00d7 1 \u00d7 1 = 4 \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 order_number = 10101 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 orderdetails \u2013 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e MySQL \u0441\u043c\u043e\u0433\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432\u043e \u0432\u0441\u0435\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438 \u043d\u0435 \u0441\u0442\u0430\u043b\u0430 \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u0442\u044c \u043a \u043f\u043e\u043b\u043d\u043e\u043c\u0443 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<p>  \u0412 \u043f\u0435\u0440\u0432\u043e\u043c \u0432\u044b\u0432\u043e\u0434\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0442\u0438\u043f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u2013 \u201cconst\u201d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0442\u0438\u043f\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0441 \u0431\u043e\u043b\u0435\u0435, \u0447\u0435\u043c \u043e\u0434\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e. MySQL \u0441\u043c\u043e\u0433\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c PRIMARY KEY \u043a\u0430\u043a \u0438\u043d\u0434\u0435\u043a\u0441. \u0412 \u043f\u043e\u043b\u0435 \u201cref\u201d \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u201cconst\u201d, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0438 \u0447\u0442\u043e \u0438\u043d\u043e\u0435, \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 10101, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043f\u043e\u0441\u043b\u0435 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 WHERE.<\/p>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441. \u0412 \u043d\u0435\u043c \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, products \u0438 productvariants, \u043a\u0430\u0436\u0434\u0430\u044f \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0430 \u0441 productline. productvariants, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432 \u0441 \u043f\u043e\u043b\u0435\u043c productCode \u2013 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u0438\u0445 \u0446\u0435\u043d\u044b.<\/p>\n<p>  EXPLAIN SELECT * FROM (<br \/>  SELECT p.productName, p.productCode, p.buyPrice, l.productLine, p.status, l.status AS lineStatus FROM<br \/>  products p<br \/>  INNER JOIN productlines l ON p.productLine = l.productLine<br \/>  UNION<br \/>  SELECT v.variantName AS productName, v.productCode, p.buyPrice, l.productLine, p.status, l.status AS lineStatus FROM productvariants v<br \/>  INNER JOIN products p ON p.productCode = v.productCode<br \/>  INNER JOIN productlines l ON p.productLine = l.productLine<br \/>  ) products<br \/>  WHERE status = &#8216;Active&#8217; AND lineStatus = &#8216;Active&#8217; AND buyPrice BETWEEN 30 AND 50<br \/>  ********************** 1. row **********************<br \/>   id: 1<br \/>   select_type: PRIMARY<br \/>   table:  type: ALL<br \/>  possible_keys: NULL<br \/>   key: NULL<br \/>   key_len: NULL<br \/>   ref: NULL<br \/>   rows: 219<br \/>   Extra: Using where<br \/>  ********************** 2. row **********************<br \/>   id: 2<br \/>   select_type: DERIVED<br \/>   table: p<br \/>   type: ALL<br \/>  possible_keys: NULL<br \/>   key: NULL<br \/>   key_len: NULL<br \/>   ref: NULL<br \/>   rows: 110<br \/>   Extra: <br \/>  ********************** 3. row **********************<br \/>   id: 2<br \/>   select_type: DERIVED<br \/>   table: l<br \/>   type: eq_ref<br \/>  possible_keys: PRIMARY<br \/>   key: PRIMARY<br \/>   key_len: 52<br \/>   ref: classicmodels.p.productLine<br \/>   rows: 1<br \/>   Extra: <br \/>  ********************** 4. row **********************<br \/>   id: 3<br \/>   select_type: UNION<br \/>   table: v<br \/>   type: ALL<br \/>  possible_keys: NULL<br \/>   key: NULL<br \/>   key_len: NULL<br \/>   ref: NULL<br \/>   rows: 109<br \/>   Extra: <br \/>  ********************** 5. row **********************<br \/>   id: 3<br \/>   select_type: UNION<br \/>   table: p<br \/>   type: eq_ref<br \/>  possible_keys: PRIMARY<br \/>   key: PRIMARY<br \/>   key_len: 17<br \/>   ref: classicmodels.v.productCode<br \/>   rows: 1<br \/>   Extra: <br \/>  ********************** 6. row **********************<br \/>   id: 3<br \/>   select_type: UNION<br \/>   table: l<br \/>   type: eq_ref<br \/>  possible_keys: PRIMARY<br \/>   key: PRIMARY<br \/>   key_len: 52<br \/>   ref: classicmodels.p.productLine<br \/>   rows: 1<br \/>   Extra: <br \/>  ********************** 7. row **********************<br \/>   id: NULL<br \/>   select_type: UNION RESULT<br \/>   table: &lt;union2,3&gt;<br \/>   type: ALL<br \/>  possible_keys: NULL<br \/>   key: NULL<br \/>   key_len: NULL<br \/>   ref: NULL<br \/>   rows: NULL<br \/>   Extra: <br \/>  7 rows in set (0.01 sec)<\/p>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0440\u044f\u0434 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432 \u044d\u0442\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435. \u041e\u043d \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 products \u0438 productvarians. \u0422.\u043a. \u0432 \u044d\u0442\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u043d\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 productLine \u0438 buyPrice, \u0432 \u043f\u043e\u043b\u044f\u0445 possible_keys \u0438 key \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f NULL. \u0421\u0442\u0430\u0442\u0443\u0441 \u0442\u0430\u0431\u043b\u0438\u0446 products \u0438 productlines \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 UNION\u2019\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0438\u0445 \u0432\u043d\u0443\u0442\u0440\u0438 UNION\u2019\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442 \u0447\u0438\u0441\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u044b.<\/p>\n<p>  CREATE INDEX idx_buyPrice ON products(buyPrice);<br \/>  CREATE INDEX idx_buyPrice ON productvariants(buyPrice);<br \/>  CREATE INDEX idx_productCode ON productvariants(productCode);<br \/>  CREATE INDEX idx_productLine ON products(productLine);<\/p>\n<p>  EXPLAIN SELECT * FROM (<br \/>  SELECT p.productName, p.productCode, p.buyPrice, l.productLine, p.status, l.status as lineStatus FROM products p<br \/>  INNER JOIN productlines AS l ON (p.productLine = l.productLine AND p.status = &#8216;Active&#8217; AND l.status = &#8216;Active&#8217;) <br \/>  WHERE buyPrice BETWEEN 30 AND 50<br \/>  UNION<br \/>  SELECT v.variantName AS productName, v.productCode, p.buyPrice, l.productLine, p.status, l.status FROM productvariants v<br \/>  INNER JOIN products p ON (p.productCode = v.productCode AND p.status = &#8216;Active&#8217;) <br \/>  INNER JOIN productlines l ON (p.productLine = l.productLine AND l.status = &#8216;Active&#8217;)<br \/>  WHERE<br \/>  v.buyPrice BETWEEN 30 AND 50<br \/>  ) product<\/p>\n<p>  ********************** 1. row **********************<br \/>   id: 1<br \/>   select_type: PRIMARY<br \/>   table:  type: ALL<br \/>  possible_keys: NULL<br \/>   key: NULL<br \/>   key_len: NULL<br \/>   ref: NULL<br \/>   rows: 12<br \/>   Extra: <br \/>  ********************** 2. row **********************<br \/>   id: 2<br \/>   select_type: DERIVED<br \/>   table: p<br \/>   type: range<br \/>  possible_keys: idx_buyPrice,idx_productLine<br \/>   key: idx_buyPrice<br \/>   key_len: 8<br \/>   ref: NULL<br \/>   rows: 23<br \/>   Extra: Using where<\/p>\n<p>  ********************** 3. row **********************<br \/>   id: 2<br \/>   select_type: DERIVED<br \/>   table: l<br \/>   type: eq_ref<br \/>  possible_keys: PRIMARY<br \/>   key: PRIMARY<br \/>   key_len: 52<br \/>   ref: classicmodels.p.productLine<br \/>   rows: 1<br \/>   Extra: Using where<\/p>\n<p>  ********************** 4. row **********************<br \/>   id: 3<br \/>   select_type: UNION<br \/>   table: v<br \/>   type: range<br \/>  possible_keys: idx_buyPrice,idx_productCode<br \/>   key: idx_buyPrice<br \/>   key_len: 9<br \/>   ref: NULL<br \/>   rows: 1<br \/>   Extra: Using where<\/p>\n<p>  ********************** 5. row **********************<br \/>   id: 3<br \/>   select_type: UNION<br \/>   table: p<br \/>   type: eq_ref<br \/>  possible_keys: PRIMARY,idx_productLine<br \/>   key: PRIMARY<br \/>   key_len: 17<br \/>   ref: classicmodels.v.productCode<br \/>   rows: 1<br \/>   Extra: Using where<\/p>\n<p>  ********************** 6. row **********************<br \/>   id: 3<br \/>   select_type: UNION<br \/>   table: l<br \/>   type: eq_ref<br \/>  possible_keys: PRIMARY<br \/>   key: PRIMARY<br \/>   key_len: 52<br \/>   ref: classicmodels.p.productLine<br \/>   rows: 1<br \/>   Extra: Using where<\/p>\n<p>  ********************** 7. row **********************<br \/>   id: NULL<br \/>   select_type: UNION RESULT<br \/>   table: &lt;union2,3&gt;<br \/>   type: ALL<br \/>  possible_keys: NULL<br \/>   key: NULL<br \/>   key_len: NULL<br \/>   ref: NULL<br \/>   rows: NULL<br \/>   Extra: <br \/>  7 rows in set (0.01 sec)<\/p>\n<p>  \u041a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043b\u043e\u0441\u044c \u0441 2,625,810 (219 \u00d7 110 \u00d7 109) \u0434\u043e 276 (12 \u00d7 23), \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u0435\u043c \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u044d\u0442\u043e\u0442 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0435\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432, \u0432\u044b \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. MySQL \u043d\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u044b, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f WHERE. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 UNION \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. MySQL \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0432\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b. (http:\/\/www.php.su\/mysql\/manual\/?page=MySQL_indexes \u2013 \u0434\u043e\u043f. \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f).<\/p>\n<h4>\u0418\u0442\u043e\u0433<\/h4>\n<p>  \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e EXPLAIN, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u043b\u044f \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u0434\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u0430, \u0447\u0435\u043c \u0432 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043d\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u0445. \u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0440\u044f\u0434 \u0442\u0430\u0431\u043b\u0438\u0446 \u0432\u043c\u0435\u0441\u0442\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u0441 WHERE. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0443\u0442 \u043a \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0430\u0448\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/211022\/\"> http:\/\/habrahabr.ru\/post\/211022\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">       \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0435 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u0437\u0430\u043f\u0440\u043e\u0441, \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 MySQL \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043b\u0430\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u0430\u043c\u044b\u0439 \u043f\u043b\u0430\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c EXPLAIN. EXPLAIN \u2013 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u043c\u043e\u0449\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u0432\u0430\u0448\u0435 \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f MySQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0438\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u043e \u043f\u0435\u0447\u0430\u043b\u044c\u043d\u044b\u043c \u0444\u0430\u043a\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0440\u0435\u0434\u043a\u043e \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 EXPLAIN \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u0441\u044c \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.  <\/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-211022","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/211022","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=211022"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/211022\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211022"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211022"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211022"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}