Load Memory usage in SQL Server

ACDBA 421 Reputation points
2021-04-26T17:47:52.493+00:00

I would like to load test a dev sql server . I want to make sql server memory usage close to 100%. Is there scripts available? I got certain scripts which only increase CPU.. Not memory.

SQL Server Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2021-04-26T21:38:10.75+00:00

    Create a table and fill it up with data, so that it's size exceeds the available memory SQL Server with a factor of 2 or so. Tip: add a char(8000) column with a default of ' ', so you don't need that many rows.

    Once you have done that, run an operation which forces SQL Server to scan that table, for instance

    SELECT * FROM tbl WHERE bigcol LIKE '%junk%'

    Then again, you may have more specific ideas of what memory you to fill up. This fills up the buffer cache, which is by far the simplest.

    1 person found this answer helpful.
    0 comments No comments

  2. Cris Zhan-MSFT 6,661 Reputation points
    2021-04-27T09:18:05.383+00:00

    Hi,

    The caching of data pages usually occupies most of the memory usage of SQL Server. As long as there is no memory pressure, SQL Server will keep the read data in the memory to achieve optimal performance, because it is faster to read from the memory than to read the data from the hard disk. As Erland said, the most direct way is for the user to send a large data query request, which will fill up the buffer cache.

    Not sure if you manually specify the maximum server memory (Max Server memory) for your SQL Server instance. If you do not specify this option, SQL Server will dynamically change its memory requirements based on the available system resources, which is also the recommended practice. .

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.