【发布时间】:2020-12-17 11:43:52
【问题描述】:
我最近将我的 Java Liquibase 版本从 3.5.3 升级到了 3.6.3
我有一个非常繁重的环境,其中有很多数据库和表(我使用的是 Oracle)。 在这种环境下,我正在尝试执行一个巨大的变更日志文件,并在其中创建表和索引。
在下面找到一小部分更改日志。
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.2.xsd">
...
...
...
<changeSet author="me" id="tableCreation78">
<preConditions onFail="MARK_RAN">
<not>
<tableExists tableName="MY_TABLE_NAME" />
</not>
</preConditions>
<comment>Creating table MY_TABLE_NAME</comment>
<createTable tableName="MY_TABLE_NAME">
<column name="M_ID" type="bigint">
<constraints nullable="false" primaryKey="true" primaryKeyName="PK_MY_TABLE_NAME_190" />
</column>
<column name="M_FORMAT" type="int" />
</createTable>
</changeSet>
...
...
...
<changeSet author="me" id="indexCreation121">
<preConditions onFail="MARK_RAN">
<tableExists tableName="MY_TABLE_NAME"/>
<not>
<indexExists tableName="MY_TABLE_NAME" columnNames="M_FEEDER_ID"/>
</not>
</preConditions>
<comment>Creating index for MY_TABLE_NAME</comment>
<createIndex tableName="MY_TABLE_NAME" indexName="MY_INDEX_NAME">
<column name="M_ID_INDEX"/>
</createIndex>
</changeSet>
...
...
...
</databaseChangeLog>
在 Liquibase 3.5.3 上,以前创建索引很快。 当我迁移到 Liquibase 3.6.3 时,我的性能出现了严重的倒退。
过去需要 1-2 分钟才能完成,现在最多需要 20 分钟才能完成。
变更日志没有定义唯一约束。
在调试时,我注意到两个版本之间的许多差异之一。在 3.5.3 中,不会调用来自 UniqueConstraintSnapshotGenerator 的 listConstraints 和 listColumns 方法。
在 3.6.3 版本中,这些方法被调用了很多,即使更改日志中没有定义唯一约束。我猜他们是从之前定义的环境表中来的。
其中一些查询(见下文)使用完全相同的参数多次调用。不知道是不是3.6.3中添加的维护步骤。
2020-08-13 17:03:52,270 INFO [main] select ucc.owner as constraint_container, ucc.constraint_name as constraint_name, ucc.column_name, f.validated as constraint_validate from all_cons_columns ucc INNER JOIN all_constraints f ON ucc.owner = f.owner AND ucc.constraint_name = f.constraint_name where ucc.constraint_name='UC' and ucc.owner='DB' and ucc.table_name not like 'BIN$%' order by ucc.position
我不确定这是否是回归的原因,但老实说,我没有想法。 有谁知道这是否可能是这种回归的原因? 他们是否在 Liquibase 3.6.3 中添加了可能导致性能大幅下降的新维护步骤?
非常感谢!
【问题讨论】: