Home > database > Consult the SQL execution efficiency
Consult the SQL execution efficiency
Time:10-01
1: SQL execution time of 0.826 seconds SELECT Tenant_id, O2o_user_id The FROM Crm_point_sync_i2o WHERE sync_status=0 AND next_execute_time & lt; NOW () AND tenant_id IN (SELECT Tenant_id The FROM Crm_config WHERE is_enable=1 AND is_sync=1) The ORDER BY try_times ASC, Update_time DESC LIMIT 1000;
SQL2, on the basis of sql1 remove the sort, by rights, should be faster ah, how slow so much: the execution time of 2.212 seconds SELECT Tenant_id, O2o_user_id The FROM Crm_point_sync_i2o WHERE sync_status=0 AND next_execute_time & lt; NOW () AND tenant_id IN (SELECT Tenant_id The FROM Crm_config WHERE is_enable=1 AND is_sync=1) LIMIT of 1000
Execution plan is as follows:
CodePudding user response:
Have a LIMIT of 1000; This changed the data sequence, so do not add the ORDER BY not necessarily fast