Skip to content
Advertisement

Select into a temporary table efficiency is faster than direct query

Case:

Query below sql need 10.56 sec, and 236 rows were queried.

Estimated Execution Plan:
image Most cost:
image

After I try to use select into temporary table then it just need 0.03 sec

Estimated Execution Plan: image

Then I’ve tried add below index, but it still no change.

hct_mlots table create sql,total rows 88790

mf_mo table create SQL

Advertisement

Answer

I made an idiot mistake, two column types are different, mf_mo’s mo_no is varchar(20) and hct_dailywork is nvarchar(200), so indexs do not work for them.. (I used automatic generation tool for convenience, but not double check)

Updated estimated execution plan image

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement