摘要 |
An online index rebuilding method and apparatus are disclosed. The method includes: creating an index snapshot, an index cache, and a target index for a source index, and blocking a write transaction to a base table of a database during a creating process; migrating source index data in the source index to the target index page by page according to a sequence of an index page, and filtering out invalid source index data from the source index by using the index snapshot during a migration process; storing new index data, which is generated during the migration process, in the index cache; and during the migration process, if new index data required by a current index page that is being processed exists in the index cache, migrating both the new index data and the source index data that is in the current index page to the target index; or, after migration of all the source index data is complete, migrating the new index data in the index cache to the target index. According to embodiments of the present invention, random IO operations of a system and system overheads may be reduced. |