I have these four tables:
Clientes | Lojas | Endereço | Contato
As both lojas
and clientes
have address and contact telephones , there is only a single table for endereços
and contatos
, to identify each register there is a prefix for each insert: C for client and L for store, so I have records like this: tabela contatos
ContatoId | contato_dddCelular | contato_celular | contato_dddtellefone | contato_telefone
C1 |11 | 912341234 |11 |12341234
L1 |21 | 912341234 |21 |12341234
There are some views
in mysql
that are showing an absurd slowness, after doing some tests I realized that the problem was just some joins
being done with the Concat()
function, something like join contatos on Concat("C",clientes.clienteId) = contatos.ContatoId)
after removing these join
queries were done almost instantly, my question is what would be an alternative relationship or ideal to fix this problem without having to create two address and contact tables?