Tengo las siguientes consultas MySql que estoy tratando de optimizar, pero no lo he logrado.
Alguno de ustedes puede sugerirme alguna manera de lograrlo?
English:
Hi.
I have the following MySql queries that I am trying to optimize, but I have not succeeded.
Can any of you suggest some way to achieve it?
- Code: Select all Expand view RUN
- //Tarda 3 min para 60 Mil registros (demasiado tiempo)
//This query takes 3 minutes on a table with 60,000 records. Too much time.
SELECT a.codicont, a.nombre
FROM facturas a
WHERE NOT EXISTS ( SELECT b.codicont FROM catalogo b
WHERE b.codicont = a.codicont ) ;
//Esta tarda 3 min para 60 Mil registros (demasiado tiempo)
//This query takes 3 minutes on a table with 60,000 records. Too much time.
SELECT codicont, nombre
FROM facturas
WHERE codicont NOT IN (SELECT codicont FROM catalogo) ;
//Esta tarda 5 min para 60 Mil registros (demasiado tiempo)
//This query takes 5 minutes on a table with 60,000 records. Too much time.
SELECT t1.codicont, t1.nombre
FROM facturas t1
LEFT JOIN catalogo t2
ON t2.codicont = t1.codicont
WHERE t2.codicont IS NULL ;
//Esta se toma3 segundos, pero trae todos los datos, y solo queremos los nulos. (los que no existen en tabla catalogo)
//This query takes 3 seconds on a table with 60,000 records, but we wants null records only.
SELECT A.codicont AS codigo, A.nombre AS nombre, B.codicont AS catalogo
FROM facturas A LEFT JOIN catalogo B
ON A.codicont = B.codicont ;
Pueden ayudar?
Can help?
Saludos.
Best regards.