{"id":328318,"date":"2022-01-20T15:00:14","date_gmt":"2022-01-20T15:00:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=328318"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=328318","title":{"rendered":"<span>\u0421 \u0447\u0435\u043c \u043a\u0443\u0448\u0430\u0442\u044c Irregular Selectivity \u0432 MSSQL \u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u044d\u0442\u043e \u043d\u0430\u0448\u0438\u043c \u0431\u0440\u0430\u0442\u044c\u044f\u043c \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435, \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f MSSQL, \u0430 \u0442\u0430\u043a\u0436\u0435 Postgres \u0438 MySQL. \u0415\u0441\u043b\u0438 \u0442\u0435\u043c\u0430 \u0432\u0430\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u0430, \u043f\u0435\u0440\u0435\u043c\u0430\u0442\u044b\u0432\u0430\u0439\u0442\u0435 \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0433\u043b\u0430\u0432\u0435.<\/p>\n<p>\u0412 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435, \u0435\u0441\u043b\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 100K, \u0442\u043e \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e 10 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u041d\u043e \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0430\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0437\u0430\u0442\u0435\u0441\u0430\u043b\u043e\u0441\u044c \u043e\u0441\u043e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, NULL, \u043f\u0440\u043e\u0431\u0435\u043b \u0438\u043b\u0438 &#8216;n\/a&#8217;? \u0414\u043b\u044f SQL optimizier \u044d\u0442\u043e \u0433\u043e\u043b\u043e\u0432\u043d\u0430\u044f \u0431\u043e\u043b\u044c. \u0414\u043b\u044f \u0432\u0430\u0441 \u0442\u043e\u0436\u0435.<\/p>\n<h2>\u041a\u0430\u043a \u0442\u0430\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f?<\/h2>\n<p>\u0412\u044b\u0434\u0435\u043b\u044e \u043f\u044f\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d (\u043c\u043e\u0436\u0435\u0442, \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u0431\u043e\u043b\u044c\u0448\u0435?)<\/p>\n<p><strong>\u0422\u0430\u043a\u043e\u0432\u0430 \u0436\u0438\u0437\u043d\u044c<\/strong> &#8212; n\/a, \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u0442\u0434. \u0422\u0435 \u0436\u0435 \u043d\u0435\u043b\u0435\u0433\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043c\u043c\u0438\u0433\u0440\u0430\u043d\u0442\u044b, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 SSN. <\/p>\n<p><strong>\u0423\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u0435<\/strong>. \u041f\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0443\u0442\u0438 \u043c\u0430\u043b\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430<\/p>\n<p><strong>\u041a\u0438\u0442 \u0438 \u0440\u044b\u0431\u0435\u0448\u043a\u0430<\/strong>. \u0427\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u043e\u0442\u0434\u0435\u043b\u0443, \u0444\u0438\u0440\u043c\u0435, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438\u0442\u0434.<\/p>\n<p><strong>\u0421\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0440\u043e\u0441\u0442\u0430<\/strong>. \u041c\u044b \u0437\u0430\u0432\u0435\u043b\u0438 \u0432 \u0431\u0430\u0437\u0435 &#8216;department id&#8217; \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u043e\u0432, \u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u043b\u0433\u043e \u0431\u044b\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u0442 \u0441\u0442\u0430\u043b\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435<\/p>\n<p><strong>\u0418\u0441\u043a\u0443\u0441c\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/strong>. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0431\u0430\u0437\u044b \u0432 DEV \u043f\u0440\u0438 \u043b\u0435\u043d\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u042d\u0442\u043e \u043f\u043e\u0442\u043e\u043c \u0430\u0443\u043a\u043d\u0435\u0442\u0441\u044f \u043d\u0430 PROD.<\/p>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0438 <em>\u043a\u0438\u0442 \u0438 \u0440\u044b\u0431\u0435\u0448\u043a\u0430<\/em> \u0438 <em>\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0440\u043e\u0441\u0442\u0430<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0445\u043e\u0436\u0438 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430. \u041c\u044b, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043d\u0438\u0436\u0435, \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0435\u0442\u043a\u0443 \u0434\u043b\u044f &#8216;n\/a&#8217;, \u043d\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c hardcode id &#8216;\u043a\u0438\u0442\u0430&#8217; \u0432 \u043a\u043e\u0434\u0435, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0447\u0442\u043e \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u044f\u0446\u0438\u044f\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u043c\u0438.<\/p>\n<h2>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0435\u043c\u043e \u043f\u0440\u0438\u043c\u0435\u0440<\/h2>\n<pre><code class=\"sql\">create table Unlucky (   n int identity primary key,    VAL varchar(32),    somethingElse varchar(128)) GO set nocount on declare @n int=1000000 while @n>0 begin    set @n=@n-1    insert into Unlucky select convert(varchar,@n\/10)+'val',     convert(varchar,@n)+convert(varchar,@n)     +convert(varchar,@n)+convert(varchar,@n)   end GO update Unlucky set VAL='n\/a' where n%2=1 GO create index VAL on Unlucky (val) GO<\/code><\/pre>\n<p>\u0412 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0435 \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043d\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 val=&#8217;n\/a&#8217;, \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0443 \u043d\u0430\u0441 5 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"238\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/145\/dfc\/2c7\/145dfc2c70d226eb1e2cfec7c119c146.png\" data-width=\"574\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u041f\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c<\/h2>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"501\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/59a\/8bd\/c9e\/59a8bdc9e2a28cb35d755af986e481aa.png\" data-width=\"557\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c, SQL server \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u043c\u043d\u044b\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u043d\u0430. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443:<\/p>\n<pre><code class=\"sql\">create procedure GetVal @val varchar(32) as    select * from Unlucky where val=@val GO<\/code><\/pre>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"442\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/47a\/d19\/a26\/47ad19a26fd05cf3a8806366e72a5200.png\" data-width=\"783\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u043a\u0430 \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440e\u043a\u0440\u0430\u0441\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e SQL server \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u044f\u0432\u043d\u043e, \u043a\u0430\u043a \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/www.sqlshack.com\/sql-server-2016-parameter-sniffing\/\" rel=\"noopener noreferrer nofollow\">parameter sniffing. <\/a><\/p>\n<h2>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043e \u0433\u0440\u0443\u0441\u0442\u043d\u043e\u043c.<\/h2>\n<p>\u041d\u043e parameter sniffing \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u0442\u044c. <\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"498\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/05c\/77d\/ea4\/05c77dea41d4acfc02591beed16d9ea3.png\" data-width=\"682\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418 \u0432\u043e\u0442 \u0443\u0436\u0435 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f index seek. \u0410 \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0441 n\/a:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"404\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e7d\/1e1\/431\/e7d1e1431176e94b53ddd409ed08ae5e.png\" data-width=\"719\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u043c \u0432\u0441\u0442\u0430\u043b, \u0442\u043e\u0433\u043e \u0438 \u0442\u0430\u043f\u043a\u0438. \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 SQL server, \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0438\u043b\u0438 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043b\u0430\u043d SQL server \u043c\u043e\u0436\u0435\u0442 &#8216;\u0437\u0430\u0441\u0442\u0440\u044f\u0442\u044c&#8217; \u0432 &#8216;\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c&#8217; \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0445\u0432\u0430\u0442\u0430\u0442\u044c\u0441\u044f \u0437\u0430 <s>\u043c\u043e\u043b\u043e\u0442\u043e\u043a<\/s> <em>freeproccache<\/em>. \u0422\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>poisoned execution plan<\/em>.<\/p>\n<h2>\u0418 \u043a\u0430\u043a \u0441 \u044d\u0442\u0438\u043c \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f?<\/h2>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0442\u043a\u0438 \u0434\u043b\u044f \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"sql\">create procedure SmartGetVal @val varchar(32) as    if @val='n\/a'      select * from Unlucky where val='n\/a' -- not @val!!!   else     select * from Unlucky where val=@val GO<\/code><\/pre>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e SQL:<\/p>\n<pre><code class=\"sql\">create procedure DynGetVal @val varchar(32) as    declare @sql varchar(1000)   set @sql='select * from Unlucky where val='''+@val+''''   exec(@sql) GO<\/code><\/pre>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430\u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e (SQL injection, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u0442\u0434), \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0434\u043b\u044f OLAP\/Reporting \u0441\u0438\u0441\u0442\u0435\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0443\u043a\u0430\u0437\u0430\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u043b\u0438 \u043d\u0435\u0442 \u0432\u0435\u043b\u0438\u043a\u043e. \u0418 \u0443\u0436 \u0442\u043e\u0447\u043d\u043e \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043b\u044e\u0431\u0438\u043c\u043e\u0433\u043e \u043f\u0440\u0438\u0435\u043c\u0430 \u0434\u0435\u0432\u0435\u043b\u043e\u043f\u0435\u0440\u043e\u0432, \u043f\u0440\u043e\u043a\u043b\u0438\u043d\u0430\u0435\u043c\u043e\u0433\u043e \u0432\u0441\u0435\u043c\u0438 DBA:<\/p>\n<pre><code class=\"sql\">where ...   and (@userid IS NULL or userid=@userid)   and (@companyid IS NULL or companyid=@companyid)   and (@deptid IS NULL or deptid=@deptid) <\/code><\/pre>\n<figure class=\"\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"202\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4df\/7c0\/4fd\/4df7c04fd585c6c956aac118757ca6d9.png\" data-width=\"300\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 query hints <strong>OPTION(RECOMPILE)<\/strong> &#8212; \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043a\u0432\u0435\u0440\u0435\u0439 \u043d\u043e \u0442\u0440\u0430\u0442\u0438\u0442\u044c 100-500ms \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442. <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0445\u0438\u043d\u0442\u044b <strong>OPTION(OPTIMIZE FOR UNKNOWN)<\/strong> \u0438 <strong>OPTION (OPTIMIZE FOR @var=value,&#8230;)<\/strong> <\/p>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f irregular selectivity<\/h2>\n<p>\u0414\u043b\u044f MS SQL \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u043f\u043e \u0432\u0441\u0435\u043c \u0446\u0435\u043b\u044b\u043c \u0438 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c (\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u043d\u043d\u044b\u043c) \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442 selectivity report:<\/p>\n<figure class=\"full-width\"><img decoding=\"async\" src=\"\/img\/image-loader.svg\" height=\"205\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/326\/654\/538\/32665453820be6f460133ec8d264322b.png\" data-width=\"658\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043d\u0435 \u043d\u0443\u0436\u0434\u0430\u044e\u0442\u0441\u044f, \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a: \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0430\u043c\u043e\u0435 \u0447\u0430\u0441\u0442\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430 &#8212; \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445. \u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043b\u0430 \u0431\u043e\u043b\u0435\u0435 30%, \u0442\u043e \u044d\u0442\u043e \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442 \u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<\/p>\n<p>\u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0441 \u043c\u0430\u043b\u043e\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043d\u0435 \u0441\u0442\u043e\u0438\u0442.<\/p>\n<p>\u0412\u0430\u0441 \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0443\u0434\u0438\u0432\u043b\u044f\u0435\u0442, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a HTML \u0442\u0430\u0431\u043b\u0438\u0446\u0430? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u044c <a href=\"https:\/\/www.actionatdistance.com\/mission\" rel=\"noopener noreferrer nofollow\">\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/a>. \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u0434\u043b\u044f MSSQL \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<details class=\"spoiler\">\n<summary>&#8216;standalone&#8217; \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f MSSQL, \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"sql\">declare @tab varchar(128) = 'tablename' declare @s varchar(128), @sql varchar(max), @rows bigint select @rows=max(rowcnt) from sysindexes where id=OBJECT_ID(@tab) if @rows=0 set @rows=1 create table #res (s varchar(128), cnt int) create table #tp (s varchar(128), topper int) DECLARE cols CURSOR FOR select name from syscolumns where id=OBJECT_ID(@tab)    and xtype in (48,52,56,127,167,231,239,175,108) and length&lt;=256 OPEN cols; FETCH NEXT FROM cols into @s; WHILE @@FETCH_STATUS = 0 BEGIN   set @sql='insert into #res select '''+@s+''',(select count(distinct ['+@s+']) from ['+@tab+'])'   print @sql   exec (@sql)   set @sql='insert into #tp select '''+@s+''',(select top 1 count(*) from ['+@tab+'] group by ['+@s+'] order by 1 desc)'   print @sql   exec (@sql)   FETCH NEXT FROM cols into @s; END CLOSE cols; DEALLOCATE cols; select #res.s as [Column], cnt as DistinctValues,      @rows\/case when cnt=0 then 1 else cnt end as RowsPerValueAvg,      topper as RecordsInMostFreqVal,      convert(money,topper*100.\/@rows) as PctInTop      from #res   inner join #tp on #tp.s=#res.s   order by 2 desc drop table #res drop table #tp <\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0414\u043b\u044f <a href=\"https:\/\/www.actionatdistance.com\/postgres\" rel=\"noopener noreferrer nofollow\">Postgre<\/a> \u0438 <a href=\"https:\/\/www.actionatdistance.com\/mysql\" rel=\"noopener noreferrer nofollow\">MySQL<\/a> \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u0438 \u0432 \u0441\u0430\u043c\u0438\u0445 <a href=\"https:\/\/www.actionatdistance.com\/modules\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0434\u0443\u043b\u044f\u0445<\/a>, \u0441\u043a\u0430\u0447\u0430\u0439\u0442\u0435 \u0438\u0445 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u0438 \u0438\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043b \u0441 \u0438\u043c\u0435\u043d\u0435\u043c *selectivity. , \u0440\u0430\u0432\u043d\u043e \u043a\u0430\u043a \u0438 \u0434\u043b\u044f <a href=\"https:\/\/www.actionatdistance.com\/mssql\" rel=\"noopener noreferrer nofollow\">MSSQL<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/646763\/\"> https:\/\/habr.com\/ru\/post\/646763\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u044d\u0442\u043e \u043d\u0430\u0448\u0438\u043c \u0431\u0440\u0430\u0442\u044c\u044f\u043c \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435, \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f. \u0412 \u043a\u043e\u043d\u0446\u0435 \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f MSSQL, \u0430 \u0442\u0430\u043a\u0436\u0435 Postgres \u0438 MySQL. \u0415\u0441\u043b\u0438 \u0442\u0435\u043c\u0430 \u0432\u0430\u043c \u0437\u043d\u0430\u043a\u043e\u043c\u0430, \u043f\u0435\u0440\u0435\u043c\u0430\u0442\u044b\u0432\u0430\u0439\u0442\u0435 \u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0433\u043b\u0430\u0432\u0435.<\/p>\n<p>\u0412 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435, \u0435\u0441\u043b\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 100K, \u0442\u043e \u043d\u0430 \u043a\u0430\u0436\u0434\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e 10 \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u041d\u043e \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0430\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0437\u0430\u0442\u0435\u0441\u0430\u043b\u043e\u0441\u044c \u043e\u0441\u043e\u0431\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, NULL, \u043f\u0440\u043e\u0431\u0435\u043b \u0438\u043b\u0438 &#8216;n\/a&#8217;? \u0414\u043b\u044f SQL optimizier \u044d\u0442\u043e \u0433\u043e\u043b\u043e\u0432\u043d\u0430\u044f \u0431\u043e\u043b\u044c. \u0414\u043b\u044f \u0432\u0430\u0441 \u0442\u043e\u0436\u0435.<\/p>\n<h2>\u041a\u0430\u043a \u0442\u0430\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f?<\/h2>\n<p>\u0412\u044b\u0434\u0435\u043b\u044e \u043f\u044f\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d (\u043c\u043e\u0436\u0435\u0442, \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u0431\u043e\u043b\u044c\u0448\u0435?)<\/p>\n<p><strong>\u0422\u0430\u043a\u043e\u0432\u0430 \u0436\u0438\u0437\u043d\u044c<\/strong> &#8212; n\/a, \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0438\u0442\u0434. \u0422\u0435 \u0436\u0435 \u043d\u0435\u043b\u0435\u0433\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u043c\u043c\u0438\u0433\u0440\u0430\u043d\u0442\u044b, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 SSN. <\/p>\n<p><strong>\u0423\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u0435<\/strong>. \u041f\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0443\u0442\u0438 \u043c\u0430\u043b\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430<\/p>\n<p><strong>\u041a\u0438\u0442 \u0438 \u0440\u044b\u0431\u0435\u0448\u043a\u0430<\/strong>. \u0427\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u043e\u0442\u0434\u0435\u043b\u0443, \u0444\u0438\u0440\u043c\u0435, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438\u0442\u0434.<\/p>\n<p><strong>\u0421\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0440\u043e\u0441\u0442\u0430<\/strong>. \u041c\u044b \u0437\u0430\u0432\u0435\u043b\u0438 \u0432 \u0431\u0430\u0437\u0435 &#8216;department id&#8217; \u043d\u0430 \u0431\u0443\u0434\u0443\u0449\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043c\u043d\u043e\u0433\u043e \u043e\u0442\u0434\u0435\u043b\u043e\u0432, \u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u043b\u0433\u043e \u0431\u044b\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d, \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e\u0442 \u0441\u0442\u0430\u043b\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435<\/p>\n<p><strong>\u0418\u0441\u043a\u0443\u0441c\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/strong>. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0431\u0430\u0437\u044b \u0432 DEV \u043f\u0440\u0438 \u043b\u0435\u043d\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432. \u042d\u0442\u043e \u043f\u043e\u0442\u043e\u043c \u0430\u0443\u043a\u043d\u0435\u0442\u0441\u044f \u043d\u0430 PROD.<\/p>\n<p>\u041d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0438 <em>\u043a\u0438\u0442 \u0438 \u0440\u044b\u0431\u0435\u0448\u043a\u0430<\/em> \u0438 <em>\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0440\u043e\u0441\u0442\u0430<\/em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0445\u043e\u0436\u0438 \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430. \u041c\u044b, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0436\u0435\u043c \u043d\u0438\u0436\u0435, \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0435\u0442\u043a\u0443 \u0434\u043b\u044f &#8216;n\/a&#8217;, \u043d\u043e \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c hardcode id &#8216;\u043a\u0438\u0442\u0430&#8217; \u0432 \u043a\u043e\u0434\u0435, \u0442\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0447\u0442\u043e \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u044f\u0446\u0438\u044f\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0440\u0430\u0437\u043d\u044b\u043c\u0438.<\/p>\n<h2>\u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u0435\u043c\u043e \u043f\u0440\u0438\u043c\u0435\u0440<\/h2>\n<pre><code class=\"sql\">create table Unlucky (   n int identity primary key,    VAL varchar(32),    somethingElse varchar(128)) GO set nocount on declare @n int=1000000 while @n>0 begin    set @n=@n-1    insert into Unlucky select convert(varchar,@n\/10)+'val',     convert(varchar,@n)+convert(varchar,@n)     +convert(varchar,@n)+convert(varchar,@n)   end GO update Unlucky set VAL='n\/a' where n%2=1 GO create index VAL on Unlucky (val) GO<\/code><\/pre>\n<p>\u0412 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0435 \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043d\u043e \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 val=&#8217;n\/a&#8217;, \u0434\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0443 \u043d\u0430\u0441 5 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u041f\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c<\/h2>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u0430\u043a \u0438 \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c, SQL server \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u043c\u043d\u044b\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u043d\u0430. \u041d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0433\u0440\u0443\u0437\u0438\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443:<\/p>\n<pre><code class=\"sql\">create procedure GetVal @val varchar(32) as    select * from Unlucky where val=@val GO<\/code><\/pre>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u043a\u0430 \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440e\u043a\u0440\u0430\u0441\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e SQL server \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430, \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u044f\u0432\u043d\u043e, \u043a\u0430\u043a \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <a href=\"https:\/\/www.sqlshack.com\/sql-server-2016-parameter-sniffing\/\" rel=\"noopener noreferrer nofollow\">parameter sniffing. <\/a><\/p>\n<h2>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043e \u0433\u0440\u0443\u0441\u0442\u043d\u043e\u043c.<\/h2>\n<p>\u041d\u043e parameter sniffing \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u0442\u044c. <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418 \u0432\u043e\u0442 \u0443\u0436\u0435 \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f index seek. \u0410 \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u044b\u0437\u043e\u0432\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0441 n\/a:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u043c \u0432\u0441\u0442\u0430\u043b, \u0442\u043e\u0433\u043e \u0438 \u0442\u0430\u043f\u043a\u0438. \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 SQL server, \u043f\u043e\u0441\u043b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0438\u043b\u0438 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043b\u0430\u043d SQL server \u043c\u043e\u0436\u0435\u0442 &#8216;\u0437\u0430\u0441\u0442\u0440\u044f\u0442\u044c&#8217; \u0432 &#8216;\u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c&#8217; \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0445\u0432\u0430\u0442\u0430\u0442\u044c\u0441\u044f \u0437\u0430 <s>\u043c\u043e\u043b\u043e\u0442\u043e\u043a<\/s> <em>freeproccache<\/em>. \u0422\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>poisoned execution plan<\/em>.<\/p>\n<h2>\u0418 \u043a\u0430\u043a \u0441 \u044d\u0442\u0438\u043c \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f?<\/h2>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0432 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0442\u043a\u0438 \u0434\u043b\u044f \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"sql\">create procedure SmartGetVal @val varchar(32) as    if @val='n\/a'      select * from Unlucky where val='n\/a' -- not @val!!!   else     select * from Unlucky where val=@val GO<\/code><\/pre>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e SQL:<\/p>\n<pre><code class=\"sql\">create procedure DynGetVal @val varchar(32) as    declare @sql varchar(1000)   set @sql='select * from Unlucky where val='''+@val+''''   exec(@sql) GO<\/code><\/pre>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0430\u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c\u044e (SQL injection, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u0442\u0434), \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0434\u043b\u044f OLAP\/Reporting \u0441\u0438\u0441\u0442\u0435\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0443\u0434\u0430 \u0431\u043e\u043b\u0435\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0443\u043a\u0430\u0437\u0430\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u043b\u0438 \u043d\u0435\u0442 \u0432\u0435\u043b\u0438\u043a\u043e. \u0418 \u0443\u0436 \u0442\u043e\u0447\u043d\u043e \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043b\u044e\u0431\u0438\u043c\u043e\u0433\u043e \u043f\u0440\u0438\u0435\u043c\u0430 \u0434\u0435\u0432\u0435\u043b\u043e\u043f\u0435\u0440\u043e\u0432, \u043f\u0440\u043e\u043a\u043b\u0438\u043d\u0430\u0435\u043c\u043e\u0433\u043e \u0432\u0441\u0435\u043c\u0438 DBA:<\/p>\n<pre><code class=\"sql\">where ...   and (@userid IS NULL or userid=@userid)   and (@companyid IS NULL or companyid=@companyid)   and (@deptid IS NULL or deptid=@deptid) <\/code><\/pre>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 query hints <strong>OPTION(RECOMPILE)<\/strong> &#8212; \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u043e\u0439\u0442\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043a\u0432\u0435\u0440\u0435\u0439 \u043d\u043e \u0442\u0440\u0430\u0442\u0438\u0442\u044c 100-500ms \u043d\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442. <\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0445\u0438\u043d\u0442\u044b <strong>OPTION(OPTIMIZE FOR UNKNOWN)<\/strong> \u0438 <strong>OPTION (OPTIMIZE FOR @var=value,&#8230;)<\/strong> <\/p>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043b\u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u044f irregular selectivity<\/h2>\n<p>\u0414\u043b\u044f MS SQL \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u043f\u043e \u0432\u0441\u0435\u043c \u0446\u0435\u043b\u044b\u043c \u0438 \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c (\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u043d\u043d\u044b\u043c) \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442 selectivity report:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0435\u0440\u0432\u044b\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043d\u0435 \u043d\u0443\u0436\u0434\u0430\u044e\u0442\u0441\u044f, \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a: \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0441\u0430\u043c\u043e\u0435 \u0447\u0430\u0441\u0442\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043d\u0435\u0433\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u0435\u0439. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430 &#8212; \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0432 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\u0445. \u0415\u0441\u043b\u0438 \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043b\u0430 \u0431\u043e\u043b\u0435\u0435 30%, \u0442\u043e \u044d\u0442\u043e \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442 \u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443.<\/p>\n<p>\u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0441 \u043c\u0430\u043b\u043e\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043d\u0435 \u0441\u0442\u043e\u0438\u0442.<\/p>\n<p>\u0412\u0430\u0441 \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u0443\u0434\u0438\u0432\u043b\u044f\u0435\u0442, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a HTML \u0442\u0430\u0431\u043b\u0438\u0446\u0430? \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e \u0447\u0430\u0441\u0442\u044c <a href=\"https:\/\/www.actionatdistance.com\/mission\" rel=\"noopener noreferrer nofollow\">\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/a>. \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u0434\u043b\u044f MSSQL \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e.<\/p>\n<details class=\"spoiler\">\n<summary>&#8216;standalone&#8217; \u0441\u043a\u0440\u0438\u043f\u0442 \u0434\u043b\u044f MSSQL, \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0435 \u0438\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"sql\">declare @tab varchar(128) = 'tablename' declare @s varchar(128), @sql varchar(max), @rows bigint select @rows=max(rowcnt) from sysindexes where id=OBJECT_ID(@tab) if @rows=0 set @rows=1 create table #res (s varchar(128), cnt int) create table #tp (s varchar(128), topper int) DECLARE cols CURSOR FOR select name from syscolumns where id=OBJECT_ID(@tab)    and xtype in (48,52,56,127,167,231,239,175,108) and length&lt;=256 OPEN cols; FETCH NEXT FROM cols into @s; WHILE @@FETCH_STATUS = 0 BEGIN   set @sql='insert into #res select '''+@s+''',(select count(distinct ['+@s+']) from ['+@tab+'])'   print @sql   exec (@sql)   set @sql='insert into #tp select '''+@s+''',(select top 1 count(*) from ['+@tab+'] group by ['+@s+'] order by 1 desc)'   print @sql   exec (@sql)   FETCH NEXT FROM cols into @s; END CLOSE cols; DEALLOCATE cols; select #res.s as [Column], cnt as DistinctValues,      @rows\/case when cnt=0 then 1 else cnt end as RowsPerValueAvg,      topper as RecordsInMostFreqVal,      convert(money,topper*100.\/@rows) as PctInTop      from #res   inner join #tp on #tp.s=#res.s   order by 2 desc drop table #res drop table #tp <\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0414\u043b\u044f <a href=\"https:\/\/www.actionatdistance.com\/postgres\" rel=\"noopener noreferrer nofollow\">Postgre<\/a> \u0438 <a href=\"https:\/\/www.actionatdistance.com\/mysql\" rel=\"noopener noreferrer nofollow\">MySQL<\/a> \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u0438 \u0432 \u0441\u0430\u043c\u0438\u0445 <a href=\"https:\/\/www.actionatdistance.com\/modules\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0434\u0443\u043b\u044f\u0445<\/a>, \u0441\u043a\u0430\u0447\u0430\u0439\u0442\u0435 \u0438\u0445 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u0438 \u0438\u0449\u0438\u0442\u0435 \u0444\u0430\u0439\u043b \u0441 \u0438\u043c\u0435\u043d\u0435\u043c *selectivity. , \u0440\u0430\u0432\u043d\u043e \u043a\u0430\u043a \u0438 \u0434\u043b\u044f <a href=\"https:\/\/www.actionatdistance.com\/mssql\" rel=\"noopener noreferrer nofollow\">MSSQL<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/646763\/\"> https:\/\/habr.com\/ru\/post\/646763\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-328318","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328318","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=328318"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/328318\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=328318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=328318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=328318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}