2
I migrated data from a bank Myisam for Innodb and some VIEW
were extremely slow (on average 15x slower), after much research found that answer from @Maniero and in it he makes a comparison between the two Engines.
In his reply I noticed that Innodb is slow with clause COUNT(*)
that’s when I removed the COUNT(*)
of SELECT
within the VIEW
and here is the result:
310x faster.
The query I’m running is this(Decreases to be more readable):
SELECT DISTINCT
`a`.`ASSINATURAS_ID` AS `ASSINATURAS_ID`,
`pd`.`PEDIDOS_DETALHES_Descricao_Produto` AS `PEDIDOS_DETALHES_Descricao_Produto`,
`pd`.`FK_PRODUTO` AS `FK_PRODUTO`,
(SELECT
COUNT(*)
FROM
`licencas`
WHERE
(`licencas`.`FK_PEDIDO` = `p`.`PEDIDOS_ID`)) AS `TotalDownloadSubscriptionCount`,
FROM
((`n_assinaturas` `a`
JOIN `pedidos` `p` ON ((`p`.`PEDIDOS_ID` = `a`.`FK_PEDIDO`)))
JOIN `planos_conta` `pc` ON ((`pc`.`ID_PLANOS_Conta` = `p`.`FK_PLANOS_Conta`)))
There is an option to COUNT(*)
in the Innodb ?
My condolences, went from something good to something questionable.
– Maniero
trial
SELECT SQL_CALC_FOUND_ROWS * FROM nome_da_tabela limit 1;
thenSELECT FOUND_ROWS();
– Hebert Lima
@Maniero unfortunately I was "forced" by shared hosting
– Leonardo Bonetti
@Hebertlima I will test
– Leonardo Bonetti
@Hebertlima how I would apply this in a subquery?
– Leonardo Bonetti
I will explain in response
– Hebert Lima
@Hebertlima I will update the question with the query I was doing ok?
– Leonardo Bonetti
@Leonardobonetti blz
– Hebert Lima
@Hebertlima ready, decreases it to become more legible, anyway if you can explain to me how it would be in my subquery will help a lot , while this I go searching more about these clauses
– Leonardo Bonetti