{"id":51,"date":"2009-10-13T17:10:01","date_gmt":"2009-10-13T22:10:01","guid":{"rendered":"http:\/\/sqlity.net\/en\/?p=51"},"modified":"2014-11-13T14:05:14","modified_gmt":"2014-11-13T19:05:14","slug":"execution-plan-inaccuracies","status":"publish","type":"post","link":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/","title":{"rendered":"Execution Plan Inaccuracies"},"content":{"rendered":"<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\"><span style=\"color: #000000;\"><span style=\"font-size: 10pt;\">Execution plans are a great tool when you are trying to performance tune your SQL code. They contain a lot of information about how SQL Server will achieve what we have asked it to do. You can see which way tables are accessed, how many rows are read, where data is sorted and so on. But you have to be careful when using them. You probably already know, that there are two types of Execution Plans. The Estimated Execution Plan you can get, without actually executing the query. This is an estimate of how SQL Server thinks it will execute the query and it is based manly on statistics of tables and indexes. The Actual Execution Plan on the other hand, SQL Server produces while actually executing the query. It contains information about ho much data was actually read and moved around.<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\"><span style=\"color: #000000;\"><span style=\"font-size: 10pt;\">That the Estimated Execution Plan can be inaccurate is not a surprise, because it is an estimate. But even the Actual Execution Plan can contain vastly inaccurate data.<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\"><span style=\"color: #000000;\"><span style=\"font-size: 10pt;\">Lets look at an example. First we create a table with the columns id, val1 and val2 and fill it with testing data:<\/span><\/span><\/p>\n<table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<colgroup>\n<col width=\"256*\" \/><\/colgroup>\n<tbody>\n<tr>\n<td bgcolor=\"#e6e6e6\" width=\"100%\">\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">CREATE<\/span> <span style=\"color: #0000ff;\">TABLE<\/span> <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">TstData<\/span><span style=\"color: #808080;\">(<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #000000;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">id <span style=\"color: #0000ff;\">INT<\/span> <span style=\"color: #0000ff;\">IDENTITY<\/span><span style=\"color: #808080;\">(<\/span>1<span style=\"color: #808080;\">,<\/span>1<span style=\"color: #808080;\">)<\/span> <span style=\"color: #0000ff;\">PRIMARY<\/span> <span style=\"color: #0000ff;\">KEY<\/span> <span style=\"color: #0000ff;\">NONCLUSTERED<\/span><span style=\"color: #808080;\">,<\/span><\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #000000;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">val1 <span style=\"color: #0000ff;\">INT<\/span> <span style=\"color: #808080;\">NOT<\/span> <span style=\"color: #808080;\">NULL,<\/span><\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #000000;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">val2 <span style=\"color: #0000ff;\">VARCHAR<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #ff00ff;\">MAX<\/span><span style=\"color: #808080;\">)<\/span><\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #808080;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">);<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">INSERT<\/span> <span style=\"color: #0000ff;\">INTO<\/span> <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">TstData<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #000000;\">val1<\/span><span style=\"color: #808080;\">,<\/span><span style=\"color: #000000;\">val2<\/span><span style=\"color: #808080;\">)<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">SELECT<\/span> <span style=\"color: #000000;\">A<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #0000ff;\">no<\/span><span style=\"color: #808080;\">,<\/span><span style=\"color: #ff00ff;\">REPLICATE<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #0000ff;\">CHAR<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #000000;\">65<\/span><span style=\"color: #808080;\">+(<\/span><span style=\"color: #000000;\">B<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #0000ff;\">no<\/span> <span style=\"color: #808080;\">%<\/span> <span style=\"color: #000000;\">26<\/span><span style=\"color: #808080;\">)),<\/span><span style=\"color: #000000;\">A<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #0000ff;\">no<\/span><span style=\"color: #808080;\">)<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">FROM<\/span> <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">f_num<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #000000;\">10<\/span><span style=\"color: #808080;\">)<\/span> <span style=\"color: #0000ff;\">AS<\/span> <span style=\"color: #000000;\">A<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #808080;\">CROSS<\/span> <span style=\"color: #808080;\">JOIN<\/span> <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">f_num<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #000000;\">50<\/span><span style=\"color: #808080;\">)<\/span> <span style=\"color: #0000ff;\">AS<\/span> <span style=\"color: #000000;\">B<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">GO<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">CREATE<\/span> <span style=\"color: #0000ff;\">CLUSTERED<\/span> <span style=\"color: #0000ff;\">INDEX<\/span> <span style=\"color: #000000;\">TstData_CI<\/span> <span style=\"color: #0000ff;\">ON<\/span> <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">TstData<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #000000;\">val1<\/span><span style=\"color: #808080;\">);<\/span><\/span><\/span><\/p>\n<p lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">GO<\/span><\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\"><span style=\"color: #000000;\"><span style=\"font-size: 10pt;\">Then we create a view that concatenates the val2 columns together in id order, grouped by val1.<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\"><span style=\"color: #000000;\"><span style=\"font-size: 10pt;\">So if the data in dbo.TstData looked like this:<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/images.sqlity.net\/ExecutionPlan1_html_6909c154.gif\" alt=\"\" name=\"Object1\" width=\"124\" height=\"108\" border=\"0\" \/><\/p>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\"><span style=\"color: #000000;\"><span style=\"font-size: 10pt;\">the view would return this:<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/images.sqlity.net\/ExecutionPlan1_html_2e9904ce.gif\" alt=\"\" name=\"Object2\" width=\"115\" height=\"65\" border=\"0\" \/><\/p>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\"><span style=\"color: #000000;\"><span style=\"font-size: 10pt;\">This is the code for this first view:<\/span><\/span><\/p>\n<table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<colgroup>\n<col width=\"256*\" \/><\/colgroup>\n<tbody>\n<tr>\n<td bgcolor=\"#e6e6e6\" width=\"100%\">\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">CREATE VIEW <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">TstVw1<\/span><\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">AS<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">SELECT<\/span> <span style=\"color: #0000ff;\">DISTINCT<\/span> <span style=\"color: #000000;\">A<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">val1<\/span><span style=\"color: #808080;\">,<\/span><span style=\"color: #000000;\">C<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">Cnct<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">FROM<\/span> <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">TstData<\/span> <span style=\"color: #0000ff;\">AS<\/span> <span style=\"color: #000000;\">A<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #808080;\">CROSS<\/span> <span style=\"color: #808080;\">APPLY(<\/span><span style=\"color: #0000ff;\">SELECT<\/span> <span style=\"color: #808080;\">(<\/span><span style=\"color: #0000ff;\">SELECT<\/span> <span style=\"color: #000000;\">B<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">val2 [text language=\"()\"][\/text]<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">FROM<\/span> <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">TstData<\/span> <span style=\"color: #0000ff;\">AS<\/span> <span style=\"color: #000000;\">B<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">WHERE<\/span> <span style=\"color: #000000;\">B<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">val1<\/span> <span style=\"color: #808080;\">=<\/span> <span style=\"color: #000000;\">A<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">val1<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">ORDER<\/span> <span style=\"color: #0000ff;\">BY<\/span> <span style=\"color: #000000;\">B<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">id<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">FOR<\/span> <span style=\"color: #0000ff;\">XML<\/span> <span style=\"color: #0000ff;\">PATH<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #ff0000;\">''<\/span><span style=\"color: #808080;\">)<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #808080;\">)<\/span> <span style=\"color: #0000ff;\">AS<\/span> <span style=\"color: #000000;\">Cnct<\/span><\/span><\/span><\/p>\n<p lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #808080;\">)<\/span> <span style=\"color: #0000ff;\">AS<\/span> <span style=\"color: #000000;\">C<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\"><span style=\"color: #000000;\"><span style=\"font-size: 10pt;\">It is using SQL Servers XML capabilities to do the concatenation.<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\"><span style=\"color: #000000;\"><span style=\"font-size: 10pt;\">Next we create a second view that does exactly the same thing, but instead of XML it is using a SQL function that cursors through all rows of the table to get there:<\/span><\/span><\/p>\n<table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<colgroup>\n<col width=\"256*\" \/><\/colgroup>\n<tbody>\n<tr>\n<td bgcolor=\"#e6e6e6\" width=\"100%\">\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">CREATE<\/span> <span style=\"color: #0000ff;\">FUNCTION<\/span> <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">TstDataConcat<\/span><span style=\"color: #808080;\">(<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #000000;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">@GrpVal <span style=\"color: #0000ff;\">INT<\/span><\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #808080;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">)<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">RETURNS<\/span> <span style=\"color: #0000ff;\">VARCHAR<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #ff00ff;\">MAX<\/span><span style=\"color: #808080;\">)<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">AS<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">BEGIN<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">DECLARE<\/span> <span style=\"color: #000000;\">@Cnct<\/span> <span style=\"color: #0000ff;\">VARCHAR<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #ff00ff;\">MAX<\/span><span style=\"color: #808080;\">);<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">DECLARE<\/span> <span style=\"color: #000000;\">@Val1<\/span> <span style=\"color: #0000ff;\">INT<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">DECLARE<\/span> <span style=\"color: #000000;\">@Val2<\/span> <span style=\"color: #0000ff;\">VARCHAR<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #ff00ff;\">MAX<\/span><span style=\"color: #808080;\">);<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">SET<\/span> <span style=\"color: #000000;\">@Cnct<\/span> <span style=\"color: #808080;\">=<\/span> <span style=\"color: #ff0000;\">''<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">DECLARE<\/span> <span style=\"color: #000000;\">cur<\/span> <span style=\"color: #0000ff;\">CURSOR<\/span> <span style=\"color: #0000ff;\">LOCAL<\/span> <span style=\"color: #0000ff;\">FAST_FORWARD<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">FOR<\/span> <span style=\"color: #0000ff;\">SELECT<\/span> <span style=\"color: #000000;\">val1<\/span><span style=\"color: #808080;\">,<\/span><span style=\"color: #000000;\">val2<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">FROM<\/span> <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">TstData<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">ORDER<\/span> <span style=\"color: #0000ff;\">BY<\/span> <span style=\"color: #000000;\">id<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">OPEN<\/span> <span style=\"color: #000000;\">cur<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">FETCH<\/span> <span style=\"color: #0000ff;\">NEXT<\/span> <span style=\"color: #0000ff;\">FROM<\/span> <span style=\"color: #000000;\">cur<\/span> <span style=\"color: #0000ff;\">INTO<\/span> <span style=\"color: #000000;\">@Val1<\/span><span style=\"color: #808080;\">,<\/span> <span style=\"color: #000000;\">@Val2<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">WHILE<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #ff00ff;\">@@FETCH_STATUS<\/span> <span style=\"color: #808080;\">=<\/span> <span style=\"color: #000000;\">0<\/span><span style=\"color: #808080;\">)<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">BEGIN<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">IF<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #000000;\">@Val1<\/span> <span style=\"color: #808080;\">=<\/span> <span style=\"color: #000000;\">@GrpVal<\/span><span style=\"color: #808080;\">)<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">BEGIN<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">SET<\/span> <span style=\"color: #000000;\">@Cnct<\/span> <span style=\"color: #808080;\">+=<\/span> <span style=\"color: #000000;\">@Val2<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">END<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">FETCH<\/span> <span style=\"color: #0000ff;\">NEXT<\/span> <span style=\"color: #0000ff;\">FROM<\/span> <span style=\"color: #000000;\">cur<\/span> <span style=\"color: #0000ff;\">INTO<\/span> <span style=\"color: #000000;\">@Val1<\/span><span style=\"color: #808080;\">,<\/span> <span style=\"color: #000000;\">@Val2<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">END<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">CLOSE<\/span> <span style=\"color: #000000;\">cur<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">DEALLOCATE<\/span> <span style=\"color: #000000;\">cur<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">RETURN<\/span> <span style=\"color: #000000;\">@Cnct<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">END<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">GO<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">CREATE<\/span> <span style=\"color: #0000ff;\">VIEW<\/span> <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">TstVw2<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">AS<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">SELECT<\/span> <span style=\"color: #000000;\">val1<\/span><span style=\"color: #808080;\">,<\/span><span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">TstDataConcat<\/span><span style=\"color: #808080;\">(<\/span><span style=\"color: #000000;\">val1<\/span><span style=\"color: #808080;\">)<\/span> <span style=\"color: #0000ff;\">AS<\/span> <span style=\"color: #000000;\">Cnct<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">FROM<\/span> <span style=\"color: #000000;\">dbo<\/span><span style=\"color: #808080;\">.<\/span><span style=\"color: #000000;\">TstData<\/span><\/span><\/span><\/p>\n<p lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\">GROUP<\/span> <span style=\"color: #0000ff;\">BY<\/span> <span style=\"color: #000000;\">val1<\/span><span style=\"color: #808080;\">;<\/span><\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\"><span style=\"color: #000000;\"><span style=\"font-size: 10pt;\">The function this view is using is intentionally not well optimized.<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\"><span style=\"font-size: 10pt;\"><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span lang=\"en-US\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">When we compare the performance of a<\/span><\/span><\/span><\/span><\/span> <span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">SELECT<\/span><\/span><\/span><span style=\"color: #808080;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">*<\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">INTO<\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">#tst1<\/span><\/span><\/span> <span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">FROM<\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">dbo<\/span><\/span><\/span><span style=\"color: #808080;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">.<\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">TstVw1<\/span><\/span><\/span><span style=\"color: #808080;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">;<\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span lang=\"en-US\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">with it's counterpart using<\/span><\/span><\/span><\/span><\/span> <span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">dbo<\/span><\/span><\/span><\/span><\/span><\/span><span style=\"color: #808080;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">.<\/span><\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">TstVw2<\/span><\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span lang=\"en-US\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">, by looking at the actual execution plan we find a clear indication, that the XML version is a lot more complicated:<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\"><span style=\"color: #000000;\"><img decoding=\"async\" src=\"http:\/\/images.sqlity.net\/ExecutionPlan1_html_42274550.png\" alt=\"\" name=\"graphics1\" border=\"2\" \/><br \/>\n<\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-size: 10pt;\">SQL Server is telling us that the cost of the XML version is 0.640 or 94% of the batch. The cursor version is declared to cost a mere 0.042 or 6% of the batch. Below is an exerpt from the XML execution plan, containing some additional information about this.<\/span><\/p>\n<table width=\"95%\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n<colgroup>\n<col width=\"256*\" \/><\/colgroup>\n<tbody>\n<tr>\n<td width=\"100%\">\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">&lt;<\/span><\/span><\/span><\/span><\/span><span style=\"color: #a31515;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">StmtSimple<\/span><\/span><\/span><\/span><\/span><span style=\"color: #ff0000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">StatementEstRows<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">=<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">107.495<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #ff0000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">StatementOptmLevel<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">=<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">FULL<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #ff0000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">StatementOptmEarlyAbortReason<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">=<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">GoodEnoughPlanFound<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #ff0000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><strong>StatementSubTreeCost<\/strong><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><strong>=<\/strong><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><strong>\"<\/strong><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><strong>0.640166<\/strong><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><strong>\"<\/strong><\/span><\/span><\/span><\/span><span style=\"color: #ff0000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">StatementText<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">=<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">SELECT * INTO #tst1 FROM dbo.TstVw1;<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #ff0000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">StatementType<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">=<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">SELECT INTO<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">&gt;<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">&lt;<span style=\"color: #a31515;\">QueryPlan<\/span> <span style=\"color: #ff0000;\">DegreeOfParallelism<\/span>=<span style=\"color: #000000;\">\"<\/span>0<span style=\"color: #000000;\">\"<\/span> <span style=\"color: #ff0000;\">MemoryGrant<\/span>=<span style=\"color: #000000;\">\"<\/span>6656<span style=\"color: #000000;\">\"<\/span> <span style=\"color: #ff0000;\">CachedPlanSize<\/span>=<span style=\"color: #000000;\">\"<\/span>48<span style=\"color: #000000;\">\"<\/span> <span style=\"color: #ff0000;\">CompileTime<\/span>=<span style=\"color: #000000;\">\"<\/span>6<span style=\"color: #000000;\">\"<\/span> <span style=\"color: #ff0000;\">CompileCPU<\/span>=<span style=\"color: #000000;\">\"<\/span>5<span style=\"color: #000000;\">\"<\/span> <span style=\"color: #ff0000;\">CompileMemory<\/span>=<span style=\"color: #000000;\">\"<\/span>224<span style=\"color: #000000;\">\"<\/span>&gt;<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\" lang=\"zxx\"><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">&lt;<span style=\"color: #a31515;\">StmtSimple<\/span> <span style=\"color: #ff0000;\">StatementEstRows<\/span>=<span style=\"color: #000000;\">\"<\/span>10<span style=\"color: #000000;\">\"<\/span> <span style=\"color: #ff0000;\">StatementOptmLevel<\/span>=<span style=\"color: #000000;\">\"<\/span>FULL<span style=\"color: #000000;\">\"<\/span> <span style=\"color: #ff0000;\">StatementOptmEarlyAbortReason<\/span>=<span style=\"color: #000000;\">\"<\/span>GoodEnoughPlanFound<span style=\"color: #000000;\">\"<\/span> <span style=\"color: #ff0000;\"><strong>StatementSubTreeCost<\/strong><\/span><strong>=<\/strong><span style=\"color: #000000;\"><strong>\"<\/strong><\/span><strong>0.0420384<\/strong><span style=\"color: #000000;\"><strong>\"<\/strong><\/span> <span style=\"color: #ff0000;\">StatementText<\/span>=<span style=\"color: #000000;\">\"<\/span>SELECT * INTO #tst2 FROM dbo.TstVw2;<span style=\"color: #000000;\">\"<\/span> <span style=\"color: #ff0000;\">StatementType<\/span>=<span style=\"color: #000000;\">\"<\/span>SELECT INTO<span style=\"color: #000000;\">\"<\/span>&gt;<\/span><\/span><\/span><\/p>\n<p lang=\"zxx\"><span style=\"font-size: 8pt;\"><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">&lt;<\/span><\/span><\/span><\/span><\/span><span style=\"color: #a31515;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">QueryPlan<\/span><\/span><\/span><\/span><\/span><span style=\"color: #ff0000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">DegreeOfParallelism<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">=<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">0<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #ff0000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">CachedPlanSize<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">=<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">40<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #ff0000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">CompileTime<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">=<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">11<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #ff0000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">CompileCPU<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">=<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">8<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #ff0000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">CompileMemory<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">=<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">112<\/span><\/span><\/span><\/span><\/span><span style=\"color: #000000;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">\"<\/span><\/span><\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"text-decoration: none;\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-style: normal;\"><span style=\"font-weight: normal;\">&gt;<\/span><\/span><\/span><\/span><\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-size: 10pt;\">So according to the actual execution plan the cursor version is over 15 times faster than the XML version.<\/span><\/p>\n<p style=\"margin-bottom: 0in;\"><span style=\"font-size: 10pt;\"><span lang=\"zxx\">Now, we all know that this result is very unlikely, and when we look at the output of the comparison with<\/span> <span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">STATISTICS<\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">TIME<\/span><\/span><\/span><span style=\"color: #0000ff;\"><span style=\"font-family: Courier New, monospace;\"><span lang=\"zxx\">ON<\/span><\/span><\/span><span lang=\"zxx\">, we get these a lot more realistic results:<\/span><\/span><\/p>\n<table width=\"95%\" border=\"1\" cellspacing=\"0\" cellpadding=\"5\">\n<colgroup>\n<col width=\"256*\" \/><\/colgroup>\n<tbody>\n<tr>\n<td width=\"100%\">\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">starting tst1 (CROSS APPLY)<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">DBCC execution completed. If DBCC printed error messages, contact your system administrator.<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">DBCC execution completed. If DBCC printed error messages, contact your system administrator.<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">(10 row(s) affected)<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">(1 row(s) affected)<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">SQL Server Execution Times:<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">CPU time = 47 ms, elapsed time = 51 ms.<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">starting tst2 (FUNCTION)<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">DBCC execution completed. If DBCC printed error messages, contact your system administrator.<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">DBCC execution completed. If DBCC printed error messages, contact your system administrator.<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">(10 row(s) affected)<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">(1 row(s) affected)<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">SQL Server Execution Times:<\/span><\/span><\/p>\n<p lang=\"zxx\"><span style=\"font-family: Courier New, monospace;\"><span style=\"font-size: 8pt;\">CPU time = 2797 ms, elapsed time = 3067 ms.<\/span><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"margin-bottom: 0in; font-style: normal; font-weight: normal; text-decoration: none;\" lang=\"zxx\"><span style=\"color: #000000;\"><span style=\"font-family: Times New Roman, serif;\"><span style=\"font-size: 10pt;\">That is 47ms for the XML version compared to almost 3 seconds for the cursor. That means, eventhough the Execution Plan said the XML solution would be 15 times slower that the function, it ended up being close to 60 times faster.<\/span><\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\" lang=\"zxx\"><span style=\"font-family: Times New Roman, serif;\"><span style=\"font-size: 10pt;\">So, while Execution Plans are an invaluable tool for performance monitoring and tuning, you always have to be careful about the values it returns. The counts and the operators shown in the Actual Execution Plan are reliable, but the time comparisons can not always be relied on.<\/span><\/span><\/p>\n<p style=\"margin-bottom: 0in;\"><span style=\"font-size: 10pt;\"><span lang=\"zxx\">If you want to try this for your self, you can download the <a href=\"http:\/\/downloads.sqlity.net\/ExecutionPlan1.sql.txt\">full source here<\/a>.<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Execution plans are a great tool when you are trying to performance tune your SQL code. They contain a lot of information about how SQL Server will achieve what we have asked it to do. You can see which way <a href=\"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/\">[more&#8230;]<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[5],"tags":[],"class_list":["post-51","post","type-post","status-publish","format-standard","hentry","category-general"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Execution Plan Inaccuracies<\/title>\n<meta name=\"description\" content=\"Execution Plans are a great performance tuning tool, however they can contain vastly inaccurate values so be certain to doublecheck\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Execution Plan Inaccuracies\" \/>\n<meta property=\"og:description\" content=\"Execution Plans are a great performance tuning tool, however they can contain vastly inaccurate values so be certain to doublecheck\" \/>\n<meta property=\"og:url\" content=\"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/\" \/>\n<meta property=\"og:site_name\" content=\"sqlity.net\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/sqlity.net\" \/>\n<meta property=\"article:published_time\" content=\"2009-10-13T22:10:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-11-13T19:05:14+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/images.sqlity.net\/ExecutionPlan1_html_6909c154.gif\" \/>\n<meta name=\"author\" content=\"Sebastian Meine\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@sqlity\" \/>\n<meta name=\"twitter:site\" content=\"@sqlity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sebastian Meine\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/\"},\"author\":{\"name\":\"Sebastian Meine\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"headline\":\"Execution Plan Inaccuracies\",\"datePublished\":\"2009-10-13T22:10:01+00:00\",\"dateModified\":\"2014-11-13T19:05:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/\"},\"wordCount\":869,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/images.sqlity.net\\\/ExecutionPlan1_html_6909c154.gif\",\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/\",\"name\":\"Execution Plan Inaccuracies\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/images.sqlity.net\\\/ExecutionPlan1_html_6909c154.gif\",\"datePublished\":\"2009-10-13T22:10:01+00:00\",\"dateModified\":\"2014-11-13T19:05:14+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\"},\"description\":\"Execution Plans are a great performance tuning tool, however they can contain vastly inaccurate values so be certain to doublecheck\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/#primaryimage\",\"url\":\"http:\\\/\\\/images.sqlity.net\\\/ExecutionPlan1_html_6909c154.gif\",\"contentUrl\":\"http:\\\/\\\/images.sqlity.net\\\/ExecutionPlan1_html_6909c154.gif\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/51\\\/execution-plan-inaccuracies\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Execution Plan Inaccuracies\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/sqlity.net\\\/en\\\/\",\"name\":\"sqlity.net\",\"description\":\"Quality for SQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/sqlity.net\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/sqlity.net\\\/en\\\/#\\\/schema\\\/person\\\/bcffd8c572bc2f1bd10fdba80135e53c\",\"name\":\"Sebastian Meine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g\",\"caption\":\"Sebastian Meine\"},\"sameAs\":[\"http:\\\/\\\/sqlity.net\",\"https:\\\/\\\/x.com\\\/sqlity\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Execution Plan Inaccuracies","description":"Execution Plans are a great performance tuning tool, however they can contain vastly inaccurate values so be certain to doublecheck","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/","og_locale":"en_US","og_type":"article","og_title":"Execution Plan Inaccuracies","og_description":"Execution Plans are a great performance tuning tool, however they can contain vastly inaccurate values so be certain to doublecheck","og_url":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/","og_site_name":"sqlity.net","article_publisher":"https:\/\/www.facebook.com\/sqlity.net","article_published_time":"2009-10-13T22:10:01+00:00","article_modified_time":"2014-11-13T19:05:14+00:00","og_image":[{"url":"http:\/\/images.sqlity.net\/ExecutionPlan1_html_6909c154.gif","type":"","width":"","height":""}],"author":"Sebastian Meine","twitter_card":"summary_large_image","twitter_creator":"@sqlity","twitter_site":"@sqlity","twitter_misc":{"Written by":"Sebastian Meine","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/#article","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/"},"author":{"name":"Sebastian Meine","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"headline":"Execution Plan Inaccuracies","datePublished":"2009-10-13T22:10:01+00:00","dateModified":"2014-11-13T19:05:14+00:00","mainEntityOfPage":{"@id":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/"},"wordCount":869,"commentCount":0,"image":{"@id":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/#primaryimage"},"thumbnailUrl":"http:\/\/images.sqlity.net\/ExecutionPlan1_html_6909c154.gif","articleSection":["General"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/","url":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/","name":"Execution Plan Inaccuracies","isPartOf":{"@id":"https:\/\/sqlity.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/#primaryimage"},"image":{"@id":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/#primaryimage"},"thumbnailUrl":"http:\/\/images.sqlity.net\/ExecutionPlan1_html_6909c154.gif","datePublished":"2009-10-13T22:10:01+00:00","dateModified":"2014-11-13T19:05:14+00:00","author":{"@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c"},"description":"Execution Plans are a great performance tuning tool, however they can contain vastly inaccurate values so be certain to doublecheck","breadcrumb":{"@id":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/#primaryimage","url":"http:\/\/images.sqlity.net\/ExecutionPlan1_html_6909c154.gif","contentUrl":"http:\/\/images.sqlity.net\/ExecutionPlan1_html_6909c154.gif"},{"@type":"BreadcrumbList","@id":"https:\/\/sqlity.net\/en\/51\/execution-plan-inaccuracies\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/sqlity.net\/en\/"},{"@type":"ListItem","position":2,"name":"Execution Plan Inaccuracies"}]},{"@type":"WebSite","@id":"https:\/\/sqlity.net\/en\/#website","url":"https:\/\/sqlity.net\/en\/","name":"sqlity.net","description":"Quality for SQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/sqlity.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/sqlity.net\/en\/#\/schema\/person\/bcffd8c572bc2f1bd10fdba80135e53c","name":"Sebastian Meine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4ab0a6d02dd494849a584a2c3c8bc3bdcef1d0aa5f87e98bf905dbdb9ad2ce3a?s=96&d=mm&r=g","caption":"Sebastian Meine"},"sameAs":["http:\/\/sqlity.net","https:\/\/x.com\/sqlity"]}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2wXuw-P","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/comments?post=51"}],"version-history":[{"count":0,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/posts\/51\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/media?parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/categories?post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlity.net\/en\/wp-json\/wp\/v2\/tags?post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}