r/SQLServer • u/XdtTransform • Jun 16 '26
Question How much RAM does my SQL Server actually need?
I am trying to determine how much RAM our SQL Server needs. I've googled around, but I can't get a definitive answer as there are so many opinions out there.
The server has 78 GB of RAM installed. Of which 3 is available.
The allocation says 99% of RAM is utilized. The buffer is up there though, but I can't tell if this is good or bad.
I've also checked various wait stats, but once again, I can't tell if these are bad or not. And all these queries were taken after hours.
And the page life expectancy I think is fine.
The CPU during the day is between 20 and 60 percent depending on tasks going on. The users complain very occasionally about slowdowns, but when I look at the current queries I don't see anything obvious. But also, from what I've observed, the users are perfectly ok with something being slow, so they are unlikely to report anything unless it physically impedes their work.
So based on this... does the server need more RAM?
P.S. The server hosts a single 350 GB database (e.g. that's the size of the full backup) and some minor ones that in total are less than 1GB. The server probably has low 5 digit sessions per day. Most transactions are short and read-only. A few are heavy duty, like reports, data denormalization, etc... And since someone asked, here are the server properties, including parallelism. The SQL Server itself is 2017 Standard Edition running on Windows Server 2016 Standard.
•
u/AutoModerator Jun 16 '26
After your question has been solved /u/XdtTransform, please reply to the helpful user's comment with the phrase "Solution verified".
This will not only award a point to the contributor for their assistance but also update the post's flair to "Solved".
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
17
u/JamesTweet Jun 16 '26
Make sure you set the maximum amount of memory that SQL Server can use so that the OS has some memory. In your case I would say to allow SQL Server to use 68 GB. That leaves 10 GB for the OS.
5
u/Better-Credit6701 Jun 16 '26
You didn't mention how much data.
4
u/blinner 1 Jun 16 '26
Nothing on those stats screams out a need for more RAM.
How big are the databases being supported by this server?
2
u/ddBuddha Jun 16 '26
Not related to the memory but you probably want to adjust the parallel processing related settings, the default cost threshold for parallelism (ctfp) of 5 is way too low for modern processors. You should also set the maximum degrees of parallelism (mdop) to the appropriate value for your server and workload.
7
u/plaid_rabbit Jun 16 '26
Just something you won't be used to... SQL server by default eats all the ram it can on a machine. It assumed it's the only major app installed on it and if it can use the ram for something, it will. It sees free ram and considers it wasted. It'll use as much for caching things as it can. So 95% memory utilization is totally normal. So ignore the memory utilization metric.
PLE Is one of a few metrics that show you're running low in ram... And it says you're fine.
20-60% CPU usage might be something to look at.
You need to look at a bunch of different things to see what's eating up all your CPU. Sometimes it's a badly behaved commonly run query. At one company, the wost case was a simple select * from users where email = @username... That was done on every page. Email was index and everything. What had been overlooked was @usename was a nvarchar, but email was a varchar, so it was scanning a million rows on every request... A quick change to the query and the site became so much more responsive...
5
u/Khmerrr Jun 16 '26
What is the problem you're trying to solve?
If you're having user complaints, then the right tool is query store: confgure it, let it run, gather data. You'll end with a formidable source of truth to query. It'll help you determine what is "slow", hungry for ram, ecc... Maybe you'll end up with a slow component that is not even on the sqlserver side.
1
u/alexwh68 Jun 16 '26
I have had a few of these in the past, try to understand what is making the CPU busy, it could be the operating system paging excessively, another thing to look at is long running queries, missing indexes can create large table scans rather than seeks, making simple queries hammer resources.
Low memory will increase paging, increase disk I/O as stuff is paged in/out to disk, this will push up CPU usage.
I would look to hard limit the ram available to the sql server process.
1
u/dbrownems Microsoft Employee Jun 16 '26
>So based on this... does the server need more RAM?
No. PLE is high, and no significant IO waits.
3
u/Dry_Author8849 Jun 16 '26
You can read for yourself in the official documentation
The recommendation is to set max memory to 75% of the server ram on windows server.
You may want to pay attention to tempdb configuration as well.
You may also want to look at enabling the query store and allocate memory to it.
SQL Server uses memory to cache query plans and data. It will consume memory until the max limit is reached. What you want to look up is the size of the databases that are running. You can use a rough estimate to get a server with physical ram that covers at least a minimum 30% the space allocated to databases, until you reach a reasonable hardware availability limit. It's a very rough number as it depends on the amount of users and other factors.
Also, you will be limited by the edition of sql server. The enterprise edition has no limits but is licensed by core. There is a ratio between cores and physical memory you may want to explore.
Cheers!
3
u/JounDB Jun 16 '26
75-80% for SQL, 20% for OS and other small processes
2
u/No_Resolution_9252 Jun 16 '26
Ignore page life expectancy, its a useless metric. You can have high PLE and severe memory pressure (albeit under unusual circumstances) and you can have low PLE and no memory pressure. That you don't have much of any pageiolatch_sh wait indicates you probably do not have a memory problem.
Your CXP wait of 0 concerns me. Is your server set to a maxdop of 1?
You appear to have severe blocking. (lck_m_ix) but minimal lck_m_s waits. Are you regularly rebuilding your indexes? Does your app also make heavy use of expanding updates to variable width or nullable columns? This can also be a sign of severe overindexing or some amount of underindexing.
async_io_completion is probably from backups.
If your CPU spikes are up to 60%, you are fine. If you average 60% over longer durations, you may have problems when something big comes in at the same time and it spikes it up further. You can tune a SQL Server to run an OLTP workload at 95% CPU reliably, but this is a hyper-extreme level of tuning an optimization to get it there that few dbas have the skill to do and few organizations have the discipline to leave workloads off of the oltp server that shouldn't be on it.
Biggest redflag is the low parallelism wait. Even a small amount of parallelism (say maxdop = 2) can provide massive improvements in performance. From the unusual amount of RAM, is this a VM running on a virtual infrastructure on-prem? Is the virtual host oversubscribed? Oversubscription makes parallelism a problem much sooner than if it has access to the CPU resources it needs and may have been a reason to reduce it to 1 in the past.
1
u/Empty-Ad4867 Jun 16 '26
Check for missing or overlaped indexes. Check for fragmentation and create a maintenance plan for rebuild/reorg inex. Check if top queries are well written. Check if you have locks. ....
1
u/BrightonDBA Jun 16 '26
“All of it plus another 200%”
1
u/jwk6 Jun 16 '26
A good rule of thumb is to look at the "worst" queries your appliction or users may run, and examine the memory utilization of those queries and especially the indexes required to execute the query.
So say your 350 GB database has a very large table that contains a 50 GB index that is used often. That means SQL Server may be running out of buffer pool space when the pages of that index are loaded into memory. Page life expectancy is an okay indicator, but can be misleading. At the same time you should also look at cache hit ratio and wait stats.
Someone else mentioned monitoring wait states. A good one to look for is RESOURCE_SEMAPHORE. This occurs when SQL Server is trying to allocate RAM to the query but cannot.
Also, make sure you are not using any Linked Servers for real-time / live server to server queries. These are notorious for consuming large amounts of memory and causing issues including RESOURCE_SEMAPHORE. Using Linked Servers for nightly batch jobs and ETL is okay.
1
u/vabello Jun 16 '26
Anywhere from 1GB to 24TB depending on your hardware and SQL licensing. You gave no details about your database or application.
Generally speaking though, you want to manually control the amount of RAM allocated to SQL as it will cause contention with the OS.
1
u/IglooDweller Jun 16 '26
If you don’t want your memory to be used. Take it out and put it in a drawer.
Memory on a database server is used for caching, scratch space for heavy queries, etc.
1
u/DavidKleeGeek Microsoft MVP Jun 16 '26
Just like a lot of folks mentioned here, this is a good and not straightforward question. Memory in SQL Server is effectively a storage read cache for data that has already been read to minimize repetitive reads back to disk, as well as a transient request 'bucket'.
99% of RAM used is pretty much by design, but just make sure you've got at worse a few gigs of RAM for the OS to have some more headroom. 3GB as you note for available RAM, as long as it doesn't drop below say a gig and a half or so, is just fine.
See if you can get a baseline of a lot of the following metrics taken during normal business hours. Sample PLE, memory grants pending, buffer cache hit ratios, and lazy writes per second. Look for resource_semaphore waits. PageIOLatch wait stats can show just how much demand for reads there is. Make sure to try to filter by business hours, as things like PLE can crash with routine backups, index maintenance, integrity checks, etc., and all of that is quite normal.
Take a look at the Glenn Berry diagnostics scripts (https://glennsqlperformance.com) for a lot of these queries in one place.
From a Windows OS perspective, track IOPs and throughput by logical disk. Since RAM is a storage read cache for SQL Server, if you are really squeezed on RAM, you'll most likely see your storage read demand elevate on one or more of your SQL Server object disks. The higher the read rate, the more likely you'll be squeezed on RAM. (Or, your server is suffering from inefficient code, but that's a different story altogether.)
1
u/Commercial-Trash-606 Jun 21 '26
That's like "How much food does my teenage kid need?"
SQL Serer is designed to take as much RAM as possible in the given machine. You can limit this behavior by telling it how much it can consume. Go to SSMS, right click on the instance (not the DB), and see properties. Under Memory tab, you can specify how much RAM it should take, max.
0
u/Simple_Brilliant_491 Jun 16 '26 edited Jun 16 '26
Take a look at https://aisqltuner.com/fast-sql-server-health-check/. It will identify the waits the server is facing along with your configuration settings and identify whether you have issues due to memory pressure.
Generally setting max memory to 75% of RAM, as was suggested, for a dedicated server makes sense. Also consider number of cores. 4 to 8 GB per core is usually reasonable.
Disclosure: I am the founder and CEO of AI SQL Tuner LLC, maker of AI SQL Tuner Studio.
0
u/DHGru Jun 16 '26
what is the PLE. Some of the old recommendaitions are for when sysstems had like 16GB of memory. Paging out 78GB vs 16GB every 5 minutes is a big difference.
0
u/CPDRAGMEISH Jun 16 '26
IT'SG OK
Much, very muchd:-)
-
Answer: It depends