I have query for a user export, there are about 6000 users in this particular modx database,
SELECT mg.user_group, mg.member, u.id, u.username, u.active, ua.fullname, ua.email, ua.phone, ua.mobilephone,
ua.blocked, ua.dob, ua.address, ua.country, ua.city, ua.state, ua.zip, ua.website, ua.extended,
GROUP_CONCAT(CONVERT(mg.user_group, CHAR(10)) ORDER BY mg.user_group SEPARATOR ',') AS groups
FROM modx_users u
LEFT JOIN modx_user_attributes ua ON u.id = ua.internalKey
LEFT JOIN modx_member_groups mg ON u.id = mg.member
GROUP BY u.id
It runs VERY slow, about 27 seconds, after a bit of digging around, I find that the member column in the modx_member_groups table is not indexed.
Adding an index to that column (member, member, Normal, BTREE) the query now takes under a second. Great! So that seems fine, but:
- are there any drawbacks or issues I may encounter after adding the index?
- will updates to modx remove the index?
- why isn't this field indexed in the first place? Seems like it should be!
-thanks
-sean