I’m only a dabbler in databases – using them for backends for basic web applications, never anything enterprise.
I’ve recently needed to work with two tables – one with 130,000 rows and the other with 29,000 rows. They have similar data and I need to pull from them with some sort of JOIN statement. Unfortunately this seems to cause issues and the query sits and hangs.
The query is as follows:
SELECT *
FROM call_status LEFT JOIN queue_log
ON call_status.callId = queue_log.callid
ORDER BY call_status.callId DESC limit 10;
When checking the processlist, I see the following:
Query 643 Copying to tmp table SELECT * FROM call_status LEFT JOIN queue_log ON call_status.callId = queue_log.callid ORDER BY call
Yes, the query has been running for over 10 minutes.
I’ve run an explain and this it the output:
1 SIMPLE call_status ALL (null) (null) (null) (null) 28954 Using temporary; Using filesort
1 SIMPLE queue_log ALL ix_queue_log_callid (null) (null) (null) 130419
I’ve run a SHOW INDEX on both tables, both look fine to me:
call_status:
call_status 0 PRIMARY 1 callId A 28954 (null) (null) BTREE
call_status 0 ix_order_callId 1 callId A 28954 (null) (null) BTREE
queue_log:
queue_log 1 ix_queue_log_callid 1 callid A 26083 (null) (null) BTREE
I’m at a complete loss, and it’s 2am here.
Can you try this?: