Self outer Join alternative for inserting into Physical table from Temp table

不想你离开。 提交于 2019-12-12 18:24:39

问题


How to improve the performance of this query?

INSERT INTO ABC(TRACKING_ID,GROUP_ID,ETL_NUM,ENTITY_ID,UNI_ID,DOS_TO)
SELECT A.TID,A.TID2,A.ETL_NUM,A.ENTITY_ID,A.UNI_ID,A.DOS_TO
FROM #TEMP A(NOLOCK)
LEFT OUTER JOIN #TEMP B(NOLOCK) ON A.TID=B.TID
AND ETL_NUM<B.ETL_NUM
WHERE B.TID IS NULL

I have 11 million records. It takes 9 hours to process this query. For tuning this query i have added index on Temp table ETL_NUM. But it didnt improve performance.

I don't have Admin privileges on DB.


回答1:


Could you make it clearer?

Do you want to insert 11millions records into the DB you don't have Admin authority?

And you want to insert all the data manually? So, you think it takes around 9 hours. Or for just one query you wrote down takes 9hours?

Well, If you are talking about the former one, It depends how you have the data. If you have the data in JSON or in a stylesheet or this kind of file. It can be easier. If it is latter one, you may need to ask the admin and discuss about it.



来源:https://stackoverflow.com/questions/49714734/self-outer-join-alternative-for-inserting-into-physical-table-from-temp-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!