SQL Server Query Slow from PHP, but FAST from SQL Mgt Studio - WHY?

前端 未结 3 1622
无人共我
无人共我 2020-12-20 22:55

I have a fast running query (sub 1 sec) when I execute the query in SQL Server Mgt Studio, but when I run the exact same query in PHP (on the same db instace) using FreeTDS

相关标签:
3条回答
  • 2020-12-20 23:14

    Using the LOGIN EVENT (and EXISTING CONNECTION) in SQL Profiler with the Text column will show the connection settings of a lot of important SET commands--Arithabort, Isolation Level, Quoted Identifier, and others. Compare and contrast these between the fast and slow connections to see if anything stands out.

    0 讨论(0)
  • 2020-12-20 23:16

    what settings are on, usually ARITHABORT is the culprit, it is ON in SSMS but you might be connecting with it off

    Run this in SSMS while you are running your query and see what the first column is for the session that is connected from PHP

    select arithabort,* from sys.dm_exec_sessions
    where session_id > 50
    
    0 讨论(0)
  • 2020-12-20 23:22

    Run the SQL Profiler, and set up a trace and see if there are any differences between the two runs.

    0 讨论(0)
提交回复
热议问题