2017-09-28 2 views
-2

코드를 다시 작성하는 더 좋은 방법이 있습니까? 쿼리는 영원히 실행됩니다. 감사합니다시간 초과되는 SQL 쿼리의 속도를 높이려면 어떻게합니까?

SELECT * from w..ts 
    where not si in 
    (
    select si from g..sa 
    ) 
    and ci in 
    (
    Select ClientID from w..tcwhere ds= 'AZ' 
    ) 
    and s> 2 
    and sd between '1/1/2010' and GETDATE() 
    order by si 
+4

안녕하세요. [ask]를 읽으십시오. 이것은 질문이 아닙니다. 어떤 DB 플랫폼, 어떤 구체적인 오류가 있습니까? – OldProgrammer

+0

실제 웹 서비스입니까? 이것은 유용한 정보를 줄 수있는 정보가 아닙니다. –

+0

쿼리 실행에 영원히 걸리는 코드를 다시 작성하는 더 좋은 방법이 있습니까? – Alexo

답변

1

조인을 고려하거나 대신 적용하십시오.

SELECT * from webservice..tService 
left join table t1 on t1.col1 = tService.col2 
inner join table t2 on t2.col1 = tService.col2 
where t1.ServiceID is null 
and ServiceStep > 2 
and ServiceDate between '1/1/2010' and GETDATE() 
order by ServiceID 
관련 문제