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 12»»

Index !!!! Expand / Collapse
Author
Message
Posted Tuesday, September 25, 2012 4:03 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, March 12, 2014 12:13 AM
Points: 258, Visits: 690
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 !!!!!
Post #1363904
Posted Tuesday, September 25, 2012 4:15 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:10 AM
Points: 40,403, Visits: 36,843
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 2008, MVP
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

Post #1363910
Posted Tuesday, September 25, 2012 4:26 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, March 12, 2014 12:13 AM
Points: 258, Visits: 690
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 !!!!!
Post #1363919
Posted Tuesday, September 25, 2012 4:34 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:10 AM
Points: 40,403, Visits: 36,843
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 2008, MVP
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

Post #1363922
Posted Tuesday, September 25, 2012 4:40 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 3:22 AM
Points: 3,906, Visits: 1,098
Why do u want to perform all the stuff at a shot??? How big your databases?

Plan accrodingly to the size of the databases.




Post #1363929
Posted Tuesday, September 25, 2012 4:42 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, March 12, 2014 12:13 AM
Points: 258, Visits: 690
I want to perform this just as a Good Prectise..

There are 20 Databases almost 10 GB each.. thats it ;)








************************************
Every Dog has a Tail !!!!!
Post #1363930
Posted Tuesday, September 25, 2012 4:55 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Saturday, November 1, 2014 6:54 AM
Points: 5,221, Visits: 5,118
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
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

Post #1363941
Posted Tuesday, September 25, 2012 5:02 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:10 AM
Points: 40,403, Visits: 36,843
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 2008, MVP
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

Post #1363944
Posted Tuesday, September 25, 2012 5:03 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, March 12, 2014 12:13 AM
Points: 258, Visits: 690
That Means the points mentioned 1, 2 & 3 should be done only???







************************************
Every Dog has a Tail !!!!!
Post #1363945
Posted Tuesday, September 25, 2012 5:04 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Saturday, November 1, 2014 6:54 AM
Points: 5,221, Visits: 5,118
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
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

Post #1363946
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse