Space and statistics: spacedb, compactdb, optimizedb, plandump, vacuumdb
spacedb
Section titled “spacedb”The coradb spacedb utility is used to check how much space of database volumes is being used. The tool can show brief aggregated information on database space usage, or detailed descriptions of all volumes and files in use, based on its options. Information returned by the coradb spacedb utility includes the volume ID's, names, purpose and total/free space of each volume.
coradb spacedb [options] database_name- coradb : An integrated utility for the CoraDB service and database management.
- spacedb : A command that checks the space in the database. It executes successfully only when the database is in a stopped state.
- database_name : The name of the database whose space is to be checked. The path-name to the directory where the database is to be created must not be included.
The following shows [options] available with the coradb spacedb utility.
This option stores the result of checking the space information of testdb to a file named db_output.
coradb spacedb -o db_output testdbThis option is used to access a database in standalone, which means it works without processing server; it does not have an argument. If -S is not specified, the system recognizes that a database is running in client/server mode.
coradb spacedb --SA-mode testdbThis option is used to access a database in client/server mode, which means it works in client/server process respectively; it does not have an argument. If -C is not specified, the system recognize that a database is running in client/server mode by default.
coradb spacedb --CS-mode testdbThis option specifies the size unit of the space information of the database to be one of PAGE, M(MB), G(GB), T(TB), H(print-friendly). The default value is H. If you set the value to H, the unit is automatically determined as follows: M if 1 MB = DB size < 1024 MB, G if 1 GB = DB size < 1024 GB.
$ coradb spacedb --size-unit=H testdb
Space description for database 'testdb' with pagesize 16.0K. (log pagesize: 16.0K)
type purpose volume_count used_size free_size total_sizePERMANENT PERMANENT DATA 2 61.0 M 963.0 M 1.0 GPERMANENT TEMPORARY DATA 1 12.0 M 500.0 M 512.0 MTEMPORARY TEMPORARY DATA 1 40.0 M 88.0 M 128.0 M- - 4 113.0 M 1.5 G 1.6 G
Space description for all volumes:volid type purpose used_size free_size total_size volume_name 0 PERMANENT PERMANENT DATA 60.0 M 452.0 M 512.0 M /home1/coradb/testdb 1 PERMANENT PERMANENT DATA 1.0 M 51.0 M 512.0 M /home1/coradb/testdb_x001 2 PERMANENT TEMPORARY DATA 12.0 M 500.0 M 512.0 M /home1/coradb/testdb_x00232766 TEMPORARY TEMPORARY DATA 40.0 M 88.0 M 128.0 M /home1/coradb/testdb_t32766
LOB space description file:/home1/coradb/lobThis option aggregates volume count, used size, free size and total size by volume types and purposes. There are three classes of volumes: permanent volumes with permanent data, permanent volumes with temporary data and temporary volume with temporary data; no temporary volumes with permanent data. Last row shows the total values for all types of volumes.
$ coradb spacedb -s testdb
Space description for database 'testdb' with pagesize 16.0K. (log pagesize: 16.0K)
type purpose volume_count used_size free_size total_sizePERMANENT PERMANENT DATA 2 61.0 M 963.0 M 1.0 GPERMANENT TEMPORARY DATA 1 12.0 M 500.0 M 512.0 MTEMPORARY TEMPORARY DATA 1 40.0 M 88.0 M 128.0 M- - 4 113.0 M 1.5 G 1.6 GThis option shows detailed information on the purpose of stored data. The information includes number of files, used size, size of file tables, reserved sectors size and total size.
Space description for database 'testdb' with pagesize 16.0K. (log pagesize: 16.0K)
Detailed space description for files:data_type file_count used_size file_table_size reserved_size total_sizeINDEX 17 0.3 M 0.3 M 16.5 M 17.0 MHEAP 28 7.6 M 0.4 M 26.0 M 34.0 MSYSTEM 8 0.4 M 0.1 M 7.5 M 8.0 MTEMP 10 0.0 M 0.2 M 49.8 M 50.0 M- 63 8.2 M 1.0 M 99.8 M 109.0 Mcompactdb
Section titled “compactdb”The coradb compactdb utility is used to secure unused space of the database volume. In case the database server is not running (offline), you can perform the job in standalone mode. In case the database server is running, you can perform it in client-server mode.
Reference to the object deleted during compacting is displayed as NULL, which means this can be reused by OIDs.
coradb compactdb [options] database_name [class_name], class_name2, ...]- coradb: An integrated utility for the CoraDB service and database management.
- compactdb: A command that compacts the space of the database so that OIDs assigned to deleted data can be reused.
- database_name: The name of the database whose space is to be compacted. The path name to the directory where the database is to be created must not be included.
- class_name_list: You can specify the list of tables names that you want to compact space after a database name; the -i option cannot be used together. If you use the lists on client/server mode, it skips securing space taken by objects such as catalog, delete files and tracker, etc.
-I, -c, -d, -p options are applied in client/server mode only.
The following shows [options] available with the coradb compactdb utility.
You can output messages that shows which class is currently being compacted and how many instances have been processed for the class by using the -v option.
coradb compactdb -v testdbThis option specifies to compact used space in standalone mode while database server is not running; no argument is specified. If the -S option is not specified, system recognizes that the job is executed in client/server mode.
coradb compactdb --SA-mode testdbThis option specifies to compact used space in client/server mode while database server is running; no argument is specified. Even though this option is omitted, system recognizes that the job is executed in client/server mode.
You can specify an input file name that contains the table name with this option. Write one table name in a single line; invalid table name is ignored. Note that you cannot specify the list of the table names after a database name in case of you use this option. If you use this option on client/server mode, it skips securing space taken by objects such as catalog, delete files and tracker, etc.
The following options can be used in client/server mode only.
-p, --pages-commited-once=NUMBER
You can specify the number of maximum pages that can be committed once with this option. The default value is 10, the minimum value is 1, and the maximum value is 10. The less option value is specified, the more concurrency is enhanced because the value for class/instance lock is small; however, it causes slowdown on operation, and vice versa.
coradb compactdb --CS-mode -p 10 testdb tbl1, tbl2, tbl5You can delete an existing table representation (schema structure) from catalog with this option. Generally you'd better keep the existing table representation because schema updating cost will be saved when you keep the status as referring to the past schema for the old records.
-I, --Instance-lock-timeout=NUMBER
You can specify a value of instance lock timeout with this option. The default value is 2 (seconds), the minimum value is 1, and the maximum value is 10. The less option value is specified, the more operation speeds up. However, the number of instances that can be processed becomes smaller, and vice versa.
-c, --class-lock-timeout=NUMBER
You can specify a value of instance lock timeout with this option. The default value is 10 (seconds), the minimum value is 1, and the maximum value is 10. The less option value is specified, the more operation speeds up. However, the number of tables that can be processed becomes smaller, and vice versa.
vacuumdb
Section titled “vacuumdb”coradb vacuumdb removes the old row versions and index entries left behind by updates and deletes (see MVCC and VACUUM). The database server normally does this continuously in the background; vacuumdb runs the same cleanup on demand for a stopped database.
coradb vacuumdb [option] database_name| Option | Meaning |
|---|---|
| -S, --SA-mode | Standalone mode: the database server must be stopped |
| -C, --CS-mode | Client-server mode; currently not available (Vacuumdb is temporary not available for client-server mode) |
coradb server stop testdbcoradb vacuumdb -S testdbThe SQL statement VACUUM does the same in a standalone corasql session (corasql -S).
optimizedb
Section titled “optimizedb”Updates statistical information such as the number of objects, the number of pages to access, and the distribution of attribute values.
coradb optimizedb [option] database_name- coradb: An integrated utility for the CoraDB service and database management.
- optimizedb: Updates the statistics information, which is used for cost-based query optimization of the database. If the option is specified, only the information of the specified class is updated.
- database_name: The name of the database whose cost-based query optimization statistics are to be updated.
The following shows [option] available with the coradb optimizedb utility.
The following example shows how to update the query statistics information of the given class by using the -n option.
coradb optimizedb -n event_table testdbThe following example shows how to update the query statistics information of all classes in the database.
coradb optimizedb testdbplandump
Section titled “plandump”The coradb plandump utility is used to display information on the query plans stored (cached) on the server.
coradb plandump [options] database_name- coradb: An integrated utility for the CoraDB service and database management.
- plandump: A utility that displays the query plans stored in the current cache of a specific database.
- database_name: The name of the database where the query plans are to be checked or dropped from its server cache.
If no option is used, it checks the query plans stored in the cache.
coradb plandump testdbThe following shows [options] available with the coradb plandump utility.
This option drops the query plans stored in the cache.
coradb plandump -d testdbThis option stores the results of the query plans stored in the cache to a file.
coradb plandump -o output.txt testdb