|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.derby.iapi.db.OnlineCompress
Implementation of SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE().
Code which implements the following system procedure: void SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE( IN SCHEMANAME VARCHAR(128), IN TABLENAME VARCHAR(128), IN PURGE_ROWS SMALLINT, IN DEFRAGMENT_ROWS SMALLINT, IN TRUNCATE_END SMALLINT)
This system procedure can be used to force 3 levels of in place compression of a SQL table. The table is specified using the SCHEMANAME and TABLENAME arguments.
If PURGE_ROWS is set to non-zero then a single pass is made through the table which will purge committed deleted rows from the table. This space is then available for future inserted rows, but remains allocated to the table. As this option scans every page of the table, it's performance is linearly related to the size of the table.
If DEFRAGMENT_ROWS is set to non-zero then a single defragment pass is made which will move existing rows from the end of the table towards the front of the table. The goal of the defragment run is to empty a set of pages at the end of the table which can then be returned to the OS by the TRUNCATE_END option. It is recommended to only run DEFRAGMENT_ROWS, if also specifying the TRUNCATE_END option. This option scans the whole table and needs to update index entries for every base table row move, and thus execution time is linearly related to the size of the table.
If TRUNCATE_END is set to non-zero then all contiguous pages at the end of the table will be returned to the OS. Running the DEFRAGMENT_ROWS option may increase the number of pages affected. This option itself does no scans of the table, so performs on the order of a few system calls. TODO LIST: o defragment requires table level lock in nested user transaction, which will conflict with user lock on same table in user transaction.
Constructor Summary | |
private |
OnlineCompress()
no requirement for a constructor |
Method Summary | |
static void |
compressTable(java.lang.String schemaName,
java.lang.String tableName,
boolean purgeRows,
boolean defragmentRows,
boolean truncateEnd)
Implementation of SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE(). |
private static void |
defragmentRows(java.lang.String schemaName,
java.lang.String tableName,
DataDictionary data_dictionary,
TransactionController tc)
Defragment rows in the given table. |
private static void |
fixIndex(DataValueDescriptor[] base_row,
DataValueDescriptor[] index_row,
RowLocation old_row_loc,
RowLocation new_row_loc,
ConglomerateController index_cc,
ScanController index_scan,
int[] index_col_map)
Delete old index row and insert new index row in input index. |
private static void |
purgeRows(java.lang.String schemaName,
java.lang.String tableName,
DataDictionary data_dictionary,
TransactionController tc)
Purge committed deleted rows from conglomerate. |
private static void |
setup_indexes(TransactionController tc,
TableDescriptor td,
int[][] index_col_map,
ScanController[] index_scan,
ConglomerateController[] index_cc,
DataValueDescriptor[][] index_row)
|
private static void |
truncateEnd(java.lang.String schemaName,
java.lang.String tableName,
DataDictionary data_dictionary,
TransactionController tc)
Truncate end of conglomerate. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
private OnlineCompress()
Method Detail |
public static void compressTable(java.lang.String schemaName, java.lang.String tableName, boolean purgeRows, boolean defragmentRows, boolean truncateEnd) throws java.sql.SQLException
Top level implementation of the system procedure. All the real work is found in the other routines in this file implementing the 3 phases of inplace compression: purge, defragment, and truncate.
schemaName
- schema name of table, requiredtableName
- table name to be compressedpurgeRows
- if true, do a purge pass on the tabledefragmentRows
- if true, do a defragment pass on the tabletruncateEnd
- if true, return empty pages at end to OS.
java.sql.SQLException
- Errors returned by throwing SQLException.private static void defragmentRows(java.lang.String schemaName, java.lang.String tableName, DataDictionary data_dictionary, TransactionController tc) throws java.sql.SQLException
Scans the rows at the end of a table and moves them to free spots towards the beginning of the table. In the same transaction all associated indexes are updated to reflect the new location of the base table row.
After a defragment pass, if was possible, there will be a set of empty pages at the end of the table which can be returned to the operating system by calling truncateEnd(). The allocation bit maps will be set so that new inserts will tend to go to empty and half filled pages starting from the front of the conglomerate.
schemaName
- schema of table to defragementtableName
- name of table to defragmentdata_dictionary
- An open data dictionary to look up the table in.tc
- transaction controller to use to do updates.
java.sql.SQLException
private static void purgeRows(java.lang.String schemaName, java.lang.String tableName, DataDictionary data_dictionary, TransactionController tc) throws StandardException
Scans the table and purges any committed deleted rows from the table. If all rows on a page are purged then page is also reclaimed.
schemaName
- schema of table to defragementtableName
- name of table to defragmentdata_dictionary
- An open data dictionary to look up the table in.tc
- transaction controller to use to do updates.
StandardException
private static void truncateEnd(java.lang.String schemaName, java.lang.String tableName, DataDictionary data_dictionary, TransactionController tc) throws StandardException
Returns the contiguous free space at the end of the table back to the operating system. Takes care of space allocation bit maps, and OS call to return the actual space.
schemaName
- schema of table to defragementtableName
- name of table to defragmentdata_dictionary
- An open data dictionary to look up the table in.tc
- transaction controller to use to do updates.
StandardException
private static void setup_indexes(TransactionController tc, TableDescriptor td, int[][] index_col_map, ScanController[] index_scan, ConglomerateController[] index_cc, DataValueDescriptor[][] index_row) throws StandardException
StandardException
private static void fixIndex(DataValueDescriptor[] base_row, DataValueDescriptor[] index_row, RowLocation old_row_loc, RowLocation new_row_loc, ConglomerateController index_cc, ScanController index_scan, int[] index_col_map) throws StandardException
base_row
- all columns of base rowindex_row
- an index row template, filled in by this routineold_row_loc
- old location of base row, used to delete indexnew_row_loc
- new location of base row, used to update indexindex_cc
- index conglomerate to insert new rowindex_scan
- index scan to delete old entryindex_col_map
- description of mapping of index row to base row,
StandardException
- Standard exception policy.
|
Built on Mon 2007-06-04 09:58:47+0400, from revision ??? | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |