{"id":490,"date":"2012-06-29T00:37:02","date_gmt":"2012-06-29T00:37:02","guid":{"rendered":"\/blogs\/joe\/post\/MSQL_DQ-and-PREEMPTIVE_COM_QUERYINTERFACEe28093Two-Sides-of-the-Same-Coin.aspx"},"modified":"2013-01-02T20:31:54","modified_gmt":"2013-01-03T04:31:54","slug":"msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/","title":{"rendered":"MSQL_DQ and PREEMPTIVE_COM_QUERYINTERFACE\u2013Two Sides of the Same Coin"},"content":{"rendered":"<p>The MSQL_DQ wait type accumulates while waiting for a distributed query to complete and it is not necessarily indicative of an issue.<\/p>\n<p>If MSQL_DQ is one of your top wait types accumulated on your SQL Server instance, you may also see an associated PREEMPTIVE_COM_QUERYINTERFACE wait type.&#160; And actually, you may see that the accumulated values are identical between these two wait types.&#160; PREEMPTIVE_COM_QUERYINTERFACE basically represents accumulated wait time for linked server queries and remote operations as well.<\/p>\n<p>To illustrate, I\u2019ll execute the following query that captures total wait stats before and after and returns the delta (I could use XEvents to do this too \u2013 but this is an isolated system and I only have one distributed query being executed at a time).&#160; <\/p>\n<p>I\u2019ll execute a distributed query 50 times and we\u2019ll see what accumulates:<\/p>\n<pre class=\"csharpcode\"><span class=\"rem\">-- \u201cBefore\u201d state of waits<\/span>\r\n<span class=\"kwrd\">SELECT<\/span> wait_type, waiting_tasks_count\r\n<span class=\"kwrd\">INTO<\/span> #before_waits\r\n<span class=\"kwrd\">FROM<\/span> sys.dm_os_wait_stats\r\n<span class=\"kwrd\">WHERE<\/span> wait_type <span class=\"kwrd\">IN<\/span> (<span class=\"str\">'PREEMPTIVE_COM_QUERYINTERFACE'<\/span>,\r\n                    <span class=\"str\">'MSQL_DQ'<\/span>);\r\n<span class=\"kwrd\">GO<\/span>\r\n\r\n<span class=\"rem\">-- Distributed query executed 50 times<\/span>\r\n<span class=\"kwrd\">SELECT<\/span> <span class=\"str\">'x'<\/span>\r\n<span class=\"kwrd\">FROM<\/span>    <span class=\"kwrd\">OPENQUERY<\/span> ( [JOSEPHSACK-PC\\AUGUSTUS] ,<span class=\"str\">'SELECT TOP 1 o1.name\r\n                    FROM master.dbo.sysobjects AS o1'<\/span> );\r\n<span class=\"kwrd\">GO<\/span> 50\r\n\r\n\r\n<span class=\"rem\">-- \u201cAfter\u201d state of waits<\/span>\r\n<span class=\"kwrd\">SELECT<\/span> wait_type, waiting_tasks_count\r\n<span class=\"kwrd\">INTO<\/span> #after_waits\r\n<span class=\"kwrd\">FROM<\/span> sys.dm_os_wait_stats\r\n<span class=\"kwrd\">WHERE<\/span> wait_type <span class=\"kwrd\">IN<\/span> (<span class=\"str\">'PREEMPTIVE_COM_QUERYINTERFACE'<\/span>,\r\n                    <span class=\"str\">'MSQL_DQ'<\/span>);\r\n<span class=\"kwrd\">GO<\/span>\r\n\r\n<span class=\"kwrd\">SELECT<\/span>    a.wait_type, \r\n        (a.waiting_tasks_count - b.waiting_tasks_count) <span class=\"kwrd\">AS<\/span> accumulated_waiting_tasks_count\r\n<span class=\"kwrd\">FROM<\/span> #before_waits <span class=\"kwrd\">AS<\/span> b\r\n<span class=\"kwrd\">INNER<\/span> <span class=\"kwrd\">JOIN<\/span> #after_waits <span class=\"kwrd\">AS<\/span> a <span class=\"kwrd\">ON<\/span>\r\n    b.wait_type = a.wait_type;\r\n<span class=\"kwrd\">GO<\/span>\r\n\r\n<span class=\"kwrd\">DROP<\/span> <span class=\"kwrd\">TABLE<\/span> #before_waits;\r\n<span class=\"kwrd\">DROP<\/span> <span class=\"kwrd\">TABLE<\/span> #after_waits<\/pre>\n<style type=\"text\/css\">\n.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<p>This returns the following (after the 50 result sets, of course):<\/p>\n<p><a href=\"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-content\/uploads\/windows-live-writer\/msql_dq-and-preemptive_com_queryinterfac\/5cfc59f7\/image.png\"><img fetchpriority=\"high\" decoding=\"async\" style=\"background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-content\/uploads\/windows-live-writer\/msql_dq-and-preemptive_com_queryinterfac\/37fe997e\/image_thumb.png\" width=\"828\" height=\"73\" \/><\/a><\/p>\n<p>Why care?&#160; <\/p>\n<p>Because if MSQL_DQ is 25% of your accumulated wait time for the SQL Server instance \u2013 and PREEMPTIVE_COM_QUERYINTERFACE is also a matching 25% of your wait time, this doesn\u2019t <em>truly<\/em> represent 50% of your overall wait time.&#160; You may overlook wait types with lower accumulated wait times&#160; &#8211; and in this scenario that may be a mistake.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The MSQL_DQ wait type accumulates while waiting for a distributed query to complete and it is not necessarily indicative of an issue. If MSQL_DQ is one of your top wait types accumulated on your SQL Server instance, you may also see an associated PREEMPTIVE_COM_QUERYINTERFACE wait type.&#160; And actually, you may see that the accumulated values [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"class_list":["post-490","post","type-post","status-publish","format-standard","hentry","category-performance"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.9.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MSQL_DQ and PREEMPTIVE_COM_QUERYINTERFACE\u2013Two Sides of the Same Coin - Joe Sack<\/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\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MSQL_DQ and PREEMPTIVE_COM_QUERYINTERFACE\u2013Two Sides of the Same Coin - Joe Sack\" \/>\n<meta property=\"og:description\" content=\"The MSQL_DQ wait type accumulates while waiting for a distributed query to complete and it is not necessarily indicative of an issue. If MSQL_DQ is one of your top wait types accumulated on your SQL Server instance, you may also see an associated PREEMPTIVE_COM_QUERYINTERFACE wait type.&#160; And actually, you may see that the accumulated values [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/\" \/>\n<meta property=\"og:site_name\" content=\"Joe Sack\" \/>\n<meta property=\"article:published_time\" content=\"2012-06-29T00:37:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-01-03T04:31:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-content\/uploads\/windows-live-writer\/msql_dq-and-preemptive_com_queryinterfac\/37fe997e\/image_thumb.png\" \/>\n<meta name=\"author\" content=\"Joseph Sack\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joseph Sack\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/\",\"name\":\"MSQL_DQ and PREEMPTIVE_COM_QUERYINTERFACE\u2013Two Sides of the Same Coin - Joe Sack\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/#website\"},\"datePublished\":\"2012-06-29T00:37:02+00:00\",\"dateModified\":\"2013-01-03T04:31:54+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/#\/schema\/person\/533eb0113a15fb5a6e8067a49e4ae648\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Performance\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/category\/performance\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MSQL_DQ and PREEMPTIVE_COM_QUERYINTERFACE\u2013Two Sides of the Same Coin\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/\",\"name\":\"Joe Sack\",\"description\":\"SQL Server Performance Tuning, High Availability and Disaster Recovery Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/#\/schema\/person\/533eb0113a15fb5a6e8067a49e4ae648\",\"name\":\"Joseph Sack\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a4b39a7719a6bfff1add3ec00527810734579ee114d6d983e8e68f937b77be96?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a4b39a7719a6bfff1add3ec00527810734579ee114d6d983e8e68f937b77be96?s=96&d=mm&r=g\",\"caption\":\"Joseph Sack\"},\"description\":\"Joe Sack is a Principal Consultant with SQLskills. He has worked as a SQL Server professional since 1997 and has supported and developed for SQL Server environments in financial services, IT consulting, manufacturing, retail and the real estate industry. Prior to joining SQLskills he worked at Microsoft as a Premier Field Engineer supporting very large enterprise customer environments. He was responsible for providing deep SQL Server advisory services, training, troubleshooting and ongoing solutions guidance. His areas of expertise include performance tuning, scalability, T-SQL development and high-availability. In 2006 Joe earned the \u201cMicrosoft Certified Master: SQL Server 2005\u201d certification and in 2008 he earned the \u201cMicrosoft Certified Master: SQL Server 2008\u201d certification. In 2009 he took over responsibility for the entire SQL Server Microsoft Certified Master program and held that post until 2011. He was given the SQL Server MVP award in 2013.\",\"sameAs\":[\"http:\/\/3.209.169.194\/blogs\/joe\",\"https:\/\/twitter.com\/https:\/\/twitter.com\/josephsack\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/joe\/author\/joe\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MSQL_DQ and PREEMPTIVE_COM_QUERYINTERFACE\u2013Two Sides of the Same Coin - Joe Sack","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\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/","og_locale":"en_US","og_type":"article","og_title":"MSQL_DQ and PREEMPTIVE_COM_QUERYINTERFACE\u2013Two Sides of the Same Coin - Joe Sack","og_description":"The MSQL_DQ wait type accumulates while waiting for a distributed query to complete and it is not necessarily indicative of an issue. If MSQL_DQ is one of your top wait types accumulated on your SQL Server instance, you may also see an associated PREEMPTIVE_COM_QUERYINTERFACE wait type.&#160; And actually, you may see that the accumulated values [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/","og_site_name":"Joe Sack","article_published_time":"2012-06-29T00:37:02+00:00","article_modified_time":"2013-01-03T04:31:54+00:00","og_image":[{"url":"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-content\/uploads\/windows-live-writer\/msql_dq-and-preemptive_com_queryinterfac\/37fe997e\/image_thumb.png"}],"author":"Joseph Sack","twitter_misc":{"Written by":"Joseph Sack","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/","url":"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/","name":"MSQL_DQ and PREEMPTIVE_COM_QUERYINTERFACE\u2013Two Sides of the Same Coin - Joe Sack","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/joe\/#website"},"datePublished":"2012-06-29T00:37:02+00:00","dateModified":"2013-01-03T04:31:54+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/joe\/#\/schema\/person\/533eb0113a15fb5a6e8067a49e4ae648"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/joe\/msql_dq-and-preemptive_com_queryinterface-two-sides-of-the-same-coin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/joe\/"},{"@type":"ListItem","position":2,"name":"Performance","item":"https:\/\/www.sqlskills.com\/blogs\/joe\/category\/performance\/"},{"@type":"ListItem","position":3,"name":"MSQL_DQ and PREEMPTIVE_COM_QUERYINTERFACE\u2013Two Sides of the Same Coin"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/joe\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/joe\/","name":"Joe Sack","description":"SQL Server Performance Tuning, High Availability and Disaster Recovery Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/joe\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/joe\/#\/schema\/person\/533eb0113a15fb5a6e8067a49e4ae648","name":"Joseph Sack","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/joe\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a4b39a7719a6bfff1add3ec00527810734579ee114d6d983e8e68f937b77be96?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a4b39a7719a6bfff1add3ec00527810734579ee114d6d983e8e68f937b77be96?s=96&d=mm&r=g","caption":"Joseph Sack"},"description":"Joe Sack is a Principal Consultant with SQLskills. He has worked as a SQL Server professional since 1997 and has supported and developed for SQL Server environments in financial services, IT consulting, manufacturing, retail and the real estate industry. Prior to joining SQLskills he worked at Microsoft as a Premier Field Engineer supporting very large enterprise customer environments. He was responsible for providing deep SQL Server advisory services, training, troubleshooting and ongoing solutions guidance. His areas of expertise include performance tuning, scalability, T-SQL development and high-availability. In 2006 Joe earned the \u201cMicrosoft Certified Master: SQL Server 2005\u201d certification and in 2008 he earned the \u201cMicrosoft Certified Master: SQL Server 2008\u201d certification. In 2009 he took over responsibility for the entire SQL Server Microsoft Certified Master program and held that post until 2011. He was given the SQL Server MVP award in 2013.","sameAs":["http:\/\/3.209.169.194\/blogs\/joe","https:\/\/twitter.com\/https:\/\/twitter.com\/josephsack"],"url":"https:\/\/www.sqlskills.com\/blogs\/joe\/author\/joe\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-json\/wp\/v2\/posts\/490","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-json\/wp\/v2\/comments?post=490"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-json\/wp\/v2\/posts\/490\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-json\/wp\/v2\/media?parent=490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-json\/wp\/v2\/categories?post=490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/joe\/wp-json\/wp\/v2\/tags?post=490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}