{"id":2198,"date":"2017-08-17T18:02:12","date_gmt":"2017-08-17T16:02:12","guid":{"rendered":"http:\/\/soci.hu\/blog\/?p=2198"},"modified":"2017-08-17T18:04:59","modified_gmt":"2017-08-17T16:04:59","slug":"forceseek-delete-hez","status":"publish","type":"post","link":"https:\/\/soci.hu\/blog\/index.php\/2017\/08\/17\/forceseek-delete-hez\/","title":{"rendered":"Forceseek delete-hez"},"content":{"rendered":"<p>Volt egy delete-em, ami nem akart rendesen index ment\u00e9n lefutni. A delete-et kicser\u00e9lve select-re ugyanez volt a helyzet, de select eset\u00e9n egy oszlopokkal kik\u00e9nyszer\u00edtett forceseek seg\u00edtett.<br \/>\nViszont delete-et nem lehet hintelni. A megold\u00e1s CTE volt, \u00edgy indirekten m\u00e9giscsak lehet hintelni. A lek\u00e9rdez\u00e9s p\u00e1r sz\u00e1zszor gyorsabb lett. :)<\/p>\n<p>\u00c9rdemes megjegyezni h\u00e1rom tr\u00fckk\u00f6t tanuls\u00e1gul:<br \/>\n1. CTE kimenet\u00e9n lehet futtatni DDL-eket<br \/>\n2. \u00cdgy indirekten lehet hintelni<br \/>\n3. N\u00e9ha j\u00f3 index eset\u00e9n se seekel a szerver, ilyenkor csakis az oszlopokkal megseg\u00edtett forceseek seg\u00edt.<\/p>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\">\r\n;with B\r\nas\r\n(\r\nselect * from dbo.Bar with(forceseek(IX_Natural_Key(TickerId, BDT)))\r\nwhere TickerId = @tickerId and BDT in \r\n    (select DATEADD(day, DATEDIFF(day,'19000101',DATEADD(DAY, 1, cast(StartDate as datetime))), CAST(ClosingTime AS DATETIME2(7)))\r\n    from TradingHours where TickerId = @timeTemplateTickerId and StartDate is not null and EndDate is null and IsEnabled = 1 and Priority &gt; 10)\r\n)\r\ndelete from B;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Volt egy delete-em, ami nem akart rendesen index ment\u00e9n lefutni. A delete-et kicser\u00e9lve select-re ugyanez volt a helyzet, de select eset\u00e9n egy&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,4,30],"tags":[],"class_list":["post-2198","post","type-post","status-publish","format-standard","hentry","category-adatbazisok","category-szakmai-elet","category-sql-server"],"_links":{"self":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=2198"}],"version-history":[{"count":3,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2198\/revisions"}],"predecessor-version":[{"id":2202,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/2198\/revisions\/2202"}],"wp:attachment":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=2198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=2198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=2198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}