Answer the question
In order to leave comments, you need to log in
How to optimize select?
Good day. There is one very resource-intensive query with a cursor of 250 thousand lines, and a mask search inside the cursor for ~ 2 thousand lines.
A perversion, but I didn’t come up with another one - you need to identify the purpose of the payment from a bank statement, and it always says something different there.
I need to get the number of matches by mask, and if there is only one match, get the ID of this line.
Option was thought up 2.
1 - in the temporary table, then counting.
select *
into #temp1
from #temp_pay_parser
where @str like [contract_mask]
2 are two selects with mask search.
In general, both queries work out approximately the same - 1 line in 2 seconds.
Is there any way to get both values in one select, in order to cut the processing time in half? in MySQL there was a bug like
select top 1 @a = count(*), @b = [id]
from #temp_pay_parser
where @str like [contract_mask]
Is there a similar option for MSSQL 2008?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question