mysql - how do i improve cross join with 20,000 records? -
i have 2 tables: users (userid,student_no,name) , regd (semester,student_no). users contain 7,000 records , regd contains 20,000 records. there entries in regd not in users.
how quickly select entries in users have entries in regd semester = '2012-2'? tried this:
select * `regd` , users semester = '2012-2' , users.student_no = regd.student_no but taking forever load queries if have tiny database. every 6 months, 10,000 entries added regd , 2,500 entries added users each year.
add indexes on join columns:
create index idx_regd_student_no on regd(student_no); and
create index idx_users_student_no on users(student_no); also, if tables don't have pk, add one. in case of regd, can use pk = (semester, student_no).
as other comments say, 22k records not big, can assume without decent index.
hope helps.
Comments
Post a Comment