Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Significant drop in performance on If Exists, and while loop blocks

$
0
0
Greetings all :) I am running into a situation I have never experienced in 12 years. I have an Except query, comparing two tables. This query runs in 2 seconds. It rarely every returns data, so I use an 'If Exists' logic to see if there is data, otherwise move on in the proc. For reasons unknown, when I wrap this in any sort of conditional logic, it takes longer than 30 seconds to execute, which is extremely baffling. I have tried If exists, while exists, wrapping it in a '(select count(*) from (subquery) as x) >0' type query. Nothing changes is. Does anyone know why this occurs? The tables are not large, they are 40k records each, and only one column is being compared in Except query, which are both tables primary key. So logistically, there should be nothing from a table structure, or query structure standpoint causing this. Any ideas as to why SQL is doing this?

Viewing all articles
Browse latest Browse all 3145

Latest Images

Trending Articles



Latest Images