When you drop an index, you are dropping a logical index; however, you are not always dropping the physical index to which it refers. If another logical index refers to the same physical index, the physical index is not deleted. This is important to know, especially if you expect disk space to be freed by dropping the index, or if you are dropping the index with the intent to physically recreate it.
To determine whether an index for a table is sharing a physical index with any other indexes, select the table in Sybase Central, and then click the Indexes tab. Note whether the Phys. ID value for the index is also present for other indexes in the list. Matching Phys. ID values mean that those indexes share the same physical index. If you want to recreate a physical index, you can use the ALTER INDEX ... REBUILD statement. Alternatively, you can drop all of the indexes, and then recreate them.
At any time, you can obtain a list of all tables in which physical indexes are being shared, by executing a query similar to the following:
SELECT tab.table_name, idx.table_id, phys.phys_index_id, COUNT(*) FROM SYSIDX idx JOIN SYSTAB tab ON (idx.table_id = tab.table_id) JOIN SYSPHYSIDX phys ON ( idx.phys_index_id = phys.phys_index_id AND idx.table_id = phys.table_id ) GROUP BY tab.table_name, idx.table_id, phys.phys_index_id HAVING COUNT(*) > 1 ORDER BY tab.table_name; |
Following is an example result set for the query:
table_name | table_id | phys_index_id | COUNT(*) |
---|---|---|---|
ISYSCHECK | 57 | 0 | 2 |
ISYSCOLSTAT | 50 | 0 | 2 |
ISYSFKEY | 6 | 0 | 2 |
ISYSSOURCE | 58 | 0 | 2 |
MAINLIST | 94 | 0 | 3 |
MAINLIST | 94 | 1 | 2 |
The number of rows for each table indicates the number of shared physical indexes for the tables. In this example, all of the tables have one shared physical index, except for the fictitious table, MAINLIST, which has two. The phys_index_id values identifies the physical index being shared, and the value in the COUNT column tells you how many logical indexes are sharing the physical index.
You can also use Sybase Central to see which indexes for a given table share a physical index. To do this, choose the table in the left pane, click the Indexes tab in the right pane, and then look for multiple rows with the same value in the Phys. ID column. Indexes with the same value in Phys. ID share the same physical index.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |