Ok, je ne suis pas grand dans MySQL, mais je connais un index me aider ici, mais je l'ai fait un peu Enfichage et ne peut pas trouver un pour vous aider ...aide avec un indice
Quelqu'un a une idée?
explain
select `users_usr`.`id_usr` AS `id_usr`,
`users_usr`.`firstname_usr` AS `firstname_usr`,
`users_usr`.`lastname_usr` AS `lastname_usr`,`users_usr`.`social_usr` AS `social_usr`,`users_usr`.`address1_usr` AS `address1_usr`,
`users_usr`.`address2_usr` AS `address2_usr`,`users_usr`.`city_usr` AS `city_usr`,`users_usr`.`state_usr` AS `state_usr`,`users_usr`.`zip_usr` AS `zip_usr`,
`users_usr`.`email_usr` AS `email_usr`,`credit_acc`.`given_credit_acc` AS `given_credit_acc`,`credit_acc`.`credit_used_acc` AS `credit_used_acc`,
`credit_acc`.`date_established_acc` AS `date_established_acc`,`credit_acc`.`type_acc` AS `type_acc`,`credit_acc`.`bureau_status_acc` AS `bureau_status_acc`,
sum((`credit_balance`.`debit_acc` - `credit_balance`.`credit_acc`)) AS `balance`
from (((`users_usr`
left join `credit_acc` on((`users_usr`.`id_usr` = `credit_acc`.`uid_usr`)))
left join `cfc_cfc` on((`credit_acc`.`id_cfc` = `cfc_cfc`.`id_cfc`)))
join `credit_acc` `credit_balance` on((`credit_balance`.`credit_used_acc` = `credit_acc`.`id_acc`)))
where ((`credit_acc`.`type_acc` = _latin1'init')
and (`credit_acc`.`status_acc` = _latin1'active')
and (`credit_acc`.`linetype_acc` = _latin1'personal'))
group by `credit_balance`.`credit_used_acc` order by `users_usr`.`id_usr`
Ça me donne
id select_type table type possible_keys key key_len ref rows Extra
------ ----------- -------------- ------ ----------------------------------- --------------- ------- --------------------------------- ------ -------------------------------
1 SIMPLE credit_balance index credit_used_acc,cash_report_index credit_used_acc 40 (NULL) 14959 Using temporary; Using filesort
1 SIMPLE credit_acc eq_ref PRIMARY,type_acc,type_acc_2,uid_usr PRIMARY 8 cc.credit_balance.credit_used_acc 1 Using where
1 SIMPLE cfc_cfc eq_ref PRIMARY PRIMARY 4 cc.credit_acc.id_cfc 1 Using index
1 SIMPLE users_usr eq_ref PRIMARY,id_usr PRIMARY 4 cc.credit_acc.uid_usr 1
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
---------- ---------- ----------------- ------------ ----------------------- --------- ----------- -------- ------ ------ ---------- -------
credit_acc 0 PRIMARY 1 id_acc A 14016 (NULL) (NULL) BTREE
credit_acc 1 type_acc 1 type_acc A 11 (NULL) (NULL) YES BTREE
credit_acc 1 type_acc 2 date_acc A 14016 (NULL) (NULL) YES BTREE
credit_acc 1 type_acc 3 affiliate_aff A 14016 (NULL) (NULL) YES BTREE
credit_acc 1 type_acc_2 1 type_acc A 11 (NULL) (NULL) YES BTREE
credit_acc 1 type_acc_2 2 date_acc A 14016 (NULL) (NULL) YES BTREE
credit_acc 1 type_acc_2 3 complete_acc A 14016 (NULL) (NULL) YES BTREE
credit_acc 1 type_acc_2 4 commission_refunded_acc A 14016 (NULL) (NULL) YES BTREE
credit_acc 1 credit_used_acc 1 credit_used_acc A 14016 (NULL) (NULL) YES BTREE
credit_acc 1 credit_used_acc 2 id_acc A 14016 (NULL) (NULL) BTREE
credit_acc 1 credit_used_acc 3 type_acc A 14016 (NULL) (NULL) YES BTREE
credit_acc 1 uid_usr 1 uid_usr A 7008 (NULL) (NULL) YES BTREE
credit_acc 1 cash_report_index 1 credit_used_acc A 7008 (NULL) (NULL) YES BTREE
credit_acc 1 cash_report_index 2 type_acc A 14016 (NULL) (NULL) YES BTREE
credit_acc 1 cash_report_index 3 date_established_acc A 14016 (NULL) (NULL) YES BTREE
quoi avec la dernière jointure? Pas vu ça avant! – benlumley