This Tech Note provides detailed guidelines and options for defragmenting and maintaining your production databases.



Similar documents
Tech Note 743 Configuring Reporting Services 2008 Configuration for a New Host Name in Windows 2008 R2

Tech Note 782 Installing Remote Desktop Services on Windows 2008 Server R2 for Wonderware Products

Tech Note 338 How to Change the ActiveFactory Reporting Website Default Install Location

Tech Note 663 HMI Reports: Creating Alarm Database (WWALMDB) Reports

Tech Note 847 Installing Wonderware Information Server (WIS) on the Windows Server Window 7 64 and 32-bit Operating System

Introduction. Application Versions. Assumptions. Delete $$ExportTempFolders. Tech Note 930 Wonderware System Platform Clean-up Guide

Migrating QI 8.0 Admin and Process Databases from Microsoft Access to Microsoft SQL Server

This tech note will explain how to use the following parameters in Configurator General Parameters.

Enabling Cross-Machine Distributed Transactions (via MSDTC)

Introduction. Symbol Script Timeout Setting. Sample MES Custom Code in Symbol Script. Application Versions. Sample Code

Tech Note 920 Resolving Disabled ActiveFactory Reporting Website for Wonderware System Platform R2

Tech Note 751 Installing InBatch Report Contents for Wonderware Information Server (WIS)

Tech Note 1010 SQL Server Authentication and ArchestrA Network Account Restrictions When Installing Wonderware Historian

Tech Note 551 Configuring SQLMail or Database Mail for the Historian Event

Tech Note 782 Installing Remote Desktop Services on Windows 2008 Server R2 for Wonderware Products

Tech Note 882 Configuring Time Synchronization for Historian Server Using Net Time and Windows Task Scheduler

Introduction. Notes. Important Considerations. Application Versions. Assumptions. 8/22/13 Setting Up Historian Servers for Tier-2 Summary Replication

Tech Note 882 Configuring Time Synchronization for Historian Server Using Net Time and Windows Task Scheduler

