Very strange performance issue

  • I have a simple query, if i run that query from SSMS it takes about 10 mins and if i run the same query as a exec sql task inside SSIS package takes less than 3 mins? I am clearing the buffers after each execution, and yes the source connection strings are the same. I am logged in the server and testing using SSMS and SSIS. Is there any reason why it is faster from SSIS? Query returns about 20 million records

    SELECT * FROM vwActivities WHERE

    CreatedDateKey>=20130101 and Fde='A123'

  • 20 million rows? It will take SSMS quite some time to render all those rows, particularly if you have results set to grid!

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]

  • Short answer: SSMS is incredibly inefficient at displaying rows.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • curious_sqldba (8/16/2013)


    I have a simple query, if i run that query from SSMS it takes about 10 mins and if i run the same query as a exec sql task inside SSIS package takes less than 3 mins? I am clearing the buffers after each execution, and yes the source connection strings are the same. I am logged in the server and testing using SSMS and SSIS. Is there any reason why it is faster from SSIS? Query returns about 20 million records

    SELECT * FROM vwActivities WHERE

    CreatedDateKey>=20130101 and Fde='A123'

    I guess I'd have to ask where you're putting the results for that query because I sure can't imagine returning 20 million rows to the screen... ever! I guess I'd also be curious why you're using an integer to represent a date/time unless the intent is to export to a file.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • curious_sqldba (8/16/2013)


    I have a simple query, if i run that query from SSMS it takes about 10 mins and if i run the same query as a exec sql task inside SSIS package takes less than 3 mins? I am clearing the buffers after each execution, and yes the source connection strings are the same. I am logged in the server and testing using SSMS and SSIS. Is there any reason why it is faster from SSIS? Query returns about 20 million records

    SELECT * FROM vwActivities WHERE

    CreatedDateKey>=20130101 and Fde='A123'

    A SELECT * query is also extremely inefficient. You are returning 20m rows and SQL Server has to touch every row and every field inorder to return the results you are looking for.

    Have you used the SQL Profiler to see if the execution plans Show up anything obvious? In this case I would suggest performing a server-side trace because I could easily imagine running the query inside the GUI (in your case the SSMS) is affecting the Overall Performance of the query.

  • Even if it coud be done efficiently, I'd still like to know why someone is building a result set that contains 20 million rows.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (8/18/2013)


    Even if it coud be done efficiently, I'd still like to know why someone is building a result set that contains 20 million rows.

    So Curious_sqldba did mention that he also ran the query in SSIS. I assume that he exporting the data. For which, of course, SSMS is not a good tool.

    [font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]

  • Erland Sommarskog (8/18/2013)


    Jeff Moden (8/18/2013)


    Even if it coud be done efficiently, I'd still like to know why someone is building a result set that contains 20 million rows.

    So Curious_sqldba did mention that he also ran the query in SSIS. I assume that he exporting the data. For which, of course, SSMS is not a good tool.

    Agreed... that's why I hate to assume and asked the question.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply