dbTalk Databases Forums  

database optimization

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss database optimization in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
David Greenberg
 
Posts: n/a

Default database optimization - 12-31-2007 , 08:36 AM






Hi
We use Sql 2000.
When defining a database maintenance plan one of the options is to
optimize the database, reorganize data and index pages, remove unused
pages etc.
Is there a command to do this manualy (or in a job) and not by usung a
DBM plan ?

Reply With Quote
  #2  
Old   
David Portas
 
Posts: n/a

Default Re: database optimization - 12-31-2007 , 01:47 PM






"David Greenberg" <davidgr (AT) iba (DOT) org.il> wrote

Quote:
Hi
We use Sql 2000.
When defining a database maintenance plan one of the options is to
optimize the database, reorganize data and index pages, remove unused
pages etc.
Is there a command to do this manualy (or in a job) and not by usung a DBM
plan ?
Yes. ALL of the features of Maintenance Plans are T-SQL commands.

http://msdn2.microsoft.com/en-us/lib...8(SQL.80).aspx

--
David Portas




Reply With Quote
  #3  
Old   
David Greenberg
 
Posts: n/a

Default Re: database optimization - 01-01-2008 , 03:00 AM



David Portas wrote:
Quote:
"David Greenberg" <davidgr (AT) iba (DOT) org.il> wrote in message
news:flaupm$35v$1 (AT) news2 (DOT) netvision.net.il...

Hi
We use Sql 2000.
When defining a database maintenance plan one of the options is to
optimize the database, reorganize data and index pages, remove unused
pages etc.
Is there a command to do this manualy (or in a job) and not by usung a DBM
plan ?


Yes. ALL of the features of Maintenance Plans are T-SQL commands.

http://msdn2.microsoft.com/en-us/lib...8(SQL.80).aspx

Thanks for the link. Problem is that the "dbcc reindex" works on a
single table , meaning that I have to write a command per table and have
to remember to add a new line for new tables when I add them.
Isn't there a single command that will take care of the whole database
in one go ?


Reply With Quote
  #4  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: database optimization - 01-01-2008 , 04:02 AM



David Greenberg (davidgr (AT) iba (DOT) org.il) writes:
Quote:
Thanks for the link. Problem is that the "dbcc reindex" works on a
single table , meaning that I have to write a command per table and have
to remember to add a new line for new tables when I add them.
Isn't there a single command that will take care of the whole database
in one go ?
You can easily write a script that iterates over sysobjects to do this.
In this case you can also run DBCC SHOWCONTIG WITH TABLE_RESULTS and
check for fragmentation, so that you only defragment tables that have a
certain fragmentation level.

If you don't like writing code, you can also do:

sp_MSforeachdb 'DBCC DBREINDEX(?)'

The stored procedure sp_MSforeachdb is undocumented and use of it is not
supported. Then again, it's commonly used.


--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx


Reply With Quote
  #5  
Old   
Knowledgy
 
Posts: n/a

Default Re: database optimization - 01-09-2008 , 02:01 PM



You can use the undocumented system stored proc called



Sp_msforeachtable



The parameter is the command you want to run and the proc will execute it
against every table within the database


--
Sincerely,
John K
Knowledgy Consulting, LLC
www.knowledgy.org

Atlanta's Business Intelligence and Knowledge Management Experts


"David Greenberg" <davidgr (AT) iba (DOT) org.il> wrote

Quote:
Hi
We use Sql 2000.
When defining a database maintenance plan one of the options is to
optimize the database, reorganize data and index pages, remove unused
pages etc.
Is there a command to do this manualy (or in a job) and not by usung a DBM
plan ?



Reply With Quote
  #6  
Old   
Jack Vamvas
 
Posts: n/a

Default Re: database optimization - 01-11-2008 , 10:31 AM



Check SQL Books Online and search DBCC SHOWCONTIG - there is a script in
there which is useful and deals
with all the tables

--

Jack Vamvas
___________________________________
Search IT jobs from multiple sources- http://www.ITjobfeed.com




"David Greenberg" <davidgr (AT) iba (DOT) org.il> wrote

Quote:
Hi
We use Sql 2000.
When defining a database maintenance plan one of the options is to
optimize the database, reorganize data and index pages, remove unused
pages etc.
Is there a command to do this manualy (or in a job) and not by usung a DBM
plan ?



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.