Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

Identifying Unused Objects in a Database Expand / Collapse
Author
Message
Posted Tuesday, August 29, 2006 10:41 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 7:33 AM
Points: 138, Visits: 280
Comments posted to this topic are about the content posted at temp


Post #304718
Posted Monday, September 11, 2006 5:42 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Sunday, September 18, 2011 6:11 PM
Points: 355, Visits: 299

I used

select name, id from sysobjects where name = 'get_emp_list_FY06'

to get my objid. then I run this
select bucketid, cacheobjtype, objtype, objid, dbid     
 from master.dbo.SYSCACHEOBJECTS
 where  objid = 1718297181

it return

bucketid    cacheobjtype      objtype  objid       dbid  
----------- ----------------- -------- ----------- ------

(0 row(s) affected)

 

Why ? Thanks.

 

Post #307568
Posted Monday, September 11, 2006 7:07 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Wednesday, January 2, 2013 12:15 PM
Points: 1,443, Visits: 711
This one scares me a little bit; if you have some procs that are run once a quarter or once a month would they show up in the cache?
Post #307592
Posted Monday, September 11, 2006 7:27 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 4:54 AM
Points: 1,516, Visits: 2,722

I wouldn't trust this post either. Now that the ASP and .net junkies can reach in and do stuff via the CLR, it's anybody's guess. And it is still so vexing that MS did not see fit to add attributes like "last modified" and "last accessed" in SS 2005 - Windows has had that capability for a long time.

AFAIK the only sure way to track when an sp is invoked would be to add tracking code e.g. write to a table when it is executed.

Post #307604
Posted Monday, September 11, 2006 7:27 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Saturday, August 31, 2013 11:41 PM
Points: 121, Visits: 34
Exactly what I was looking for
Post #307605
Posted Monday, September 11, 2006 9:54 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Sunday, November 9, 2014 12:08 PM
Points: 1,618, Visits: 1,553
Because it isn't cached.



My blog: SQL Soldier
Twitter: @SQLSoldier
My book: Pro SQL Server 2008 Mirroring
Microsoft Certified Master: SQL Server 2008
Principal DBA: Outerwall, Inc.
Also available for consulting: SQL DBA Master
Post #307685
Posted Monday, September 11, 2006 10:07 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Today @ 9:21 AM
Points: 3, Visits: 459
"select name, id from sysobjects where name = 'get_emp_list_FY06'"

calls the sysobjects table, so your query puts in cache the SYSOBJECTS table not your sp/fn.
Post #307690
Posted Monday, September 11, 2006 10:31 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Yesterday @ 4:54 AM
Points: 1,516, Visits: 2,722

One of my pet peeves is when somebody will read a question and either they don't understand it, or they don't know the answer -- does that stop them? Nope - they just reply to a different question that they do know the answer to. Human nature, I guess. End of rant.

If you re-read Leo's original article, he said:

"In my company the task becomes a little bit easier by knowing the fact that any database can be accessed only via call to a stored procedure. E.g. I have to split the task to the 2 sequential subtasks: ..."

Lucky Leo. In his case, he could very easily add some kind of logging feature that records when an sp is run, and then (over the course of time) use a process of elimination to find the sp's that never get called.

Considering that SQL Server is notorious for omitting relevant object info such as "last modified" and "last accessed" dates (which Windows itself has had for ages) we're just a little bit stuck. Even perusing the SQL-DMO library does not reveal anything that I can find relating to the topic at hand. It really gets tiring when you have to drop-and-create procedures to track when changes happen.

The issue becomes even more complex when you consider that an external application can be allowed to touch objects directly, so even the internal SQL tracking mechanisms such as dependencies don't help a bit. I can think of one customer's web app that uses SQL Server, however there is also an Access database that connects in there, along with Excel gurus who use the Data tools to run their own specialized analyses. And let's not forget an e-commerce link to both their physical and online stores.

Post #307702
Posted Monday, September 11, 2006 6:27 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 7:33 AM
Points: 138, Visits: 280

You forgot actually run the function or proc first before test it in cache memory

select name, id from sysobjects where name = 'get_emp_list_FY06'

exec get_emp_list_FY06

Then:


select bucketid, cacheobjtype, objtype, objid, dbid     
 from master.dbo.SYSCACHEOBJECTS
 where  objid = 1718297181

 




Post #307798
Posted Monday, September 11, 2006 6:30 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 7:33 AM
Points: 138, Visits: 280
Yes if you get cache in a short period time after they run. I was running tests every 2-3-5 minutes for 2 month. As I said you will have just the report of objects that MOST likely not used. Then additional analysis may required.


Post #307799
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse