SQL taking too much time for executing a query

后端 未结 2 1881
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-24 15:42

i am using below query to generate some information of around 7k lines. but the issue is that the query is taking too much time to complete just 7k line. i need to fine tune it.

2条回答
  •  鱼传尺愫
    2021-01-24 16:36

    I use the SQL Profiler to auto create the indexes needed for a fine tune query.

    • Enter in SSMS (SQL Server Management Studio) -> Tools -> SQL Server Profiler.

    • Click Connect, and then click Run, to start a new trace.

    • Execute your slow query now, so the profiler can capture and record it.

    • Stop the query and File -> Save it.

    • In the menu, click Tools -> Database Engine Tuning advisor.

    • Click Connect when it opens, and in Workload, select file, and click the first button on the right (binoculars one). Then select the file you have just saved.

    • Select now the checkbox of your database, and click the "Start Analysis" button (below the "View" and "Action" menu).

    • Once it finish, open "Action" menu, and click in "Apply Recommendations".

    Now you should have a fast and fine tuned query.

提交回复
热议问题