PRbu = sqlite3rbu_vacuum(zTarget, zState) ZState = sqlite3_mprintf("%s-vacuum", zTarget) ** the state database, where is the name of the databaseĬhar *zState /* Name of state database */ ** This function uses the database named "-vacuum" for ** may be resumed by a subsequent call to this function and return ** signals an interrupt, suspend the RBU vacuum operation so that it ** If an error occurs, return SQLite error code. ** If the RBU vacuum is completed successfully, return SQLITE_DONE. ** vacuum is finished or when the application signals an interrupt Return when either an error occurs, the RBU ** Either start a new RBU vacuum or resume a suspended RBU vacuum on The example code below uses "-vacuum", where is the name of the database being vacuumed. It is a good idea to establish a convention for determining the RBU vacuum state database name based on the target database name. In this case, the next call to sqlite3rbu_vacuum() starts an entirely new vacuum operation from scratch. When an RBU vacuum operation is completed or encounters an error, RBU automatically deletes the contents of the rbu_state table. The next time sqlite3rbu_vacuum() is called with the same S parameter, it detects this data and attempts to resume the suspended vacuum operation. If an ongoing RBU vacuum is suspended, this table is populated with state data. If state database S does not exist when sqlite3rbu_vacuum() is invoked, it is automatically created and populated with the single table used to store the state of an RBU vacuum - "rbu_state". ![]() Argument S is the name of a database in which the RBU module will save its state if the vacuum operation is suspended. An RBU handle is created by calling sqlite3rbu_vacuum(T, S).Īrgument T is the name of the database file to vacuum.For this reason, an RBU Vacuum is often significantly slower than an SQLite VACUUM under the same conditions. On the other hand, an RBU Vacuum uses more CPU than a regular SQLite VACUUM - in one test as much as five times as much. By contrast, an RBU Vacuum requires roughly the size of the final database file in temporary disk space and writes a total of twice that to disk. The total amount of data written is around three times the size of the final database file. An SQLite VACUUM requires roughly twice the size of the final database file in temporary disk space to run. ![]() ![]() For a large database file (one that does not fit in the OS disk cache) this procedure can result in two orders of magnitude faster updates.Īn RBU Vacuum operation requires less temporary disk space and writes less data to disk than an SQLite VACUUM. The RBU update process works around this by applying all changes to the main table in one pass, then applying changes to each index in separate passes, ensuring each B-Tree is updated optimally. As a result, when executing a series of INSERT, UPDATE and DELETE statements it is not generally possible to order the operations so that all b-trees are updated in key order. But if an SQL table has one or more indexes, the key order for each index may be different from the main table and the other auxiliary indexes. RBU may be more efficient The most efficient way to apply changes to a B-Tree (the data structure that SQLite uses to store each table and index on disk) is to make the changes in key order.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |