dbTalk Databases Forums  

memory usage

microsoft.public.sqlserver.clustering microsoft.public.sqlserver.clustering


Discuss memory usage in the microsoft.public.sqlserver.clustering forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Calvin Do
 
Posts: n/a

Default memory usage - 02-28-2005 , 06:41 PM






Hello,


I have a sql 2000 box that has roughly 15 datbases. How do i determine how
much memory/cpu a particular db is using?


thanks!
Calvin



Reply With Quote
  #2  
Old   
Mike Hodgson
 
Posts: n/a

Default Re: memory usage - 02-28-2005 , 09:27 PM






DBs don't use CPU, client connections do. You can correlate CPU use for
current connections by doing a little extrapolation from the
master.dbo.sysprocesses table. That table lists all current connections
and each row specifies which DB is currently being used (dbid) by the
connection and how much CPU time that connection has consumed. (Take
this with a grain of salt though because a SPID can change DB simply by
running a USE statement, so there's no guarantee the SPID has been using
the same DB its whole life.) This is a cumulative value so if a client
has been connected to the server by the same SPID for a long time, the
cumulative CPU will be high compared to a relatively new SPID. Just
bear that in mind when extrapolating - you might do well to divide the
CPU figure by the number of hours, "datediff(hh, login_time,
getdate())", (or minutes or days or...) the SPID has been alive for to
get an hourly average CPU - slightly more helpful.

As for memory, it's very hard to tell what percentage of memory is
attributable to each DB. SQL Server simply caches data pages
(regardless of which DB they belong to) when they're accessed. The
execution plans stored in the procedure cache can involve objects in
many databases so you can't really attribute them to any particular DB.
You can see a little bit of information about the buffer cache by running:

DBCC MEMUSAGE

This will show you a little info about the top 20 objects in terms of
cache use. It lists the dbid (what you're interested in), the objectid
& indexid from that DB (this will be the id of the associated
table/index) and the number of buffers (8K pages?) being used by that
object in the buffer cache. NB/ Microsoft recommend not using DBCC
MEMUSAGE and using the related perfmon counters instead (see
http://msdn.microsoft.com/library/de...kcomp_992x.asp)
but I find DBCC MEMUSAGE still slightly helpful, although I suppose you
could get the perfmon data you're after (that replaces DBCC MEMUSAGE)
from querying the master.dbo.sysperfinfo table and correlating that data.

--
*mike hodgson* |/ database administrator/ | mallesons stephen jaques
*T* +61 (2) 9296 3668 |* F* +61 (2) 9296 3885 |* M* +61 (408) 675 907
*E* mailto:mike.hodgson (AT) mallesons (DOT) nospam.com |* W* http://www.mallesons.com



Calvin Do wrote:

Quote:
Hello,


I have a sql 2000 box that has roughly 15 datbases. How do i determine how
much memory/cpu a particular db is using?


thanks!
Calvin






Reply With Quote
  #3  
Old   
Calvin Do
 
Posts: n/a

Default Re: memory usage - 03-01-2005 , 11:50 AM



thank you for the email Mike, i will review...
"Mike Hodgson" <mike.hodgson (AT) mallesons (DOT) nospam.com> wrote

DBs don't use CPU, client connections do. You can correlate CPU use for current connections by doing a little extrapolation from the master.dbo.sysprocesses table. That table lists all current connections and each row specifies which DB is currently being used (dbid) by the connection and how much CPU time that connection has consumed. (Take this with a grain of salt though because a SPID can change DB simply by running a USE statement, so there's no guarantee the SPID has been using the same DB its whole life.) This is a cumulative value so if a client has been connected to the server by the same SPID for a long time, the cumulative CPU will be high compared to a relatively new SPID. Just bear that in mind when extrapolating - you might do well to divide the CPU figure by the number of hours, "datediff(hh, login_time, getdate())", (or minutes or days or...) the SPID has been alive for to get an hourly average CPU - slightly more helpful.

As for memory, it's very hard to tell what percentage of memory is attributable to each DB. SQL Server simply caches data pages (regardless of which DB they belong to) when they're accessed. The execution plans stored in the procedure cache can involve objects in many databases so you can't really attribute them to any particular DB. You can see a little bit of information about the buffer cache by running:

DBCC MEMUSAGE

This will show you a little info about the top 20 objects in terms of cache use. It lists the dbid (what you're interested in), the objectid & indexid from that DB (this will be the id of the associated table/index) and the number of buffers (8K pages?) being used by that object in the buffer cache. NB/ Microsoft recommend not using DBCC MEMUSAGE and using the related perfmon counters instead (see http://msdn.microsoft.com/library/de...kcomp_992x.asp) but I find DBCC MEMUSAGE still slightly helpful, although I suppose you could get the perfmon data you're after (that replaces DBCC MEMUSAGE) from querying the master.dbo.sysperfinfo table and correlating that data.

--
mike hodgson | database administrator | mallesons stephen jaques
T +61 (2) 9296 3668 | F +61 (2) 9296 3885 | M +61 (408) 675 907
E mailto:mike.hodgson (AT) mallesons (DOT) nospam.com | W http://www.mallesons.com



Calvin Do wrote:
Hello,


I have a sql 2000 box that has roughly 15 datbases. How do i determine how
much memory/cpu a particular db is using?


thanks!
Calvin




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.