{"id":115,"date":"2025-09-30T12:31:57","date_gmt":"2025-09-30T02:31:57","guid":{"rendered":"http:\/\/blog.lapthorne.com.au\/?p=115"},"modified":"2025-09-30T12:31:57","modified_gmt":"2025-09-30T02:31:57","slug":"some-random-tips-for-a-guy-at-work","status":"publish","type":"post","link":"https:\/\/blog.lapthorne.com.au\/?p=115","title":{"rendered":"Some Random Tips for a Guy at Work."},"content":{"rendered":"\n<p>____________________________________________________________<\/p>\n\n\n\n<p><strong>Table of Contents<\/strong><\/p>\n\n\n\n<ol start=\"0\" class=\"wp-block-list\">\n<li>Details<\/li>\n\n\n\n<li>Indexes Present\n<ol start=\"1\" style=\"list-style-type:lower-alpha\" class=\"wp-block-list\">\n<li>Dbo.Harvest Primary Key<\/li>\n\n\n\n<li>All Indexes in DB<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>How to Trace It<\/li>\n<\/ol>\n\n\n\n<p>____________________________________________________________<\/p>\n\n\n\n<p><strong>0__Details<\/strong><\/p>\n\n\n\n<p>Just Confirming I was in the Right Place,<\/p>\n\n\n\n<p>Was Looking @<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>DB\n<ul class=\"wp-block-list\">\n<li>Dbo.Harvest<\/li>\n\n\n\n<li>Dbo.Setting<\/li>\n\n\n\n<li>Dbo.SettingSnapshot<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>Files: Anything I link or show below can be found here<\/p>\n\n\n\n<p>\u00a0xx.0 &#8211; GMDB Database Locks in Settings Table<\/p>\n\n\n\n<p>____________________________________________________________<\/p>\n\n\n\n<p><strong>1_Indexes Present<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Indexes = Dbo.Harvest\n<ul class=\"wp-block-list\">\n<li>\u2018cnstHarvest\u2019\n<ul class=\"wp-block-list\">\n<li>This is one due to the Primary Key on the table, and is a non-locking index and *<strong>should<\/strong>* not be causing the issue<\/li>\n\n\n\n<li>Removing this index will remove the ability to ensure the Primary Key is Unique<\/li>\n\n\n\n<li>Confirmed via a re-creation: \u00a0Index Creation _ Harvest _ Private Key.sql\n<ul class=\"wp-block-list\">\n<li><strong>Suggestion:<\/strong> we leave it there, the \u2018risk vs reward\u2019 gut check isn\u2019t in our favour.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Indexes = Entire Database\n<ul class=\"wp-block-list\">\n<li>I have extracted all of the potential locking indexes via the below script, results attached:\n<ul class=\"wp-block-list\">\n<li>Script: \u00a0Grab All Indexes _ Non Key.sql<\/li>\n\n\n\n<li>Results: \u00a0All Indexes in DB_MG.xlsx<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Did a second pass, to ensure there wasn\u2019t anything hiding:\n<ul class=\"wp-block-list\">\n<li>Script: \u00a0Return Index Info for Table.sql<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To be honest, I found little of interest in the above w\/ our current issues<\/li>\n<\/ul>\n\n\n\n<p>____________________________________________________________<\/p>\n\n\n\n<p><strong>2_Trace It Manually<\/strong><\/p>\n\n\n\n<p>See below to set the mood.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"405\" height=\"303\" src=\"https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-4.png\" alt=\"\" class=\"wp-image-120\" srcset=\"https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-4.png 405w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-4-300x224.png 300w\" sizes=\"(max-width: 405px) 100vw, 405px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Best way to handle this is to run a SQL Activity trace, but it needs both of us online and with time to kill.\n<ul class=\"wp-block-list\">\n<li>I can also lend Shah to the process if I am not around.\n<ul class=\"wp-block-list\">\n<li>Some of the below is for his benefit, just in case.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>I have installed a couple toys to help,\n<ul class=\"wp-block-list\">\n<li><strong>Sp_BlitzLock<\/strong>\n<ul class=\"wp-block-list\">\n<li>Handy proc for diagnosing active locks, is now in Master of SQL1 (and SQL0)<\/li>\n\n\n\n<li>Simple as\n<ul class=\"wp-block-list\">\n<li>Execute sp_BlitzLock on DB;<\/li>\n\n\n\n<li>If there was anything to show:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2197\" height=\"658\" src=\"https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image.png\" alt=\"\" class=\"wp-image-116\" srcset=\"https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image.png 2197w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-300x90.png 300w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-768x230.png 768w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-1536x460.png 1536w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-2048x613.png 2048w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SQL Activity Monitor &amp; SSIS Automation Suggestions<\/strong>\n<ul class=\"wp-block-list\">\n<li>Helpful in the moment, but useless after its already happened.\n<ul class=\"wp-block-list\">\n<li>Using \u2018Recent Expensive Queries\u2019 records, you should be able to ID any queries clashing and generating locks and \u2018lock_wait\u2019 or \u2018deadlock\u2019 status flags.<\/li>\n\n\n\n<li>By right clicking on expensive queries that affect those locks, you can select \u201cShow Execution Plan\u201d\n<ul class=\"wp-block-list\">\n<li>This delivers the below screenshot, where it shows you where the wait and lag are of the execution,<\/li>\n\n\n\n<li>I regularly use this to ID a Stat or Index that is making the process slow and removing \/ updating it.<br>See below, it is showing the table scan is taking 45% of the effort (by design with an index, no fix needed)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2023\" height=\"495\" src=\"https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-1.png\" alt=\"\" class=\"wp-image-117\" srcset=\"https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-1.png 2023w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-1-300x73.png 300w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-1-768x188.png 768w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-1-1536x376.png 1536w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SQL Profiler<\/strong>\n<ul class=\"wp-block-list\">\n<li>Full Admin Access Req<\/li>\n\n\n\n<li>Will Run a Profiler against active connections as they run,\n<ul class=\"wp-block-list\">\n<li>Will Slow the DB and Server, down while the trace is running, so we cant leave it running for ages.\n<ul class=\"wp-block-list\">\n<li>Example of what I would usually focus on<br><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"950\" height=\"611\" src=\"https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-2.png\" alt=\"\" class=\"wp-image-118\" srcset=\"https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-2.png 950w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-2-300x193.png 300w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-2-768x494.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What the Output looks like:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1783\" height=\"786\" src=\"https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-3.png\" alt=\"\" class=\"wp-image-119\" srcset=\"https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-3.png 1783w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-3-300x132.png 300w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-3-768x339.png 768w, https:\/\/blog.lapthorne.com.au\/wp-content\/uploads\/2025\/09\/image-3-1536x677.png 1536w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>____________________________________________________________ Table of Contents ____________________________________________________________ 0__Details Just Confirming I was in the Right Place, Was Looking @ Files: Anything I link or show below can be found here \u00a0xx.0 &#8211; GMDB Database Locks in Settings Table ____________________________________________________________ 1_Indexes Present ____________________________________________________________ 2_Trace It Manually See below to set the mood.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-115","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/blog.lapthorne.com.au\/index.php?rest_route=\/wp\/v2\/posts\/115"}],"collection":[{"href":"https:\/\/blog.lapthorne.com.au\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.lapthorne.com.au\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.lapthorne.com.au\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.lapthorne.com.au\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":1,"href":"https:\/\/blog.lapthorne.com.au\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/blog.lapthorne.com.au\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions\/121"}],"wp:attachment":[{"href":"https:\/\/blog.lapthorne.com.au\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.lapthorne.com.au\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.lapthorne.com.au\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}