Question

OK, I was looking at potentially reducing this (as more of an exercise than a need mind you) and it seems that Im getting this warning on what appears to be a better performing query and not on the query that requires more memory to execute? Is this weird or am I just over thinking?

Anyone want to educate me here (sorry for the large images)?

1st query and hover over:

    UPDATE c SET c.scust_phone = cc.scontract_holder_hphone
    FROM #Claims c 
    INNER JOIN SCS.scs_auto_sra.scs_contracts cc ON c.icontract_id = cc.icontract_id ;

enter image description here

second query and hover over:

    UPDATE c SET c.scust_phone = cc.scontract_holder_hphone
    FROM #Claims c 
    INNER JOIN 
        (
            SELECT icontract_id, scontract_holder_hphone 
            FROM SCS.scs_auto_sra.scs_contracts cc 
            WHERE EXISTS (SELECT icontract_id FROM #Claims x WHERE x.icontract_id = cc.icontract_id )
        ) cc ON c.icontract_id = cc.icontract_id ;

enter image description here

Was it helpful?

Solution

Actually, the warning for excessive memory grant uses an hardcoded logic. It raise an alert when a certain % of the allocated memory is not use but it does not considere the amount of wasted memory.

It cannot be "trusted" and you should not worry about it if, like in this case, it's only 1Mb that is allocated and not use.

I've seen cases where I got a warning for something like this (1Mb allocated, 1 Mb non-used) and cases where there was 256Mo allocated and like 136 Mo used (so 120Mo non-used) and there was no warning.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top