{"id":529,"date":"2011-09-10T13:26:00","date_gmt":"2011-09-10T13:26:00","guid":{"rendered":"\/blogs\/bobb\/post\/Full-text-query-plans-and-stats-in-Denali.aspx"},"modified":"2013-01-04T00:01:21","modified_gmt":"2013-01-04T08:01:21","slug":"full-text-query-plans-and-stats-in-denali","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/","title":{"rendered":"Full-text query plans and stats in Denali"},"content":{"rendered":"<p>\nI&#39;ve been looking at full-text query plans in Denali lately, and looking at the SQL&nbsp;query plan for the full-text part, there isn&#39;t much to see (modulo docid lookup or lack of it, see <a href=\"http:\/\/3.209.169.194\/blogs\/bobb\/of-filetables-full-text-and-semantic-search-and-docidmaps\/\">a couple of posts ago<\/a>). Everything seemed to be hidden behind the TableValuedFunction iterator for FulltextMatch function, and although there&#39;s the usual iterator info on this one, there&#39;s nothing about how they do the full-text query. Not even in the parameters passed to the TVF. So what does FulltextMatch do?\n<\/p>\n<p>\nNotice I said &quot;seemed&quot; to be hidden. Just ran across some new extended events for FTS that are quite interesting.These are fulltext_exec_query_stats and fulltext_query_recompile. Note: I don&#39;t find these events pre-Denali.&nbsp;Sounds promising. Started up an Extended Event session with these, set on &quot;Watch Live Data&quot; (did I already say a few times how much I liked the new &quot;extended event trace&quot; GUI?). Along with the action for sql_text.\n<\/p>\n<p>\nFor a full-text query that had a predicate that read like this: &quot;WHERE CONTAINS(file_stream, &#39;NEAR((&quot;data&quot;, &quot;SQL&quot;), 5, FALSE)&#39;);&quot;, fulltext_exec_query_stats retrieved this lovely chunk of XML. Hope it doesn&#39;t get munged in the poster or your reader.\n<\/p>\n<p>\n&lt;Root FragmentSelectionTimestamp=&quot;0x000001ec34&quot; QueryHandle=&quot;1241413008&quot; IsParallel=&quot;false&quot;&gt;<br \/>\n&nbsp;&lt;Scalar Name=&quot;ContainsTableSSERankForNear&quot; InclusiveTime=&quot;0ms&quot; RowCount=&quot;92&quot;&gt;<br \/>\n&nbsp; &lt;AND Name=&quot;AND&quot; InclusiveTime=&quot;0ms&quot; RowCount=&quot;92&quot;&gt;<br \/>\n&nbsp;&nbsp; &lt;Filter Name=&quot;SingleFragmentDocidFilter&quot; InclusiveTime=&quot;0ms&quot; RowCount=&quot;124&quot; FilterTableStrategy=&quot;Scan&quot; SetRangeCalls=&quot;2&quot;&gt;<br \/>\n&nbsp;&nbsp;&nbsp; &lt;Filter Name=&quot;SingleFragmentSeekFilter&quot; InclusiveTime=&quot;0ms&quot; RowCount=&quot;124&quot;&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp; &lt;Fragment Keyword=&quot;SQL&quot; InclusiveTime=&quot;0ms&quot; RowCount=&quot;124&quot;&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;PhysicalRead InclusiveTime=&quot;0ms&quot; RowCount=&quot;19&quot; Scans=&quot;1&quot; LogicalReads=&quot;6&quot; PhysicalReads=&quot;0&quot; ReadAheads=&quot;0&quot; LobLogicalReads=&quot;0&quot; LobPhysicalReads=&quot;0&quot; LobReadAheads=&quot;0&quot; \/&gt; <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Decompression InclusiveTime=&quot;0ms&quot; RowCount=&quot;124&quot; \/&gt; <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/Fragment&gt;<br \/>\n&nbsp;&nbsp;&nbsp; &lt;\/Filter&gt;<br \/>\n&nbsp; &lt;\/Filter&gt;<br \/>\n&nbsp; &lt;Filter Name=&quot;SingleFragmentDocidFilter&quot; InclusiveTime=&quot;0ms&quot; RowCount=&quot;124&quot; FilterTableStrategy=&quot;Scan&quot; SetRangeCalls=&quot;2&quot;&gt;<br \/>\n&nbsp;&nbsp; &lt;Filter Name=&quot;SingleFragmentSeekFilter&quot; InclusiveTime=&quot;0ms&quot; RowCount=&quot;124&quot;&gt;<br \/>\n&nbsp;&nbsp;&nbsp; &lt;Fragment Keyword=&quot;data&quot; InclusiveTime=&quot;0ms&quot; RowCount=&quot;124&quot;&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp; &lt;PhysicalRead InclusiveTime=&quot;0ms&quot; RowCount=&quot;18&quot; Scans=&quot;1&quot; LogicalReads=&quot;6&quot; PhysicalReads=&quot;0&quot; ReadAheads=&quot;0&quot; LobLogicalReads=&quot;0&quot; LobPhysicalReads=&quot;0&quot; LobReadAheads=&quot;0&quot; \/&gt; <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp; &lt;Decompression InclusiveTime=&quot;0ms&quot; RowCount=&quot;124&quot; \/&gt; <br \/>\n&nbsp;&nbsp;&nbsp; &lt;\/Fragment&gt;<br \/>\n&nbsp;&nbsp; &lt;\/Filter&gt;<br \/>\n&nbsp;&nbsp; &lt;\/Filter&gt;<br \/>\n&nbsp; &lt;\/AND&gt;<br \/>\n&nbsp;&lt;\/Scalar&gt;<br \/>\n&lt;\/Root&gt;\n<\/p>\n<p>\nVERY cool. So, although there&#39;s no magic decoder ring for this one (yet, I&#39;m working on it), you can deduce (OK, guess) the following just by reading:<br \/>\n&nbsp;&nbsp; FTS in Denali has the ability to execute this function in Parallel (although I haven&#39;t made it do this yet)<br \/>\n&nbsp;&nbsp; The CONTAINS predicate&nbsp;appears to be&nbsp;implemented using CONTAINSTABLE to begin with. They seem to be using&nbsp;a &quot;rank for NEAR&quot; rather than the CONTAINSTABLE rank.<br \/>\n&nbsp;&nbsp; I think for &quot;SSE&quot; may have something to do with FTS using streaming <a href=\"http:\/\/3.209.169.194\/blogs\/bobb\/of-filetables-full-text-and-semantic-search-and-docidmaps\/\">SIMD Extensions<\/a>.&nbsp;<br \/>\n&nbsp;&nbsp;&nbsp;The FTS portion of the query has its own cache (haven&#39;t hit the full_text_recompile event yet). <br \/>\n&nbsp;&nbsp; Each FTS &quot;Filter iterator&quot; (for lack of a better term) has its own strategy and records its own I\/O info, timing, and row count.<br \/>\n&nbsp;&nbsp; BTW, There are a lot more topmost-level iterators than in this relatively simple query. There&#39;s one (sometimes multiple)&nbsp;for FREETEXT, TOP N, etc.\n<\/p>\n<p>\nNice. If you&#39;re tired of wondering, &quot;what are those FTS predicates and TVFs doing&quot;, check out this mechanism for looking into it.\n<\/p>\n<p>\n@bobbeauch<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#39;ve been looking at full-text query plans in Denali lately, and looking at the SQL&nbsp;query plan for the full-text part, there isn&#39;t much to see (modulo docid lookup or lack of it, see a couple of posts ago). Everything seemed to be hidden behind the TableValuedFunction iterator for FulltextMatch function, and although there&#39;s the usual [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,31],"tags":[],"class_list":["post-529","post","type-post","status-publish","format-standard","hentry","category-full-text-search","category-sql-server-2012"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Full-text query plans and stats in Denali - Bob Beauchemin<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Full-text query plans and stats in Denali - Bob Beauchemin\" \/>\n<meta property=\"og:description\" content=\"I&#039;ve been looking at full-text query plans in Denali lately, and looking at the SQL&nbsp;query plan for the full-text part, there isn&#039;t much to see (modulo docid lookup or lack of it, see a couple of posts ago). Everything seemed to be hidden behind the TableValuedFunction iterator for FulltextMatch function, and although there&#039;s the usual [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/\" \/>\n<meta property=\"og:site_name\" content=\"Bob Beauchemin\" \/>\n<meta property=\"article:published_time\" content=\"2011-09-10T13:26:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-01-04T08:01:21+00:00\" \/>\n<meta name=\"author\" content=\"Bob Beauchemin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Bob Beauchemin\" \/>\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\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/\",\"name\":\"Full-text query plans and stats in Denali - Bob Beauchemin\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\"},\"datePublished\":\"2011-09-10T13:26:00+00:00\",\"dateModified\":\"2013-01-04T08:01:21+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Full-Text Search\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/full-text-search\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Full-text query plans and stats in Denali\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/\",\"name\":\"Bob Beauchemin\",\"description\":\"SQL Server Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e\",\"name\":\"Bob Beauchemin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g\",\"caption\":\"Bob Beauchemin\"},\"sameAs\":[\"http:\/www.sqlskills.com\/blogs\/bobb\/\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Full-text query plans and stats in Denali - Bob Beauchemin","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:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/","og_locale":"en_US","og_type":"article","og_title":"Full-text query plans and stats in Denali - Bob Beauchemin","og_description":"I&#39;ve been looking at full-text query plans in Denali lately, and looking at the SQL&nbsp;query plan for the full-text part, there isn&#39;t much to see (modulo docid lookup or lack of it, see a couple of posts ago). Everything seemed to be hidden behind the TableValuedFunction iterator for FulltextMatch function, and although there&#39;s the usual [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/","og_site_name":"Bob Beauchemin","article_published_time":"2011-09-10T13:26:00+00:00","article_modified_time":"2013-01-04T08:01:21+00:00","author":"Bob Beauchemin","twitter_misc":{"Written by":"Bob Beauchemin","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/","name":"Full-text query plans and stats in Denali - Bob Beauchemin","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website"},"datePublished":"2011-09-10T13:26:00+00:00","dateModified":"2013-01-04T08:01:21+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/full-text-query-plans-and-stats-in-denali\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/"},{"@type":"ListItem","position":2,"name":"Full-Text Search","item":"https:\/\/www.sqlskills.com\/blogs\/bobb\/category\/full-text-search\/"},{"@type":"ListItem","position":3,"name":"Full-text query plans and stats in Denali"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/","name":"Bob Beauchemin","description":"SQL Server Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/bobb\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/62bfa986c5b5d28fcffd8b4fc409c73e","name":"Bob Beauchemin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/bobb\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f80e6cc667410857fa6a21931dc528b8092f4d112bf7a8ff7c267674d44ee37?s=96&d=mm&r=g","caption":"Bob Beauchemin"},"sameAs":["http:\/www.sqlskills.com\/blogs\/bobb\/"],"url":"https:\/\/www.sqlskills.com\/blogs\/bobb\/author\/bobb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/comments?post=529"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/posts\/529\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/media?parent=529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/categories?post=529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/bobb\/wp-json\/wp\/v2\/tags?post=529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}