Currently Being Moderated

Reindexing LANDesk Databases

VERSION 2

Created on: Dec 20, 2007 10:38 AM by Sean McClure - Last Modified:  Feb 27, 2008 12:18 PM by Wintermute

 

*Please note that if you are running SQL Standard Edition, you will need to set the database to SINGLE USER MODE before reindexing the DB.*

 

 

*Also remember to set your DB back to Multi-User mode when done!!!*

 

 

To set a database to single-user mode in SQL 2005 

 

  1. In Object Explorer, connect to an instance of the SQL Server 2005 Database Engine, and then expand that instance.

  2. Right-click the database to change, and then click Properties.

  3. In the Database Properties dialog box, click the Options page.

  4. From the Restrict Access option, select Single.

  5. If other users are connected to the database, an Open Connections message will appear. To change the property and close all other connections, click Yes.

 

 

For SQL 2000:

 

 

To set a single database in a SQL Server 2000 database into single user mode:

 

  1. Connect to SQL Server using SQL Query Analyzer (or osql or similar).

  2. Issue the command:<code># alter database db-name set SINGLE_USER</code># where "+<code># db-name</code># +" is the name of the database to place in single user mode.

 

To start SQL Server in single user mode:

 

  1. Start a command session (start &gt; Run &gt; "cmd" Return).

  2. To ensure that SQL Server is not running type:<code># net stop MSSQLServer</code># This may say that this will also stop another service (typically<code># SQLSERVERAGENT</code># ), in which case allow it to continue. It will also indicate if the service is already stopped.

  3. To start SQL Server in single user mode type:<code># sqlservr -m</code># If this is not recognised then cd to '<code># C:\Program Files\Microsoft SQL Server\MSSQL\BINN</code># ' and try again.

 

Database Indexing

 

Performing routine database maintenance such as reindexing is important for keeping the LANDesk database running at peak performance. When information is entered or modified in the database tables, indexes can become fragmented. Index fragmentation can happen when the logical sequence of pages is disrupted or when an index page contains less than its maximum amount of data, creating a gap in the data page or index. As indexes become fragmented, data reads become inefficient when accessing tables and slow database performance.

 

 

 

 

 

Microsoft SQL Server*

1. Download SQLReindex.zip attached to this article

2. Open Microsoft* SQL Query Analyzer and login with the credentials used by the Core Server

3. Select the LANDesk Database from the dropdown in the toolbar

4. Open the script contained in SQLReindex.zip with a text editor

5. Copy the contents of the script to SQL Query Analyzer and run it

 

**Oracle**

1. Download OracleReindex_ScriptBuilder.zip attached to this article

2. Extract OracleReindex_ScriptBuilder.zip

3. Replace &lt;indexowner&gt; in the script with the actual name of the Oracle user that owns the indexes. This should be the Oracle user that was used to install the Core Server. There are 2 places in the script that need to be changed.    

4. Open Oracle* SQL Plus and login with the Oracle credentials used by the Core Server

 

5. In SQL Plus type the @ sign followed by the location of the edited

.sql file from step 2 (Example:

@c:\temp\oraclereindex_scriptbuilder.sql)

 

 

Attachments:
Trevor Trevor  says:

In some cases re-indexing the database on a MS SQL server needs to be done while the database is offline. One way to avoid taking the database offline is to de-fragment the indexes instead. Consult your Database Administrator (DBA) for assistance in writing a script to de-fragment your indexes.,

Leon Han Leon Han  says:

Be careful with the SINGLE_USER mode. If that mode is set on when you want to access the database via database tool you have to cut off all the connections to the database, also means in a production environment you have to stop all LANDesk services.

EGarlepp EGarlepp  says:

Could you run a SQL command prior to and after the Reindex to automate this, or this is something we should not do?

 

Ex:

ALTER DATABASE LDDB

SET SINGLE_USER

GO

 

 

ALTER DATABASE LDDB

SET MULTI_USER

GO

 

 

I am running SQL 2005 std SP2

LANDesk Community powered by Jive Software's Clearspace ®                                                                        Subscribe| Legal Notices| Investor Relations| Privacy Policy © 2007 LANDesk Software