{"id":69256,"date":"2021-08-16T04:10:03","date_gmt":"2021-08-16T08:10:03","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/sql-server-hints-38\/"},"modified":"2021-08-16T04:10:03","modified_gmt":"2021-08-16T08:10:03","slug":"sql-server-hints-38","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=69256","title":{"rendered":"SQL Server Hints #38"},"content":{"rendered":"<p style='padding-left:5px'>\n<pre style='padding-left:5px'>\nSQL Server Hints\n----------------\nWhat are hints?\n\nSimply to influence query execution plans to retrieve data \nfaster.\n\nsyscacheobjects\n----------------\nSQL server after compiling a query creates the execution \nplan and keeps it on syscacheobjects object.\nYou can query the object to see the existing query plans as \nfollows:\n\nselect * from sys.syscacheobjects\nwhere cacheobjtype='compiled plan'\n\n\nHints\n-----\n\nWhen you specify hints in your queries the query execution \nplans are biased toward your hints rather than using default\n strategies.\n\nTypes of Hints\n--------------\nJoin Hints: Affects the joins [join types]\nQuery Hints: Affects overall execution plan\nTable: Affects to table access \n\n\nJoin Hints\n----------\nLoops: Uses nesting for join. Each row of the inner table is\n checked for condition satisfaction with the corresponding \nouter row.\nHash: One table is treated as a hash table and the other is \nscanned one row at a time and the hash function is used to \nfind equalities\n\nMerge: Each table is sorted first. Then they are compared \nrow by row [corresponding]\n\nRemote: In this case, at least one table is remote. The join\n is done at the right table side.\n\n\nExample:\n\nselect *\n-----\n----\n---\noption (merge join)\n\n\nor\n\nselect * \nfrom x\ninner merge join y on...\n\n\nQuery Hints:\n------------\nSpecified at the end of the query with keyword 'Option'\n\n\nselect * from x\n------------\n------------\noption (recompile, fast 80)\nHash Group or Order groups:  Aggregations (group by, compute, distinct) are done by hashing or ordering\nConcat Union, Hash Union, Merge Union: All unions will be done with the specified union type\nLoop Join, Hash Join, Merge Join: Joins will be done with the specified join types\nFAST number_rows:\nForce Order:\nMaxDop:\nOptimize For:\nRecompile:\nKeep Plan:\nExpand Views:\n\n\n\nTable Hints:\n------------\nAffects how the table will be locked or which index will be \nused for the query.\nNoEXPAND\nINDEX\nfastfirstrow\nnowait\nrowlockpaglock\ntablock\nnolock\nholdlock\nignore_triggers\n\n\nPlan Guides\n-----------\nSometimes queries are originated from a third part application and you have no control to change the query.\nYou can use plan guides to influence such queries. For example: Using plan guides you can specify the nature of the\n select, update, insert queries.\nYou can use built in stored procedures to create or drop \nplan guides.\n\nsp_create_plan_guide\nsp_control_plan_guide\n<\/pre>\n<\/p>\n<p>From: http:\/\/sitestree.com\/?p=4800<br \/> Categories:38<br \/>Tags:<br \/> Post Data:2007-12-13 01:33:56<\/p>\n<pre><code>    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\"&gt;https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    (Big Data, Cloud, Security, Machine Learning): Courses: &lt;a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"&gt; http:\/\/Training.SitesTree.com&lt;\/a&gt; \n    In Bengali: &lt;a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\"&gt;http:\/\/Bangla.SaLearningSchool.com&lt;\/a&gt;\n    &lt;a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\"&gt;http:\/\/SitesTree.com&lt;\/a&gt;\n    8112223 Canada Inc.\/JustEtc: &lt;a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\"&gt;http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) &lt;\/a&gt;\n    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com'&gt; https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    Medium: &lt;a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"&gt; https:\/\/medium.com\/@SayedAhmedCanada &lt;\/a&gt;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>SQL Server Hints &#8212;&#8212;&#8212;&#8212;&#8212;- What are hints? Simply to influence query execution plans to retrieve data faster. syscacheobjects &#8212;&#8212;&#8212;&#8212;&#8212;- SQL server after compiling a query creates the execution plan and keeps it on syscacheobjects object. You can query the object to see the existing query plans as follows: select * from sys.syscacheobjects where cacheobjtype=&#8217;compiled plan&#8217; &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=69256\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-69256","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":23196,"url":"http:\/\/bangla.sitestree.com\/?p=23196","url_meta":{"origin":69256,"position":0},"title":"How to optimize query response time? #Root #By Sayed Ahmed","author":"Author-Check- Article-or-Video","date":"March 26, 2021","format":false,"excerpt":"Check that only the required columns are selected [in select statements] Check that the right types of joins are used Check that if re-ordering the joins will help or not Check the indexes of the tables [is indexing done on the right columns] Check that in joins you used the\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":69270,"url":"http:\/\/bangla.sitestree.com\/?p=69270","url_meta":{"origin":69256,"position":1},"title":"How to optimize query response time? #38","author":"Author-Check- Article-or-Video","date":"August 16, 2021","format":false,"excerpt":"Check that only the required columns are selected [in select statements] Check that the right types of joins are used Check that if re-ordering the joins will help or not Check the indexes of the tables [is indexing done on the right columns] Check that in joins you used the\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":69272,"url":"http:\/\/bangla.sitestree.com\/?p=69272","url_meta":{"origin":69256,"position":2},"title":"SQL Server Short-notes at JustEtc #38","author":"Author-Check- Article-or-Video","date":"August 16, 2021","format":false,"excerpt":"Query Optimization How to optimize query response time? SQL Server How to optimize SQL Server Cursors What are cursors? SQL Server Hints Scalability: SQL Server 2005 Scaling Out Dynamic Management Views SQL Server Database System Tuning SQL Server: Index SQL Server : Backups From: http:\/\/sitestree.com\/?p=5221 Categories:38Tags: Post Data:2012-10-04 19:57:27 Shop\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":69274,"url":"http:\/\/bangla.sitestree.com\/?p=69274","url_meta":{"origin":69256,"position":3},"title":"SQL Server Short-notes at JustETC #38","author":"Author-Check- Article-or-Video","date":"August 16, 2021","format":false,"excerpt":"How to optimize query response time? How to optimize SQL Server Cursors What are cursors? SQL Server Hints Scalability: SQL Server 2005 Scaling Out Dynamic Management Views SQL Server Database System Tuning SQL Server: Index SQL Server : Backups SQL Server Short-notes at JustEtc SQL Server Short-notes at JustEtc From:\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":70215,"url":"http:\/\/bangla.sitestree.com\/?p=70215","url_meta":{"origin":69256,"position":4},"title":"Must Read: Database Driven Software Development #106","author":"Author-Check- Article-or-Video","date":"August 29, 2021","format":false,"excerpt":"If you are developing database driven applications, you must need to know and clearly understand the following concepts. Yes, you also need to apply them in your design and implementation. If you do not follow proper database design strategies, many complexities will arise, adjusting new requirements may become cumbersome to\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":75827,"url":"http:\/\/bangla.sitestree.com\/?p=75827","url_meta":{"origin":69256,"position":5},"title":"MS SQL Server Dynamic SQl, T-SQL","author":"Sayed","date":"June 25, 2023","format":false,"excerpt":"MS SQL Server Dynamic SQl, T-SQL Mostly: Dynamic SQL Stored Procedure Trigger Cursor Function Sayed Ahmed What are the Most Important Most Used Design ERD Convert ERD to database Normalization Indexing SQL Stored Procedure Dynamic SQL These will come, not too frequent Function, User Defined Data Types, Temporary Table Trigger,\u2026","rel":"","context":"In &quot;\u09ac\u09cd\u09b2\u0997 \u0964 Blog&quot;","block_context":{"text":"\u09ac\u09cd\u09b2\u0997 \u0964 Blog","link":"http:\/\/bangla.sitestree.com\/?cat=182"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/69256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=69256"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/69256\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=69256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=69256"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=69256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}