in core/lib/sqlparse/models.py [0:0]
def droppable_indexes(self, keep_unique_key=False):
"""
Drop index before loading, and create afterwards can make the whole
process faster. Also the indexes will be more compact than loading
directly.
This function will return a list of droppable indexes for the
purpose of fast index recreation.
@param keep_unique_key: Keep unique key or not
@type keep_unique_key: bool
@return: a list of droppable indexes to make load faster
@rtype : [TableIndex]
"""
# Primary key should not be dropped, but it's not included in
# table.indexes so we are fine here
idx_list = []
auto_incre_name = ""
for col in self.column_list:
if col.auto_increment:
auto_incre_name = col.name
break
for idx in self.indexes:
# Drop index which contains only the auto_increment column is
# not allowed
if len(idx.column_list) == 1:
if auto_incre_name and auto_incre_name == idx.column_list[0].name:
continue
# We can drop unique index for most of the time. Only if we want
# to ignore duplicate key when adding new unique indexes, we need
# to have the index exist on new table before loading data. So that
# we can utilize "LOAD IGNORE" to ignore the duplicated data
if keep_unique_key and idx.is_unique:
continue
idx_list.append(idx)
return idx_list