Class SpaceTable
java.lang.Object
org.apache.derby.vti.VTITemplate
org.apache.derby.diag.SpaceTable
- All Implemented Interfaces:
AutoCloseable, ResultSet, Wrapper, AwareVTI, VTICosting
SpaceTable is a virtual table that shows the space usage of a particular
table and its indexes.
This virtual table can be invoked by calling it
directly, and supplying the schema name and table name as arguments.
SELECT * FROM TABLE(SYSCS_DIAG.SPACE_TABLE('MYSCHEMA', 'MYTABLE')) T;
If the schema name is not supplied, the default schema is used.
SELECT * FROM TABLE(SYSCS_DIAG.SPACE_TABLE('MYTABLE')) T;
NOTE: Both the schema name and the table name must be any expression that evaluates to a string data type. If you created a schema or table name as a non-delimited identifier, you must present their names in all upper case.
The SpaceTable virtual table can be used to estimate whether space might be saved by compressing a table and its indexes.
The SpaceTable virtual table has the following columns:
- CONGLOMERATENAME varchar(128) - nullable. The name of the conglomerate, which is either the table name or the index name. (Unlike the SYSCONGLOMERATES column of the same name, table ID's do not appear here).
- ISINDEX SMALLINT - not nullable. Is not zero if the conglomerate is an index, 0 otherwise.
- NUMALLOCATEDPAGES bigint - not nullable. The number of pages actively linked into the table. The total number of pages in the file is the sum of NUMALLOCATEDPAGES + NUMFREEPAGES.
- NUMFREEPAGES bigint - not nullable. The number of free pages that belong to the table. When a new page is to be linked into the table the system will move a page from the NUMFREEPAGES list to the NUMALLOCATEDPAGES list. The total number of pages in the file is the sum of NUMALLOCATEDPAGES + NUMFREEPAGES.
- NUMUNFILLEDPAGES bigint - not nullable. The number of unfilled pages that belong to the table. Unfilled pages are allocated pages that are not completely full. Note that the number of unfilled pages is an estimate and is not exact. Running the same query twice can give different results on this column.
- PAGESIZE integer - not nullable. The size of the page in bytes for that conglomerate.
- ESTIMSPACESAVING bigint - not nullable. The estimated space which could possibly be saved by compressing the conglomerate, in bytes.
- TABLEID char(36) - not nullable. The UUID of the table.
To get space information on all schemas and tables, use a query such as
select v.*
from SYS.SYSSCHEMAS s,
SYS.SYSTABLES t,
TABLE(SYSCS_DIAG.SPACE_TABLE(SCHEMANAME, TABLENAME)) v
where s.SCHEMAID = t.SCHEMAID;
-
Nested Class Summary
Nested classes/interfaces inherited from class VTITemplate
VTITemplate.ColumnDescriptor -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ResultColumnDescriptor[]private ConglomInfo[](package private) int(package private) booleanprivate static final ResultSetMetaDataprivate Stringprivate SpaceInfoprivate Stringprivate TransactionControllerprivate booleanFields inherited from interface ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVEFields inherited from interface VTICosting
defaultEstimatedCost, defaultEstimatedRowCount -
Constructor Summary
ConstructorsConstructorDescriptionSpaceTable(String tableName) SpaceTable(String schemaName, String tableName) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()private voiddoublegetEstimatedCostPerInstantiation(VTIEnvironment vtiEnvironment) Get the estimated cost for a single instantiation of a Table Function.doublegetEstimatedRowCount(VTIEnvironment vtiEnvironment) Get the estimated row count for a single scan of a Table Function.intgetInt(int columnNumber) longgetLong(int columnNumber) shortgetShort(int columnNumber) private voidgetSpaceInfo(int index) getString(int columnNumber) booleannext()booleansupportsMultipleInstantiations(VTIEnvironment vtiEnvironment) Find out if the ResultSet of the Table Function can be instantiated multiple times.booleanwasNull()Methods inherited from class VTITemplate
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getContext, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getHoldability, getInt, getLong, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getReturnTableSignature, getRow, getRowId, getRowId, getShort, getSQLXML, getSQLXML, getStatement, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, isWrapperFor, last, moveToCurrentRow, moveToInsertRow, notImplemented, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setContext, setFetchDirection, setFetchSize, unwrap, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestampMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ResultSet
updateObject, updateObject, updateObject, updateObject
-
Field Details
-
conglomTable
-
initialized
boolean initialized -
currentRow
int currentRow -
wasNull
private boolean wasNull -
schemaName
-
tableName
-
spaceInfo
-
tc
-
columnInfo
-
metadata
-
-
Constructor Details
-
SpaceTable
public SpaceTable() -
SpaceTable
-
SpaceTable
-
-
Method Details
-
getConglomInfo
- Throws:
StandardException
-
getSpaceInfo
- Throws:
StandardException
-
getMetaData
- Specified by:
getMetaDatain interfaceResultSet- Overrides:
getMetaDatain classVTITemplate- See Also:
-
next
- Specified by:
nextin interfaceResultSet- Throws:
SQLException- if no transaction context can be found- See Also:
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceResultSet- See Also:
-
getString
- Specified by:
getStringin interfaceResultSet- Overrides:
getStringin classVTITemplate- See Also:
-
getLong
public long getLong(int columnNumber) - Specified by:
getLongin interfaceResultSet- Overrides:
getLongin classVTITemplate- See Also:
-
getShort
public short getShort(int columnNumber) - Specified by:
getShortin interfaceResultSet- Overrides:
getShortin classVTITemplate- See Also:
-
getInt
public int getInt(int columnNumber) - Specified by:
getIntin interfaceResultSet- Overrides:
getIntin classVTITemplate- See Also:
-
wasNull
public boolean wasNull()- Specified by:
wasNullin interfaceResultSet- Overrides:
wasNullin classVTITemplate- See Also:
-
getEstimatedRowCount
Description copied from interface:VTICostingGet the estimated row count for a single scan of a Table Function.- Specified by:
getEstimatedRowCountin interfaceVTICosting- Parameters:
vtiEnvironment- The state variable for optimizing the Table Function.- Returns:
- The estimated row count for a single scan of the Table Function.
- See Also:
-
getEstimatedCostPerInstantiation
Description copied from interface:VTICostingGet the estimated cost for a single instantiation of a Table Function.- Specified by:
getEstimatedCostPerInstantiationin interfaceVTICosting- Parameters:
vtiEnvironment- The state variable for optimizing the Table Function.- Returns:
- The estimated cost for a single instantiation of the Table Function.
- See Also:
-
supportsMultipleInstantiations
Description copied from interface:VTICostingFind out if the ResultSet of the Table Function can be instantiated multiple times.- Specified by:
supportsMultipleInstantiationsin interfaceVTICosting- Parameters:
vtiEnvironment- The state variable for optimizing the Table Function.- Returns:
- true
- See Also:
-