how to calculate the RAM used while running a query

  • 892717952

    SSC-Addicted

    Points: 477

    how to calculate the RAM used while running a query, for example, I run the following code, how can I know the RAM used by this statement.  thanks in advance!

    select * from table1 t1 left join table2 t2

    ON t1.f1=t2.f1 and t1.f2=t2.f2

    where t1.f5='active'

  • Site Owners

    SSC Guru

    Points: 80372

    Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

  • 892717952

    SSC-Addicted

    Points: 477

    thank you for your help!

    Hoping to get an answer  here.

     

  • 892717952

    SSC-Addicted

    Points: 477

    Sorry for my bothering !

    How to calculate the RAM used while running a query, for example, I run the following code, how can I know the RAM used by this statement.  thanks in advance!

    select * from table1 t1 left join table2 t2

    ON t1.f1=t2.f1 and t1.f2=t2.f2

    where t1.f5='active'

  • Jo Pattyn

    SSC-Dedicated

    Points: 31415

    (size of data table t1 + size of t2 join fields) * (number of rows in t2) ? SQL Server estimates it . Can be lower if data is streamed (max size for one record in table 1)

    https://techcommunity.microsoft.com/t5/sql-server/understanding-sql-server-memory-grant/ba-p/383595

    https://sqlperformance.com/2019/06/sql-memory/troubleshooting-variable-memory-grants

    • This reply was modified 1 month ago by  Jo Pattyn.
  • 892717952

    SSC-Addicted

    Points: 477

    thank you so much, Jo pattyn!

  • Jeff Moden

    SSC Guru

    Points: 997308

    Calculating the amount of RAM used by a query isn't a very common question and so my curiosity has been piqued quite a bit.  Why did you need to know how much RAM was being used by a query?

    As you say, hoping to get an answer here. 😀

    --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".
    "Dear Lord... I'm a DBA so please give me patience because, if you give me strength, I'm going to need bail money too!"

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

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

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