摘要 |
The present invention discloses an online index rebuilding method and apparatus, where the method includes: receiving an online index rebuilding request; adding, according to the online index rebuilding request, a schema shared lock to a data table corresponding to an identifier of the data table; obtaining a latch and obtaining a structure control right of the data table by using the latch; after the latch is obtained, reserving storage space of a shadow index for an original index of the data table, allocating an entry address of the shadow index, and adding the entry address of the shadow index to a root page of the data table; releasing the latch after the adding the entry address of the shadow index to a root page of the data table is completed; building the shadow index in the storage space of the shadow index according to data of the original index; updating an index entry address on the root page of the data table to the entry address of the shadow index after the latch is obtained again; and releasing the latch obtained again and the schema shared lock. Therefore, efficiency of online index rebuilding is improved. |