{"id":415474,"date":"2024-06-30T00:23:23","date_gmt":"2024-06-30T00:23:23","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=415474"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=415474","title":{"rendered":"<span>MS SQL 2022 killer feature<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0441\u043e\u0432\u0441\u0435\u043c \u0440\u0430\u043d\u043d\u0435\u043c \u043f\u0440\u0435\u0432\u044c\u044e MS SQL \u0432 \u044f\u043d\u0432\u0430\u0440\u0435 \u043c\u043d\u0435 \u0432\u0435\u0436\u043b\u0438\u0432\u043e \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0438. \u0418 \u0432\u043e\u0442, \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432\u044b\u0448\u0435\u043b \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 evaluation \u0440\u0435\u043b\u0438\u0437! \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a MS SQL \u043e\u0442\u043d\u0435\u0441\u0435\u0442\u0441\u044f \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u043c\u0443 &#8212; values with irregular selectivity. <a href=\"https:\/\/habr.com\/ru\/post\/646763\/\" rel=\"noopener noreferrer nofollow\">\u0423 \u043c\u0435\u043d\u044f \u043f\u0440\u043e \u044d\u0442\u043e \u0434\u0430\u0436\u0435 \u0431\u044b\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044f<\/a>.<\/p>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 MS SQL 2022 <a href=\"https:\/\/info.microsoft.com\/ww-landing-sql-server-2022.html\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/a>. <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c &#171;<em>no such country<\/em>&#171;:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/db0\/1bf\/926\/db01bf9267e3a9f9f25c8a7dca9b0786.png\" width=\"484\" height=\"243\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/db0\/1bf\/926\/db01bf9267e3a9f9f25c8a7dca9b0786.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043c \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0435 (\u043a\u043e\u0434\u0430 +7 \u043d\u0435\u0442, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f), \u0438 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 geoIP, \u0442\u0430\u043a \u0447\u0442\u043e \u043b\u044e\u0431\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0443 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>\u041d\u043e \u044f \u0443\u0432\u0435\u0440\u0435\u043d, \u0432\u044b \u0432\u044b\u043a\u0440\u0443\u0442\u0438\u0442\u0435\u0441\u044c \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0438 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432\u043e\u0436\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435:<\/p>\n<p><strong>Microsoft SQL Server 2022 (CTP2.0) &#8212; 16.0.600.9 (X64)   May 20 2022 13:29:42   Copyright (C) 2022 Microsoft Corporation  Enterprise Evaluation Edition (64-bit) on Windows 10 Enterprise 10.0  (Build 19044: ) (Hypervisor)<\/strong><\/p>\n<p>\u041f\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u0430\u0437\u0443, \u0430 \u0432 \u043d\u0435\u0439 &#8212; \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\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 create procedure GetVal @val varchar(32) as    select * from Unlucky where val=@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=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/145\/dfc\/2c7\/145dfc2c70d226eb1e2cfec7c119c146.png\" width=\"auto\" height=\"auto\" data-src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/145\/dfc\/2c7\/145dfc2c70d226eb1e2cfec7c119c146.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0441\u0442\u0438\u043d\u044b: \u043a\u0430\u043a \u043e\u0442\u043d\u0435\u0441\u0435\u0442\u0441\u044f SQL \u043a \u0442\u0430\u043a\u0438\u043c \u0432\u044b\u0437\u043e\u0432\u0430\u043c:<\/p>\n<pre><code>exec GetVal 'n\/a' exec GetVal '99995val'<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/224\/5b2\/73d\/2245b273d3c901d6fb2ac918f1a1bf5b.png\" width=\"414\" height=\"282\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/224\/5b2\/73d\/2245b273d3c901d6fb2ac918f1a1bf5b.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e! \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043f\u043e\u0434 &#8216;MULTIPLE PLAN&#8217; \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u0430\u0440\u043e\u0439 Management Studio \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b &#8212; \u043e\u043d\u0430 \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442. \u041d\u043e <strong>SET SHOPWPLAN<\/strong> \u0442\u043e\u0436\u0435 \u043d\u0435 \u0441\u043c\u043e\u0433 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e, \u0445\u043e\u0442\u044f \u0442\u0430\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043e\u0442 MS SQL. <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c execution plan, \u043d\u0430\u0434\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <em>actual execution plan after execution<\/em>:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d84\/cd6\/e2d\/d84cd6e2d3f8ecc9519af6eba44bb485.png\" width=\"685\" height=\"348\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d84\/cd6\/e2d\/d84cd6e2d3f8ecc9519af6eba44bb485.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 QueryVariantID. \u0418 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b9d\/151\/897\/b9d151897cd2cccb70c234857a2fbf3b.png\" width=\"807\" height=\"404\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b9d\/151\/897\/b9d151897cd2cccb70c234857a2fbf3b.png\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>\u0422\u0430-\u0434\u0430\u0430\u0430\u043c!<\/strong> \u041d\u0443 \u0447\u0442\u043e \u044f \u043c\u043e\u0433\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u0436\u0435 \u0434\u043e\u043b\u0433\u043e \u044f \u044d\u0442\u043e \u0436\u0434\u0430\u043b! \u042d\u0442\u043e \u043d\u0435 \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u043e\u0432\u044b\u0439 BS \u0438\u043b\u0438 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0444\u0438\u0447\u0438, \u044d\u0442\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0448\u0430\u0433 \u0434\u043b\u044f \u0431\u0430\u0437\u044b, \u043d\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u0448\u0430\u0433 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u0442\u0432\u0430. \u041a\u0442\u043e \u0435\u0449\u0435 \u0442\u0430\u043a\u043e\u0435 \u0443\u043c\u0435\u0435\u0442? \u041d\u0438\u043a\u0442\u043e. <\/p>\n<p>\u0420\u0430\u0434\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u0437\u0430\u043b\u0435\u0437\u0435\u043c \u0432 activity monitor:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1d8\/c48\/bee\/1d8c48bee1c5a41dd7988314734bbbe9.png\" width=\"814\" height=\"143\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1d8\/c48\/bee\/1d8c48bee1c5a41dd7988314734bbbe9.png\"\/><figcaption><\/figcaption><\/figure>\n<p>Execution plan (\u043f\u043e right click) \u0442\u0430\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0439.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 Query Variants \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b (\u043f\u043e\u043a\u0430 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e?) \u043d\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/668878\/\"> https:\/\/habr.com\/ru\/articles\/668878\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0441\u043e\u0432\u0441\u0435\u043c \u0440\u0430\u043d\u043d\u0435\u043c \u043f\u0440\u0435\u0432\u044c\u044e MS SQL \u0432 \u044f\u043d\u0432\u0430\u0440\u0435 \u043c\u043d\u0435 \u0432\u0435\u0436\u043b\u0438\u0432\u043e \u043e\u0442\u043a\u0430\u0437\u0430\u043b\u0438. \u0418 \u0432\u043e\u0442, \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0432\u044b\u0448\u0435\u043b \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 evaluation \u0440\u0435\u043b\u0438\u0437! \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a MS SQL \u043e\u0442\u043d\u0435\u0441\u0435\u0442\u0441\u044f \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u043c\u0443 &#8212; values with irregular selectivity. <a href=\"https:\/\/habr.com\/ru\/post\/646763\/\" rel=\"noopener noreferrer nofollow\">\u0423 \u043c\u0435\u043d\u044f \u043f\u0440\u043e \u044d\u0442\u043e \u0434\u0430\u0436\u0435 \u0431\u044b\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044f<\/a>.<\/p>\n<p>\u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 MS SQL 2022 <a href=\"https:\/\/info.microsoft.com\/ww-landing-sql-server-2022.html\" rel=\"noopener noreferrer nofollow\">\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/a>. <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u043e\u0434\u043e\u043b\u0435\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c &#171;<em>no such country<\/em>&#171;:<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043c \u0435\u0449\u0435 \u0435\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0435 (\u043a\u043e\u0434\u0430 +7 \u043d\u0435\u0442, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f), \u0438 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 geoIP, \u0442\u0430\u043a \u0447\u0442\u043e \u043b\u044e\u0431\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0443 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f.<\/p>\n<p>\u041d\u043e \u044f \u0443\u0432\u0435\u0440\u0435\u043d, \u0432\u044b \u0432\u044b\u043a\u0440\u0443\u0442\u0438\u0442\u0435\u0441\u044c \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0438 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432\u043e\u0436\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435:<\/p>\n<p><strong>Microsoft SQL Server 2022 (CTP2.0) &#8212; 16.0.600.9 (X64)   May 20 2022 13:29:42   Copyright (C) 2022 Microsoft Corporation  Enterprise Evaluation Edition (64-bit) on Windows 10 Enterprise 10.0  (Build 19044: ) (Hypervisor)<\/strong><\/p>\n<p>\u041f\u043e\u0439\u0434\u0435\u043c \u043f\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u0430\u0437\u0443, \u0430 \u0432 \u043d\u0435\u0439 &#8212; \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\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 create procedure GetVal @val varchar(32) as    select * from Unlucky where val=@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=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0441\u0442\u0438\u043d\u044b: \u043a\u0430\u043a \u043e\u0442\u043d\u0435\u0441\u0435\u0442\u0441\u044f SQL \u043a \u0442\u0430\u043a\u0438\u043c \u0432\u044b\u0437\u043e\u0432\u0430\u043c:<\/p>\n<pre><code>exec GetVal 'n\/a' exec GetVal '99995val'<\/code><\/pre>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e! \u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u044f \u043f\u043e\u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043f\u043e\u0434 &#8216;MULTIPLE PLAN&#8217; \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0442\u0430\u0440\u043e\u0439 Management Studio \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b &#8212; \u043e\u043d\u0430 \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442. \u041d\u043e <strong>SET SHOPWPLAN<\/strong> \u0442\u043e\u0436\u0435 \u043d\u0435 \u0441\u043c\u043e\u0433 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e, \u0445\u043e\u0442\u044f \u0442\u0430\u043c \u043e\u0442\u0432\u0435\u0442 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043e\u0442 MS SQL. <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c execution plan, \u043d\u0430\u0434\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <em>actual execution plan after execution<\/em>:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 QueryVariantID. \u0418 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><strong>\u0422\u0430-\u0434\u0430\u0430\u0430\u043c!<\/strong> \u041d\u0443 \u0447\u0442\u043e \u044f \u043c\u043e\u0433\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u0436\u0435 \u0434\u043e\u043b\u0433\u043e \u044f \u044d\u0442\u043e \u0436\u0434\u0430\u043b! \u042d\u0442\u043e \u043d\u0435 \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u043e\u0432\u044b\u0439 BS \u0438\u043b\u0438 \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0444\u0438\u0447\u0438, \u044d\u0442\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0448\u0430\u0433 \u0434\u043b\u044f \u0431\u0430\u0437\u044b, \u043d\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439 \u0448\u0430\u0433 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u0442\u0432\u0430. \u041a\u0442\u043e \u0435\u0449\u0435 \u0442\u0430\u043a\u043e\u0435 \u0443\u043c\u0435\u0435\u0442? \u041d\u0438\u043a\u0442\u043e. <\/p>\n<p>\u0420\u0430\u0434\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0430 \u0437\u0430\u043b\u0435\u0437\u0435\u043c \u0432 activity monitor:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>Execution plan (\u043f\u043e right click) \u0442\u0430\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0439.<\/p>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0441\u0435 Query Variants \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b (\u043f\u043e\u043a\u0430 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e?) \u043d\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0447\u0435\u043d\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/668878\/\"> https:\/\/habr.com\/ru\/articles\/668878\/<\/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-415474","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415474","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=415474"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/415474\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=415474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=415474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=415474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}