How To Migrate Qi Analyst To A New Database On A Microsoft Access (Windows) From A New Version Of Qi.Io To A Newer Version Of A New Qi 8.0 (Windows 7.3

Introduction. Application Versions. Installing Virtual SMTP Server. Tech Note 692 Using Virtual SMTP Server for SCADAlarm Notifications

8/22/13 Configuring Windows SharePoint Services for PEM v1.0 to Work with SuiteVoyager v2.6

Tech Note 1042 Solving Historian Memory Issue with SQL Server MemToLeave Configuration

This Tech Note provides step-by-step procedures to install Microsoft SQL Server 2012 on a 32- or 64-bit Operating System.

Tech Note 868 Troubleshooting Wonderware Software Resource Issues with Performance Monitor

All Tech Notes and KBCD documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more information.

Introduction. Configuration: Entity and OCO Modeling. Application Version: OCO General Configuration

Note: This Tech Note was formerly titled Installing Microsoft SQL Server 2008 for Wonderware Historian v10.0.

Note: Not all messages in the log are indicative of a problem. Contact Technical Support if questions arise.

1. Under Application Objects, open the $Tank object and then open the $TankDisplay as shown in Figure 1 (below).

Instead, use the following steps to update system metadata that is stored in sys.servers and reported by the system function

Introduction. Back Up the Runtime Database. Application Versions

Part I: Setting up Bristol Babcock's OPC Server

To allow SQL Server Agent to trigger when a report is executed, we need to provide a set of report group types.

Communication to End Device Going In and Out of Slow Poll Mode

Industrial Application Server Redundancy: Troubleshooting Guidelines

All Tech Notes and KBCD documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more information.

All Tech Notes and KBCD documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more information.

Introduction. Tech Note 884 Setting Up Historian Servers for Tier-2 Summary Replication

Tech Note 813 Troubleshooting Wonderware Information Server (WIS) Part Four: Client License Release

This Tech Note describes working with Microsoft Reporting Services in order to publish InBatch Reports to Wonderware Information Server.

Tech Note 912 Using Alternate TCP Port Numbers with Modbus Ethernet DAServer

Introduction. Issues. Symptoms. Application Versions. Case 1: Deploy an ArchestrA Object - UDO4DevUsers_001_001 - Has Error Messages

Tech Note 612 Upgrading DLL Version Mismatches Between CBM Solution and System Platform

Tech Note 957 Creating Custom Password Entry on Intermec-Supported Handhelds

How To Write A Summary On A Historyorian Server

Using Network Application Development (NAD) with InTouch

Tech Note 1035 Moving the Historian Runtime Database to Another Machine Using SQL Server 2012

Tech Note 905 Troubleshooting Wonderware Information Server (WIS) Part Six: ArchestrA Graphics No Live-Data

Introduction. Application Versions. Compatibility and System Requirements. Firewall and DCOM Settings

Tech Note 400 Configuring Remote Connections for Windows 2000/2003/XP

ImageNow for Microsoft SQL Server

Implementing the system using these guidelines should improve your system performance for a large database while your database grows in size.

SQL Server Database Administrator s Guide

SQL Database Administration. Overview

SQL Server Maintenance Plans

8/23/13 Configuring SIDirect DAServer to Communicate with S7 PLC Over TCP Connection

8/22/13 Configuring the SST5136SD PCI Card Using the New SSTDHP IO Server V8.1 or the DASDHPlus Server

Dell InTrust Preparing for Auditing Microsoft SQL Server

Tech Note 652 Changing an ArchestrA Symbol's Custom Property Expression or Reference in Runtime

Security Settings for Wonderware Products

Database Maintenance Guide

Copyright 2011 Pearson Education, Inc. Publishing as Prentice Hall. Objectives

DMS Performance Tuning Guide for SQL Server

VirtualCenter Database Maintenance VirtualCenter 2.0.x and Microsoft SQL Server

How To Backup An Rssql Database With A Backup And Maintenance Wizard

This Tech Note describes modem connections using DAServers and provides some guidelines on how to make the modem connection work.

Dynamics NAV/SQL Server Configuration Recommendations

USING FILERELICATIONPRO TO REPLICATE SQL SERVER

Windows Small Business Server 2003 Upgrade Best Practices

Database Maintenance ZENworks Mobile Management 2.7.x August 2013

Tech Note 213 Finding Memory Leaks in Windows 95/98/98SE Using System Monitor

Symantec Backup Exec 11d for Windows Small Business Server

SQL Server Protection

Tech Note 128 Configuring InBatch For Standalone PCs With SQL Server and IndustrialSQL Server

How to schedule and automate backups of SQL Server databases in SQL Server Express Editions

USER MANAGEMENT IDimager Systems DOCUMENT VERSION 0.21

CONVERTING FROM NETKEEPER ISAM v6.32 to NETKEEPER SQL

Tech Note 53 Configuring the Siemens SINEC H1 CP1413 for Windows NT

mylittleadmin for MS SQL Server Quick Start Guide

Microsoft SQL Server Guide. Best Practices and Backup Procedures

EZManage SQL Pro. Quick guide for installation and implementation

DBA 101: Best Practices All DBAs Should Follow

SQL Server Replication Guide

Jason S Wong Sr. DBA IT Applications Manager DBA Developer Programmer M.S. Rice 88, MBA U.H. 94(MIS)

How To Use A Microsoft Microsoft Database Server 2012

Siemens Teamcenter Oracle -to-sql Server 2008 Migration Guide

Installing the TCP/IP Network Protocol

Netezza Workbench Documentation

8/23/13 Configuring the Wonderware SECS-II/GEM Host Creator (SERIAL-RS232)

Installation Manual Version 8.5 (w/sql Server 2005)

Performance. Optimizing Performance. Microsoft Dynamics CRM 3.0. White Paper. Date: January 10,

All Tech Notes and KBCD documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more information.

Database Administration Guide

SQL Server Training Course Content

Fixed Destinations. BackupAssist Quick-Start Guide for. BackupAssist installation, configuration and setup.

Backups and Maintenance

STIDistrict SQL 2000 Database Management Plans

Transcription:

Tech Note 975 Defragmenting MES Databases All Tech Notes, Tech Alerts and KBCD documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more information. Topic#: 002800 C reated: August 2013 Introduction MES (SQLServer) databases need to be regularly defragmented. Indexes including the primary key will need to be defragmented on a regular basis due to inserts and updates on the table. Without defragmentation, the query performance degrades over time. Indexes may need to be rebuilt or reorganized depending on the level of fragmentation. Typically we want to reorganize the index if its fragmentation is over 10% and less than 30%. Any indexes with over 30% fragmentation will require to be Rebuilt. If tables have less than 1000 rows, the table is too small to be concerned with index fragmentation. Wonderware generally recommends running the defragmentation on a weekly basis, during periods of low demand. If a Primary Key index needs to be rebuilt, then it could cause a table lock and a production transaction could fail. If you are a 24x7 plant then you should find time once a quarter where you can run the procedure. If you never defrag, your system performance will become progressively slower, potentially causing locks that will cause transactions to fail. For this reason, we recommend you schedule a job to run and deal with the potential failed transactions. The standard Microsoft SQLServer maintenance plans have an Index Rebuild and Index Reorganize job. The problem with these jobs is that they do not check the fragmentation level to determine if the jobs are needed or not. This Tech Note provides detailed guidelines and options for defragmenting and maintaining your production databases. Note: This operation is highly recommended for any Microsoft SQL Database used by Wonderware Products. Application Versions Factelligence 3.5 MES 4.x Microsoft SQLServer 2005, 2008 and 2012 (including while running with compatibility mode 80) Buiding the Defrag Tables To determine the fragmentation level, Wonderware Technical Support created the following scripts: defrag_createtables ww_spdefrag Download the scripts (provided as.txt files). Creating the Tables https://wdnresource.wonderware.com/support/kbcd/html/1/t002800.htm 1/6

1. Run the script defrag_createtables.sql. This script creates the following tables to track the defrag process: Temp_Frag_log Temp_Frag_Data 2. Run the ww_spdefrag.sql script. This script creates the ww_spdefrag stored procedure that will do the defragmentation. 3. Schedule a job (or maintenance plan) to defrag the database. You can use the following options: Option A To schedule it to run whenever the job runs, use the following T-SQL: EXEC ww_spdefrag @p_schedule=null,@p_dayno=null,@p_runhour=null Option B To schedule the specific time to run, for example every Sunday at 2AM: EXEC ww_spdefrag @p_schedule='weekly',@p_dayno=7,@p_runhour=2 This could be useful if you have data transfer job the runs regularly and you don t want the defrag to interfere with it. In this case, you would add a step to the data transfer job to do the defrag. The stored procedure would run every period (say 10 minutes) but only defrag when schedule (Sunday at 2AM). Option C To update more than just the current db (this examples does the MESDB and the ArchiveDB) at the default time Sunday at 2AM: EXEC ww_spdefrag @p_db_names='mesdb,archivedb' Parameter Details The following table contains details on the parameters for the Stored Procedure. ww_spdefrag Parameters Parameter Default Description @p_schedule Weekly Daily, Weekly, Monthly, Quarterly or Null to defrag when run. @p_dayno 7 CSV of day weekday:1=sun,2=mon,3=tue,4=wed,5=thur,6=fri,7=sat). This value is the SQLServer weekday value. @p_runhour 2 The hour of the day it should run at (2 for 2AM). https://wdnresource.wonderware.com/support/kbcd/html/1/t002800.htm 2/6

