简体   繁体   中英

SQL Server 2008 R2, don't use up all resources for a specific task

We have a server that hosts an application running on SQL Server 2008 R2. Throughout the week we have a stored procedure that is called around 400,000 times per day by 25 users. It runs very efficiently and memory usage remains low.

On Saturday when nobody is on the system a large update (several million inserts and updates) runs and after its completion all the memory on the server gets consumed. The server only hosts this application and I do not have any problems with SQL Server taking up all the RAM it can get, however part of me thinks its wasteful that all the memory gets consumed by this one job. I was wondering if there was a way to tell SQL Server to not consume so much memory when a specific job runs. Since this job runs on weekend when nobody is on the system it is not so time critical.

In the meantime I was simply planning on restarting SQL service. I was wondering if there is a better way of handling this?

Thanks

The memory is getting used because SQL caches the data pages as it reads them from disk, which is a good thing. The next time that data page needs to be accessed, it will be read from memory which is much faster than reding from the disk.

SQL will flush out the cached pages as they expire, or if other pages are loaded.

I would not worry at all about this, especially if SQL Server is the only big process running on that server.

If you really want to flush the cash yourself, you can issue the following statement

DBCC DropCleanBuffers

I was wondering if there was a way to tell SQL Server to not consume so much memory when a specific job runs. Since this job runs on weekend when nobody is on the system it is not so time critical.

Hahaha. Waht do you care? Sql server will erpurpose it's caches the moment other stuff starts requesting other data, you know.

I do not have any problems with SQL Server taking up all the RAM it can get

It is VERY good that you agree that the behavior you confgiured (!) (or allowed by default configuration) is acceptable.

Standard setup: SQL server sues us much memory as possible as LRU (Last recently used) page cache. A request answered from memory is faster than one that hits the disc.

A hugh update without other activity naturally will kill other items off the memroy - how should SQL Server magically decide to not use the resources? WHY should it?

Next day the new data requested will anyway go back into the cache pretty much immediately.

In the meantime I was simply planning on restarting SQL service.

So, when you dont like the funniture in your house you burn it down?

YOu could restart Windows totally - then you also clear off the OS level caches.

You dont really get any result out of it. Basiaclly what you did is a worse cure than wrong data in the cacehs. Not used data gets flushed anyway, so you restart the server as a way to tell SQQL Server it can forget old data, which it will do anyway, just because you dont like the memory to be used after allowing it to?

;) Sounds like a read in the documentation is in order.

Seriously. there is no problem, you totally make this up. SQL Server behaves sensible by any lopgical general standard and you dont really do ANYTHING except take the server down and do some number faking by rstarting it. Read up how SQL Server uses the memory. It is not like a page stored in emmory stays there forever.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM