The question of performance arises because of the high number of tables where the code has to be replaced (about 50/60 tables), in addition to having to do the uncheck / check of some constraints due to referential integrity.
Given that each database is a case (you can optimize in this case but not in others), you can always create indexes in the largest tables, such as Historico
and / or LinhasLiq
:
CREATE NONCLUSTERED INDEX IX_Historico_Entidade
ON Historico(Entidade)
INCLUDE(TipoEntidade)
CREATE NONCLUSTERED INDEX IX_Historico_EntidadeComercial
ON Historico(EntidadeComercial)
INCLUDE(TipoEntidadeComercial)
CREATE NONCLUSTERED INDEX IX_Historico_EntidadeDestino
ON Historico(EntidadeDestino)
INCLUDE(TipoEntidadeDestino)
CREATE NONCLUSTERED INDEX IX_LinhasLiq_Entidade
ON LinhasLiq(Entidade)
INCLUDE(TipoEntidade)
The Accounting table, Movimentos
, already has indexes for the Entidade
and Terceiro
columns.