I have three tables jcxx_device_check_log,sys_depart and jcxx_device_info
the jcxx_device_check_log contains 640000 data volume,
the sys_depart contains 260 data volume
the jcxx_device_info contains 840 data volume
the exists sql
EXPLAIN
format = Json
SELECT state,check_time,note,device_id,COUNT(1) FROM jcxx_device_check_log jc
WHERE exists (
SELECT jdi.id FROM sys_depart sd
INNER JOIN jcxx_device_info jdi on sd.id=jdi.sys_depart_id
where jc.device_id = jdi.id
) and check_time BETWEEN '2023-4-18 10:00:00' AND ' 2023-4-18 18:00:00'
GROUP BY device_id,state
ORDER BY device_id,state
the EXPLAIN format = Json results
"cost_info": { "query_cost": "453972.80" },
the in sql
EXPLAIN
format = Json
SELECT state,check_time,device_id,COUNT(1) FROM jcxx_device_check_log jc
WHERE device_id in (
SELECT jdi.id FROM sys_depart sd
INNER JOIN jcxx_device_info jdi on jdi.sys_depart_id=sd.id
) and check_time BETWEEN '2023-4-18 10:00:00' AND ' 2023-4-18 18:00:00'
GROUP BY device_id,state
ORDER BY device_id,state;
the EXPLAIN format = Json results
"cost_info": { "query_cost": "2025375.58" },
this is my guess
the result set of exists sql does not exist in the memory and only returns true and false.
this is my question
I want to know whether my guess is correct and how to choose a statement next time I encounter a large amount of data