Skip to content

创建备份数据库中的表时给opid_time列添加索引 #414

@H2CO3Bearcard

Description

@H2CO3Bearcard

描述您想要的功能:
创建备份数据库中的表时给opid_time列添加索引,archery在生成回滚语句时会用此列查询,语句为:

select rollback_statement 
from xxxxxxxxxxxxxxxx_xxxx_xxxxx.xxxxx 
where opid_time='1639656399_408758713_00000568'

没有索引会造成全表扫描,回滚数据库压力增大
描述您考虑过的解决/替代方案:

func (s *session) mysqlCreateSqlFromTableInfo(dbname string, ti *TableInfo) string {

	buf := bytes.NewBufferString("CREATE TABLE if not exists ")
	buf.WriteString(fmt.Sprintf("`%s`.`%s`", dbname, ti.Name))
	buf.WriteString("(")

	buf.WriteString("id bigint auto_increment primary key, ")
	buf.WriteString("rollback_statement mediumtext, ")
	buf.WriteString("opid_time varchar(50),")
        buf.WriteString("KEY `idx_opid_time` (`opid_time`)")
	buf.WriteString(") ENGINE INNODB DEFAULT CHARSET UTF8MB4;")

	return buf.String()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions