myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


T-SQL Best Practice

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Server Products] >> SQL Server >> T-SQL Best Practice Page: [1]
Login
Message << Older Topic   Newer Topic >>
T-SQL Best Practice - 8/22/2008 7:39:55 AM   
jreeves399

 

Posts: 1
Score: 0
Joined: 8/22/2008
Status: offline
Hi

I manage a number of SMS/SCCM environments and am also responsible for the SQL server implementations.  I have a problem in that our asset management team are trying to implement a huge query that I suspect is going to cause significant performance problems and the tempdb to grow.  SMS/SCCM inventory stores all the hardware and software information within the SQL database.  The asset management team want to run a query that returns all Add/Remove programs entries for every workstation within the environment.  Some of our SMS environments have up to 30,000 workstations, and this will result in a huge output, millions of rows.  I am concerned that this query will cause performance problems as the database is already very busy and I'm concerned the tempdb may consume all remaining disk space which is already an issue for us.  I have suggested that they replicate the database or take a copy of it to run the query from there.  Am I correct to be concerned about this?  I'm not an experienced SQL engineer/programmer and would welcome any advice.  My main concern are the customer environments that I manage, and I dont want the services we provide to become jeapordized by a huge query like this consuming all the disk space.  any help or advice greatly appreciated.  The query they want to use is this:

'SELECT DISTINCT
   v_GS_ADD_REMOVE_PROGRAMS."DisplayName0", v_GS_ADD_REMOVE_PROGRAMS."Publisher0", v_GS_ADD_REMOVE_PROGRAMS."Version0",
   Computer_System_DATA."Name0", Computer_System_DATA."UserName0",
   v_GS_LastSoftwareScan."LastScanDate",
   v_GS_PC_BIOS."SerialNumber0",
   v_R_System."AD_Site_Name0", v_R_System."User_Name0"
FROM
   { oj ((("v_GS_ADD_REMOVE_PROGRAMS" v_GS_ADD_REMOVE_PROGRAMS INNER JOIN "Computer_System_DATA" Computer_System_DATA ON
       v_GS_ADD_REMOVE_PROGRAMS."ResourceID" = Computer_System_DATA."MachineID")
    INNER JOIN "v_GS_PC_BIOS" v_GS_PC_BIOS ON
       Computer_System_DATA."MachineID" = v_GS_PC_BIOS."ResourceID")
    INNER JOIN "v_R_System" v_R_System ON
       Computer_System_DATA."Name0" = v_R_System."Name0")
    INNER JOIN "v_GS_LastSoftwareScan" v_GS_LastSoftwareScan ON
       Computer_System_DATA."MachineID" = v_GS_LastSoftwareScan."ResourceID"}
ORDER BY
   v_GS_ADD_REMOVE_PROGRAMS."DisplayName0" ASC,
   Computer_System_DATA."Name0" ASC,
   v_GS_LastSoftwareScan."LastScanDate" DESC' : 21/08/2008 14:31

cheers
Post #: 1
RE: T-SQL Best Practice - 8/22/2008 9:43:17 AM   
gjones


Posts: 844
Score: 50
Joined: 6/5/2001
From: Ottawa, Ontario, Canada
Status: offline
Well, I have cleaned up your query to follow best practices.
http://smsug.ca/blogs/garth_jones/archive/2008/08/22/forum-reply-t-sql-best-practice.aspx

Yes the query could cause problems but... Keep in mind that replicating the db is not supported but should work.

_____________________________

Garth@enhansoft.com

For a List of my Articles
http://www.myitforum.com/contrib/default.asp?cid=116
Blogs:
http://smsug.ca/blogs/garth_jones/default.aspx
http://myitforum.com/cs2/blogs/gjones/default.aspx


(in reply to jreeves399)
Post #: 2
Page:   [1]
All Forums >> [Server Products] >> SQL Server >> T-SQL Best Practice Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.453