SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Index !!!!


Index !!!!

Author
Message
OnlyOneRJ
OnlyOneRJ
Right there with Babe
Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)

Group: General Forum Members
Points: 732 Visits: 692
Now Daily at morning 6:00 am the server (Database) does not have any transactions.. i mean its on IDLE state as there are no one to work with it.. and the people comes at 9:00am for work ..

So before the team vcomes to work with it, My plan is to

1) First Rebuild/Reorganise Index.. Query - alter index all on tablename rebuild
2) Execute a Stored procedure
USE [DBNAME]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROC [dbo].[pr_truncateLog]
AS BEGIN
DECLARE @DBName sysname,
@logName sysname
-- Obtener nombre de base de datos
SET @DBName = DB_NAME()

BACKUP LOG @DBName WITH NO_LOG
-- Obtener lista de archivos LOG
DECLARE logCursor CURSOR FOR
SELECT name
FROM sysfiles
WHERE groupid = 0
-- Para cada archivo LOG, ejecutar DBCC SHRINKFILE
OPEN logCursor
FETCH NEXT FROM logCursor
INTO @logName
WHILE @@FETCH_STATUS = 0 BEGIN
SELECT @logName = RTRIM(@logName)
DBCC SHRINKFILE (@logName)

FETCH NEXT FROM logCursor
INTO @logName
END
CLOSE logCursor
DEALLOCATE logCursor
END
3) Run EXEC sp_updatestats
4) Server Restart


Now is this correct or can anyone help me in step by step execution??????

************************************
Every Dog has a Tail !!!!! :-D
GilaMonster
GilaMonster
SSC Guru
SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)

Group: General Forum Members
Points: 216871 Visits: 46278
Ow, ow, ow, ow...

First you want to rebuild the indexes, then you want to break the log chain (no more point in time recovery), shrink the log file, ensuring that there will be slow downs and log fragmentation from the growths and restart the server ensuring that it'll be slow when the users start using it.

Well, to be honest I could think of worse things to do, but it might take work. ;-)

For the log, please read through this - Managing Transaction Logs
Why not to shrink a DB, see - http://sqlinthewild.co.za/index.php/2007/09/08/shrinking-databases/, much the same goes for the log

Why restart daily? Some servers I work with haven't been restarted in months and there's seldom a need to restart SQL regularly, doing so means more work for the DB engine to repopulate all its caches.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


OnlyOneRJ
OnlyOneRJ
Right there with Babe
Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)

Group: General Forum Members
Points: 732 Visits: 692
Gila :-(

Can you write the steps here with example or query??? i am not able to understand it ckear as i am new in DB activites;-)

************************************
Every Dog has a Tail !!!!! :-D
GilaMonster
GilaMonster
SSC Guru
SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)

Group: General Forum Members
Points: 216871 Visits: 46278
No I can't, because what you're suggesting is incredibly harmful.

Read the article and blog post that I referenced. Especially read the article.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


Chandra Sekhara Vyas Dhara
Chandra Sekhara Vyas Dhara
SSCertifiable
SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)SSCertifiable (5K reputation)

Group: General Forum Members
Points: 5021 Visits: 1149
Why do u want to perform all the stuff at a shot??? How big your databases?

Plan accrodingly to the size of the databases.



OnlyOneRJ
OnlyOneRJ
Right there with Babe
Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)

Group: General Forum Members
Points: 732 Visits: 692
I want to perform this just as a Good Prectise..

There are 20 Databases almost 10 GB each.. thats it Wink

************************************
Every Dog has a Tail !!!!! :-D
anthony.green
anthony.green
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23538 Visits: 6519
Good practise, 2 of the points are BAD practise

Rebuild/Reorg indexes - Do this yes

Shrinking the files - Bad idea

sp_updatestats - This is partily done in the Rebuild/Reorg

Restarting the server - Bad idea, as Gail already mentions you flush all the cache data out and SQL will perform badly until the cache's have been rebuilt.



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


GilaMonster
GilaMonster
SSC Guru
SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)SSC Guru (216K reputation)

Group: General Forum Members
Points: 216871 Visits: 46278
runal_jagtap (9/25/2012)
I want to perform this just as a Good Prectise..


But it's not good practice. Other than the index rebuild and maybe the stats update, the rest of the steps can be downright harmful and should not be done, much less on a regular basis.

Please, please, please, go and read the article I linked.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


OnlyOneRJ
OnlyOneRJ
Right there with Babe
Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)Right there with Babe (732 reputation)

Group: General Forum Members
Points: 732 Visits: 692
That Means the points mentioned 1, 2 & 3 should be done only???

************************************
Every Dog has a Tail !!!!! :-D
anthony.green
anthony.green
SSC-Insane
SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)SSC-Insane (23K reputation)

Group: General Forum Members
Points: 23538 Visits: 6519
No, only points 1 and 3

Index and statistic maintenance should be done



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search