Mysql
 sql >> Database >  >> RDS >> Mysql

Ottimizzazione di MySQL basata su spiegare

prova inner join invece di sub-queryè l'impostazione predefinita per guidare la query senza eseguire sui dati, ma potrebbe essere utile seguire la query.

SELEZIONA User .id , User .username , User .password , User .role , User .created , User .modified , User .email , User .other_user_id , User .first_name , User .last_name , User .place_id , Resume .id , Resume .user_id , Resume .other_resume_id , Resume .other_user_id , Resume .file_extension , Resume .created , Resume .modified , Resume .is_deleted , Resume .has_file , Resume .is_stamped , Resume .is_active

DAstreetofwalls .users AS User
LEFT UNISCITI a my_database .attempts AS Attempt ON (Attempt .user_id =User .id E Attempt .test_id !=5)SINISTRA UNISCITI a my_database .reports AS Resume ON (Resume .user_id =User .id )

, my_database .users COME Utente1

SINISTRA UNISCITI a my_database .tags_users AS TagUser acceso (User1 .id =TagUser .user_id )

SINISTRA UNISCITI a my_database .tags AS Tag ON (TagUser .tag_id =Tag .id )

DOVEUser .id =User1 .id E Attempt .test_id =8AND Attempt .score> 60
E Resume .has_file =1E Tag .id ='8' E Tag .id !='3'GRUPPO PER User .id ORDINA PER Attempt .score DEC;