MSSQLTips.com - your daily source for SQL Server tips

Google
 
Web mssqltips.com

ESSENTIALS: Home | Tips | Search | Categories | Top 10 | Products | Authors | Blogs | Forums | Webcasts | Advertise | About
200GB database -

in Search

200GB database

Last post 06-22-2008 7:25 PM by timmer26. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-05-2008 11:22 AM

    200GB database

    I’ve recently taken on a SQL Server related assignment with a client running a very large database in a very poor environment.

    We have a 200GB database with virtually no failover support.  I’m interested in transactional replication, hardware redundancy, failover support and find that before moving forward on that we probably need to seriously re-evaluate our whole logical and physical design.  My experience is more on the TSQL side rather than full dba hardware, optimization, tuning areas.  Any suggestions for quickly ramping up my skills on the dba side (books, courses, etc.) and also recommendations for short term support resources would be appreciated.  I’m want to make sure I cover all my bases with regard to future scalability, disaster recovery, high availability etc.

     
  • 06-05-2008 1:27 PM In reply to

    Re: 200GB database

    Check out your other post on the same topic at:

     http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=104281&SearchTerms=200GB

  • 06-05-2008 1:45 PM In reply to

    Re: 200GB database

    You can see bigger tables and look index fragmentation, I did this with one 300 gb database and down to 200 gb after that, look the follow procedures:

     

    /*
    EXEC dbo.spVerFragmentacionPorTabla 'Acum'
    */
    IF EXISTS (SELECT * FROM sysobjects WHERE ID = OBJECT_ID('dbo.spVerFragmentacionPorTabla') AND type = 'P')
     DROP PROCEDURE dbo.spVerFragmentacionPorTabla
    GO
    CREATE PROCEDURE dbo.spVerFragmentacionPorTabla
     @Tabla   varchar(50)
    AS
     BEGIN
      SELECT a.index_id, nam5e, avg_fragmentation_in_percent
      FROM sys.dm_db_index_physical_stats (DB_ID(), OBJECT_ID(@Tabla),
        NULL, NULL, NULL) AS a
       JOIN sys.indexes AS b ON a.object_id = b.object_id AND a.index_id = b.index_id;
     END
    GO
    /*
    EXEC dbo.spIndicesFragmentacion 'MovFlujo',1   -- 1 = On line       0 = exclusive
    */
    IF EXISTS (SELECT * FROM sysobjects WHERE ID = OBJECT_ID('dbo.spIndicesFragmentacion') AND type = 'P')
     DROP PROCEDURE dbo.spIndicesFragmentacion
    GO
    CREATE PROCEDURE dbo.spIndicesFragmentacion
     @Tabla  varchar(255),
     @EnLinea bit = 1
    AS BEGIN
        DECLARE @SQL  varchar(max),
       @Indice  varchar(255),
       @Operacion varchar(255),
       @Porcentaje float,
       @Fragmentos int,
       @ActualID bigint

        DECLARE curInd CURSOR LOCAL FORWARD_ONLY READ_ONLY FOR
       SELECT name,  avg_fragmentation_in_percent, fragment_count
       FROM sys.dm_db_index_physical_stats (DB_ID(), OBJECT_ID(@Tabla), NULL, NULL, NULL) AS a
       JOIN sys.indexes AS b ON a.object_id = b.object_id
           AND a.index_id = b.index_id
      WHERE avg_fragmentation_in_percent > 5.0
      OPEN curInd
      FETCH NEXT FROM curInd INTO @Indice, @Porcentaje, @Fragmentos
      WHILE @@FETCH_STATUS = 0
      BEGIN
       SELECT @SQL = 'ALTER INDEX ' + @Indice + ' ON ' + @Tabla
       IF @Porcentaje BETWEEN 5.0 AND 30.0
        SELECT @Operacion = 'REORGANIZE'
       ELSE
        SELECT @Operacion = 'REBUILD'
       SELECT @SQL = @SQL + CHAR(32) + @Operacion
       IF @EnLinea = 1 And @Operacion = 'REBUILD'  SELECT @SQL = @SQL + CHAR(32) + 'WITH (ONLINE = ON) '
       INSERT LogIndicesFragmentacion (Empieza, Tabla, Indice, FragmentosI, Operacion)
       VALUES (GETDATE(), @Tabla, @Indice, @Fragmentos, @Operacion)
       SELECT @ActualID = @@IDENTITY
       BEGIN TRY
          EXEC (@SQL)
       END TRY
       BEGIN CATCH
        SELECT  @Operacion = @Operacion  + CHAR(32) + ERROR_MESSAGE()
       END CATCH
       UPDATE LogIndicesFragmentacion
          SET Termina = GETDATE(),
         FragmentosT = fragment_count
         FROM sys.dm_db_index_physical_stats (DB_ID(), OBJECT_ID(@Tabla), NULL, NULL, NULL) AS a
         JOIN sys.indexes AS b ON a.object_id = b.object_id
          AND a.index_id = b.index_id
         WHERE name = @Indice
           AND Indice = @Indice
       FETCH NEXT FROM curInd INTO @Indice, @Porcentaje, @Fragmentos
      END
      CLOSE curInd
      DEALLOCATE curInd
    END
    GO
    /*
    SELECT * FROM LogIndicesFragmentacion
    */
    IF NOT EXISTS (SELECT * FROM sysObjects WHERE id = OBJECT_ID('dbo.LogIndicesFragmentacion') AND type = 'U')
      CREATE TABLE LogIndicesFragmentacion
     (
      ID bigint identity primary key clustered not null,
            Empieza datetime null default getdate(),
      Termina  datetime null,
            Tabla varchar(255),
      Indice varchar(255),
      FragmentosI int null,
      FragmentosT int null,
      Operacion varchar(255) null,
     )
    GO

  • 06-05-2008 2:53 PM In reply to

    Re: 200GB database

    To learn...

    Books online and MSDN...is the best place...

    Few sites/fourms like these...

    You can check book TROUBLE SHOOTING SQL Server 2005 and INSIDE SQL SERVER 2005

     

    MohammedU
    SQL Server MVP
  • 06-22-2008 7:25 PM In reply to

    • timmer26
    • Top 10 Contributor
    • Joined on 12-14-2007
    • Kalamazoo, MI, USA
    • Posts 21

    Re: 200GB database

    I always recommend the WROX book series and of course the Guru's Guides series for SQL...

    Tim Ford, MCSD
Page 1 of 1 (5 items)