Optimize SELECT DISTINCT CONCAT query in MySQL

Posted by L. Cosio on Stack Overflow See other posts from Stack Overflow or by L. Cosio
Published on 2009-07-01T01:27:51Z Indexed on 2010/05/01 20:07 UTC
Read the original article Hit count: 153

Filed under:
|

Hello!

I'm running this query:

SELECT DISTINCT CONCAT(ALFA_CLAVE, FECHA_NACI) FROM listado GROUP BY ALFA_CLAVE HAVING count(CONCAT(ALFA_CLAVE, FECHA_NACI)) > 1

Is there any way to optimize it? Queries are taking 2-3 hours on a table with 850,000 rows.

Adding an index to ALFA_CLAVE and FECHA_NACI would work?

Thanks in advanced

© Stack Overflow or respective owner

Related posts about mysql

Related posts about optimization