Bad execution plan and wrong result by SQL SERVER

  • Hi, I didn't receive any answer about my problem. I'll repeat that!:

    I have one query:

    SELECT count(*) FROM SAM_GUIA_EVENTOS E,

    SAM_GUIA G WHERE G.PEG= 752074

    AND E.GUIA= G.HANDLE AND E.CLASSEGERENCIALPAGTO is NULL

    This query, after many updates after rebuid at saturday, return column E.CLASSEGERENCIALPAGTO with not null(many data). The execution plan mount merger join with hash aggregate, that too lazy. I test this at monday(one day after rebuil), but the result is correct, but when that query are executed at middle of week, change some G.PEG values, the result is total wrong.

    Plese, anyone help me to this question!

  • I'd suggest rewriting the reqery using ANSI-92 e.g.

    SELECT count(*)

    FROM SAM_GUIA_EVENTOS E

    INNER JOIN SAM_GUIA G

       ON E.GUIA = G.HANDLE and G.PEG= 752074

    WHERE E.CLASSEGERENCIALPAGTO is NULL

     

    Steven

  • What is the version of SQL Server including the build number?

    "after many updates after rebuid at saturday" - Did you run a index optimization after the updates?

    SQL = Scarcely Qualifies as a Language

  • I just do it!. The real problem is not the query or some additional hint to boots it. The problem is the wrong result at middle of week that return E.CLASSEGERENCIALPAGTO  not null. I change that query many times in good plans. Originally , I can't change the compilated query in application and every week I have this hell! I can't rebuit index and update statistics in any days of week , except weekends...so...what can I do?

  • Index optimization after the updates? Yes , I created one Job to do this. The job add recompile SP and Triggers.

Viewing 5 posts - 1 through 4 (of 4 total)

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