title: Why is a SQL query executing slower in PHP than in Query Analyzer
body: <p>I have a query that takes 5 seconds to run in SQL Server Managment Studio, but it takes 33 seconds in PHP to run the same query using <em>$qid=db_query($countQuery);</em>
  Has anyone got any idea why this might be?</p>
  
  <p>We are using SQL Server 2000 which I do not believe is the problem.</p>
  
  <p>[edit]
  After doing some profiling we noticed that the execution plans were completely different between the analyzer and the query from PHP.  This was done on a single machine, web, sql and query analyzer.</p>
  
  <p>Any Ideas?</p>
  
  <p>Thanks</p>