today, i checked my slow query log and saw lots of slow queries.
it’s looks like:
SELECT uid,uname FROM usertbl WHERE country=‘us’ ORDER BY lastlogin DESC LIMIT 0,20;
i INDEXED country field.
so should i index lastlogin field?
and one more question, should i use DISTINCT or GROUP BY to filter duplicate records?
r937
2
try it and see what happens
in general, yes
but ~not~ in this case!
if you are getting duplicates from the query that you posted, then you have some pretty serious issues
oddz
3
Assuming uid is the primary key and uname is unique you should not have duplicates.
i mean, DISTINCT and GROUP BY, which take more a lot of resources?
r937
5
it’s not a question of resources, it’s a question of why do you allow duplicates to occur in the first place?