mysql - Slow query when using ORDER BY and LIMIT -


i have slow query because using order by. understand why slow have no idea how make faster.

the table got 21.000 records. (the reason why slow)

select   id_registre,   section,   numero_naissance,   annee_naissance,   type,   prenom_fr,   nom_fr,   prenom_ar,   nom_ar,   date_naissance_equivalent,   date_redaction_equivalent registres order annee_naissance, numero_naissance limit 20010 , 30 

i use limit because use pagination.

this query takes 119 seconds, way long. if remove order clause, query takes 0.92 seconds.

i have indexe on annee_naissance, numero_naissance column.

the type of "annee_naissance" , "numero_naissance" columns int(11)

the best index query composite index on registres(annee_naissance, numero_naissance).

note both columns need in same index.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -