select up.UP_NAME as printName,count(1) as qty from riv_print_history_l phl JOIN tab_user_profile up on up.UP_USER_ID = phl.PHL_PRINT_USER_ID where phl.CREATE_TIME >= '2017-00-15 00:00:00' and phl.CREATE_TIME < '2017-09-21 00:00:00' GROUP BY phl.PHL_PRINT_USER_ID; select (select UP_NAME from tab_user_profile where UP_USER_ID = tab1.PHL_PRINT_USER_ID) as printName,tab1.qty from (select PHL_PRINT_USER_ID,count(1) as qty from riv_print_history_l where CREATE_TIME >= '2017-00-15 00:00:00' and CREATE_TIME < '2017-09-21 01:00:00' GROUP BY PHL_PRINT_USER_ID)tab1;
tab_user_profile 116行
riv_print_history_l 640746行
select PHL_PRINT_USER_ID,count(1) as qty from riv_print_history_l where CREATE_TIME >= '2017-00-15 00:00:00' and CREATE_TIME < '2017-09-21 01:00:00' GROUP BY PHL_PRINT_USER_ID
查出的结果只有3行
第一个用时10s,第二个用时0.6s