Use Interactive SQL to identify and fix index fragmentation. You should periodically check for fragmentation on your production database.
This lesson assumes that you have the roles and privileges listed in the Privileges section at the start of this tutorial: Tutorial: Diagnosing index fragmentation.
This tutorial assumes that you have created the test database, app_profiling.db. See Tutorial: Creating a test database for the application profiling tutorials.
Ensure that there are no other connections to app_profiling.db.
Start Interactive SQL. Click Start » Programs » SQL Anywhere 16 » Administration Tools » Interactive SQL.
In the Connect window, complete the following fields to connect to the test database, app_profiling.db.
In the User ID field, type DBA.
In the Password field, type sql.
In the Action dropdown list, select Start and connect to a database on this computer.
In the Database file field, type C:\AppProfilingTutorial\app_profiling.db.
In the Start Line field, type dbeng16 -x tcpip.
In Interactive SQL, execute the following SQL statement to test the index density on the Employees table:
CALL sa_index_density( 'Employees' );
Density values range between 0 and 1. Values closer to 1 indicate little index fragmentation. Values less than 0.5 indicate a level of index fragmentation that can impact performance.
The values for the indexes on the Employees appear to show fragmentation issues because the values in the Density column of the results are well under 0.5. However, these numbers are artificially low because the table is very small.
In Interactive SQL, execute the following ALTER INDEX...REBUILD statement to improve the density of an index:
ALTER INDEX PRIMARY KEY ON Employees REBUILD;
Close Interactive SQL.
Discuter à propos de cette page dans DocCommentXchange.
|Copyright © 2013, SAP AG ou société affiliée SAP - SAP Sybase SQL Anywhere 16.0|