@p_db_names Null Null/empty local db, Supports CSV for dbname like MESDB,ArchiveDB. @p_reorganizelevel 10 Percent frag to force a reoganization. @p_rebuildlevel 30 Percent frag to force a rebuild. @p_mode UPDATE TEST or UPDATE @p_keepdays 365 Keeps the last 365 days of log_data records. @p_min_row_count 1000 Tables with less then 1000 rows will not be updated (default is 1000). @p_fillfactor Null Index property, Null=not used, 1 to 100 valid, default Null. @p_pad_index 0 Index property, 0=Off, 1=On, set to 1 when using FillFactor. @p_stat_nocomp 0 Index property, 0=Off, 1=On, should keep off. @p_allow_row_lock 1 Index property, 0=Off, 1=On, default is 1. @p_allow_page_lock 1 Index property, 0=Off, 1=On, default is 1. @p_sort_in_tempdb 1 Index property, 0=Off, 1=On, when sorting in tempdb more space is required to rebuild. @p_online 0 Index property, 0=Off, 1=On, only supported for Enterprise edition. @p_reorg_page_lock Fix Fix or Skip. If Fix, for reorg index will be altered to allow page locks (else it fails). @p_debug 0 0=only errors,1=only alters,2=all. Creating a Maintenance Plan The following table explains how this Stored Procedure can be used as part of a complete maintenance plan. In this example, the plant has reduced activity Sunday morning at 2AM. This scenario uses Factelligence 3.5, where the archiving is done via a stored procedure that needs to be scheduled. Note: You can change the name of the Database according to your application and version. https://wdnresource.wonderware.com/support/kbcd/html/1/t002800.htm 3/6

