I have a query that works every day for a little over 2 years and usually takes less than 30 seconds. Suddenly, yesterday, the request began to take 3 hours to complete and used a 100% processor all the time.
SQL:
SELECT @id, alpha.A, alpha.B, alpha.C, beta.X, beta.Y, beta.Z, alpha.P, alpha.Q FROM [DifferentDatabase].dbo.fnGetStuff(@id) beta INNER JOIN vwSomeData alpha ON beta.id = alpha.id
alpha.id- type BIGINT, and beta.id- type INT. dbo.fnGetStuff()- A simple SELECT statement with 2 INNER JOINs on tables in the same database using WHERE id = @id. The function returns approximately 11000 results.
alpha.id
beta.id
dbo.fnGetStuff()
WHERE id = @id
A view vwSomeDatais a simple SELECT statement with two INNER JOINs that returns about 590,000 results.
vwSomeData
10 , . , < 10 .
, ? .
. , . - , .
SQL Server Profiler SQL Server. , , , , , .
SQL Server Management Studio, , "". , . , - .
, .
? , @ID .
, @ID WHERE, .
, , , Query Analyzer , . , Transact-SQL, , , , .
, INDEX, SQL.
, , , , .
, . , . temp .
, , , . , , , , - . , , , - , , , , ? - , . , , - .
SELECT @id, alpha.A, alpha.B, alpha.C, beta.X, beta.Y, beta.Z, alpha.P, alpha.Q FROM [DifferentDatabase].dbo.fnGetStuff(@id) beta INNER HASH JOIN vwSomeData alpha ON beta.id = alpha.id
- , :
... Profiler ... , . , - [DifferentDatabase]. , , .
:
SET SHOWPLAN_ALL ON
. , "" . , , . , , ( ..)
Source: https://habr.com/ru/post/1707661/More articles:How to set page title in ASP.NET MVC view? - asp.net-mvcCan anyone recommend from the shelf ACL Java lib? - javaHow to make the menu item "Panel" the displayed number of rows in the table? - cocoaHow to show borders of an interactive symbol? - ruby-on-railshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1707660/when-doing-equal-height-columns-in-css-is-there-a-way-to-get-internal-anchor-links-to-still-function-correctly&usg=ALkJrhg9lobaCVJVfB7gzg9gfjDK090HDgWhat is the data structure of the Inode number? - filesystemsnew Windows 7 systray - how to show information to users now - windows-7Complex forms and scripts in Access - ms-accessautorun.inf: how to get a drive letter? - windowsCan I install 2008 SQLExpress with 2005 SQLExpress? - sql-serverAll Articles