SQL Server Performance

Query Slow?

Discussion in 'SQL Server 2005 T-SQL Performance Tuning' started by tcdbms, Nov 26, 2008.

  1. tcdbms New Member

    I have a table: A
    A table have 325 columns, have three thousands rows
    Run Below Statements:
    SELECT A.*, P.Price,P.Num FROM A LEFT JOIN (SELECT ID, MIN(Price) Price, MIN(LastNum) Num FROM B GROUP BY ID) P ON A.CarId=P.CarId
    Sql server query window: cost tims 2s
    But IN Client Program Run ,Cost time Very Long, Over 1 minutes,
  2. Adriaan New Member

    What client application? For instance if it's an MS Access MDB with ODBC-linked tables, the query will be executed by the Jet engine on the workstation, instead of the MS SQL Server engine on the server. Data has to pass through the network ... all kinds of delays can present themselves.
  3. tcdbms New Member

    Client Program: Visual C# 2008
    Database: SQL SERVER 2005
  4. Adriaan New Member

    Just looked a little closer at the query - you're returning all 325 columns of table A to the VC# app, since your query says SELECT A.* ... All that data has to pass through your network, and your app has to sit still and wait for it to arrive. Always select only relevant columns.
    With the SQL query window, you're pretty much looking at the local execution time on SQL Server.
    Are you comparing the execution times of the query between the SQL query window and the VC# app? There could be local processing of the results in the VC# app that takes up additional time too.
  5. satya Moderator

    Also if it is a dynamic prepared statment then the performance will be hit, in any case it will be better to check on indexes on that relevant columns specified.
  6. tcdbms New Member

    To Adriaan and satya , Thank you!
    Now, A table have a index for primary key only, How tune the table performance?

Share This Page