Name ArchiveBackupDefrag Schedule Daily at 1:00 a.m. Archive Step 1 Execute T- SQL Statement Task T-SQL: EXEC FactelligenceProd.dbo.sp_Archive_Wo Backup Database Task Type: Full Step 2 Backup Database Task Databases: FactillegenceArchive FactelligenceProd Folder: <Specify your backup folder> Options: Create a backup file for every database Verify Backup integrity Test Database Integrity Task Step 3 Check Database Integrity Task Databases: FactelligenceArchive FactelligenceProd Options: Include Indexes Rebuild Reorganize Indexes Step 4 Execute T- SQL Statement Task T-SQL: EXEC FactelligenceProd.dbo.ww_spDefrag.ww_spDefrag @p_schedule='weekly',@p_dayno=7,@p_runhour=null,@p_debug=1 Step 5 History Cleanup Task Age: Older than 4 weeks Options: Backup files https://wdnresource.wonderware.com/support/kbcd/html/1/t002800.htm 4/6

Search folders and delete files based on extension Step 6 Maintenance Cleanup Task Folder: Same as in Backup Database Task Extensions: bak File Age: Older than 1 day In SQLServer, this Maintenance Plan looks like Figure 1 (below). FIGURE 1: SQL SERVER MAINTENANCE PLAN Make sure the connection between tasks is Completion so that even if it fails the next task is done (Figure 2 below). https://wdnresource.wonderware.com/support/kbcd/html/1/t002800.htm 5/6

FIGURE 2: TASK CONNECTION IS SET TO COMPLETION Click the following icon to view this file in.pdf format: D. McKenna Tech Notes are published occasionally by Wonderware Technical Support. Publisher: Invensys Systems, Inc., 26561 Rancho Parkway South, Lake Forest, C A 92630. There is also technical information on our software products at Wonderware Technical Support. For technical support questions, send an e-mail to wwsupport@invensys.com. Back to top 2013 Invensys Systems, Inc. All rights reserved. No part of the material protected by this copyright may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying, recording, broadcasting, or by anyinformation storage and retrieval system, without permission in writing from Invensys Systems, Inc. Terms of Use. https://wdnresource.wonderware.com/support/kbcd/html/1/t002800.htm 6/6