HI,
i am doing explain for a query and getting different results every time, i run explain 5-6 times continuously and get two different output.
see below:
mysql> explain SELECT ID, MID, VIEWED, TYPE FROM MUSER WHERE ID > ? AND VIEWEDBYSIP <> 2 AND ATTRIBUTE !=‘DELETED’ and USERID = ? LIMIT 3\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: MUSER
type: ref
possible_keys: PRIMARY,muser_1
key: muser_1
key_len: 4
ref: const
rows: 271504
Extra: Using where
in next 10 seconds the same explain command showing different results
mysql> explain SELECT ID, MID, VIEWED, TYPE FROM MUSER WHERE ID > ? AND VIEWEDBYSIP <> 2 AND ATTRIBUTE !=‘DELETED’ and USERID = ? LIMIT 3\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: MUSER
type: index_merge
possible_keys: PRIMARY,muser_1
key: muser_1,PRIMARY
key_len: 4,4
ref: NULL
rows: 1504
Extra: Using intersect(muser_1,PRIMARY); Using where
1 row in set (0.03 sec)
the database is indexed on id and userid.
What the problem is, sometimes this query took 2-5 minute and sometimes it took few seconds.
can anybody explain why is this happening?
-Yogesh