Slow running query

  • This is the query which takes about 32 seconds to execute. Any help will be appreciated.

    Checked the index on **ID which is only 10% fragmented. No blocking issues.

    SELECT fct.AccountID, count(*)

    FROM fctAssetFulfillment fct

    JOIN FulfillmentPartnerInstall fpi ON fpi.FMProBoxID = fct.AMC_BoxID

    WHERE fct.Source = 'FMPro' AND isnumeric(fct.AMC_BoxID)<>0

    AND fct.SerialNo = fpi.SerialTag

    AND fpi.CompletionDate IS NOT NULL

    AND fpi.AssetUsage LIKE '%install%'

    AND fct.InstallActualDate<>fpi.CompletionDate

    --AND (fct.FulfillmentStatus <> 'installed')

    GROUP BY fct.AccountID

    "He who learns for the sake of haughtiness, dies ignorant. He who learns only to talk, rather than to act, dies a hyprocite. He who learns for the mere sake of debating, dies irreligious. He who learns only to accumulate wealth, dies an atheist. And he who learns for the sake of action, dies a mystic."[/i]

  • Can you attach the actual execution plan please, saved as a .sqlplan file? Thanks.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • for this query, i think we'd need to see the actual execution plan on this, as well as a list of all indexes on the fctAssetFulfillment and the FulfillmentPartnerInstall tables.

    can you post that here as a .sqlplan attachment?

    one problem is this portion of the WHERE statement:

    AND fpi.AssetUsage LIKE '%install%'

    'that's going to require a scan of the table; is there another way to filter the data to get the same rows? a status which coincides with that, maybe?

    New Born DBA (1/14/2014)


    This is the query which takes about 32 seconds to execute. Any help will be appreciated.

    Checked the index on **ID which is only 10% fragmented. No blocking issues.

    SELECT fct.AccountID, count(*)

    FROM fctAssetFulfillment fct

    JOIN FulfillmentPartnerInstall fpi ON fpi.FMProBoxID = fct.AMC_BoxID

    WHERE fct.Source = 'FMPro' AND isnumeric(fct.AMC_BoxID)<>0

    AND fct.SerialNo = fpi.SerialTag

    AND fpi.CompletionDate IS NOT NULL

    AND fpi.AssetUsage LIKE '%install%'

    AND fct.InstallActualDate<>fpi.CompletionDate

    --AND (fct.FulfillmentStatus <> 'installed')

    GROUP BY fct.AccountID

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Does this help?

    "He who learns for the sake of haughtiness, dies ignorant. He who learns only to talk, rather than to act, dies a hyprocite. He who learns for the mere sake of debating, dies irreligious. He who learns only to accumulate wealth, dies an atheist. And he who learns for the sake of action, dies a mystic."[/i]

  • No, they're just pictures. It's like asking for a car and being given a picture. Execution Plans are active - hover over objects to view properties etc.

    Right-click on the execution plan (actual, not estimated) and select "save execution plan as..."

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • not really;

    the actual SQL plan allows us to review deep details of the plan, and tell if stats are out of date, which columns were used, which indexes, and so much more;

    a picture of it's not enough.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • I did save the plan but I don't know how to copy it on my local machine.

    "He who learns for the sake of haughtiness, dies ignorant. He who learns only to talk, rather than to act, dies a hyprocite. He who learns for the mere sake of debating, dies irreligious. He who learns only to accumulate wealth, dies an atheist. And he who learns for the sake of action, dies a mystic."[/i]

  • This should help you to post the information needed.

    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2

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

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