I'm using SQL Server 2008 enterprise on my online server, the main database has tables that expe开发者_Go百科ct more than 2 million records per month, as these tables grow SQL Server takes a lot from the 4GB memory installed and then closing the server RAM.
I've restricted the SQL Server RAM to 2GB but, when it uses these ram it stop working well destroy connections and performs too slowly.
Is it normal? And what can I do to get back the RAM from SQL Server after querying these large tables?
On a dedicated Windows server running SQL Server you will go down to 5-15 MB free RAM by some counters. It's normal. There is no memory leak.
If you have 4GB RAM fitted, I'd consider using /3GB switch on 32 bit and letting SQL Server work out RAM for itself. For 64 bit, add more RAM and again let SQL Server work out RAM for itself.
Starving SQL Server of RAM will result is disk thrashing as data is churned through memory.
If your SQL Server isn't on a dedicated box, then move it onto one.
Assorted links to other SO questions: One, Two, Three
See here: The SQL Server Memory Leak Confusion
Basically SQL Server will use as much memory as it can possible grab, it is much more expensive to read from disk than from RAM. To release the RAM you can restart but then again all your queries will be slow because it will hit the disk
You need to let Sql Server handle the memory. It will try and use anything you give it, because what it loads into memory is directly related to how fast it performs. Don't worry about restricting it. It will give memory back to other processes on the system when they need it, and reclaim it when those processes are done.
You probably want SQL server to use a lot of RAM. It's designed to use as much memory as you'll allow to cache results and tables in memory so that the access is much faster in the future (as you mention).
If your memory for SQL server runs low, it will automatically "age" queries and caches, so that the oldest ones will be removed.
Read here for some more information.
精彩评论