以下的运行起来得4个多小时
1 SET STATISTICS IO ON 
2 select pkid 
3 from et_order  
4 where pay_type = 4 and status = 20 and pkid not in (select isnull(get_orderid,0from score_Get)

 

 

以下运行起来就几秒钟

 

代码
1 Create Table #T
2 (
3     get_orderid int
4 )
5 
6 insert into #T select isnull(get_orderid,0from score_Get
7 
8 select pkid from et_order  where pay_type = 4 and status = 20 and pkid not in (select * from #T)

 

 

 

总结:

 

    要把数据库语句写的尽量简单,这样它的运行效率会快很多

相关文章:

  • 2021-10-30
  • 2021-06-23
  • 2021-12-14
  • 2021-11-30
  • 2021-11-19
  • 2021-10-17
  • 2021-08-16
猜你喜欢
  • 2022-12-23
  • 2021-10-20
  • 2021-12-05
  • 2021-07-30
  • 2021-08-19
相关资源
相似解决方案