hibernate多表关联导致CPU飙升

【 TiDB 使用环境】生产环境
【 TiDB 版本】V4.0.16
【复现路径】多表关联SQL执行

SELECT this_.ID AS ID1_879_8_, this_.AT_EMPLOYEE_IDS AS AT2_879_8_, this_.CC_EMPLOYEE_IDS AS CC3_879_8_, this_.CREATE_DATE AS CREATE4_879_8_, this_.CREATE_NAME AS CREATE5_879_8_
	, this_.CURRENT_DETAIL_ID AS CURRENT6_879_8_, this_.CURRENT_EX_STEP AS CURRENT7_879_8_, this_.CURRENT_INDEX AS CURRENT8_879_8_, this_.EFFECT_TIME AS EFFECT9_879_8_, this_.EMPLOYEEID AS EMPLOYE10_879_8_
	, this_.END_DATE AS END11_879_8_, this_.ENTITY_ID AS ENTITY12_879_8_, this_.EX_CC_EMPLOYEE_IDS AS EX13_879_8_, this_.EXPECT_CURRENT_EMPLOYEE_ID AS EXPECT14_879_8_, this_.FIRST_DETAIL_ID AS FIRST15_879_8_
	, this_.JOB_RECORD_ID AS JOB16_879_8_, this_.MEMO AS MEMO17_879_8_, this_.NAME AS NAME18_879_8_, this_.NEXT_EMPLOYEE_IDS AS NEXT19_879_8_, this_.NEXT_EX_STEP AS NEXT20_879_8_
	, this_.NEXT_INDEX AS NEXT21_879_8_, this_.NEXT_RELATION AS NEXT22_879_8_, this_.PROCESS_EMPLOYEE_IDS AS PROCESS23_879_8_, this_.RECORD_SEQ AS RECORD24_879_8_, this_.STATUS AS STATUS25_879_8_
	, this_.UPDATE_DATE AS UPDATE26_879_8_, this_.UPDATE_NAME AS UPDATE27_879_8_, this_.WORKFLOW_ID AS WORKFLO29_879_8_, this_.WORKFLOW_EX_RELATIONS AS WORKFLO28_879_8_, erpemploye3_.ID AS ID1_209_0_
	, erpemploye3_.BANK_CARD AS BANK5_209_0_, erpemploye3_.BANK_CARD_ADDR AS BANK6_209_0_, erpemploye3_.BANK_CARD_OWNER AS BANK7_209_0_, erpemploye3_.BANK_NAME AS BANK8_209_0_, erpemploye3_.BIRTH AS BIRTH9_209_0_
	, erpemploye3_.BLACKLIST_STATUS AS BLACKLI10_209_0_, erpemploye3_.COLOR_TEST_RESULT AS COLOR11_209_0_, erpemploye3_.COLOR_TEST_RESULT_DATE AS COLOR12_209_0_, erpemploye3_.CRT_DATE AS CRT13_209_0_, erpemploye3_.DEGREE AS DEGREE14_209_0_
	, erpemploye3_.DELAY_REASON AS DELAY15_209_0_, erpemploye3_.DEPART_REGION AS DEPART16_209_0_, erpemploye3_.DEPOSIT_BANK AS DEPOSIT17_209_0_, erpemploye3_.EDUCATION AS EDUCATI18_209_0_, erpemploye3_.EMAIL AS EMAIL19_209_0_
	, erpemploye3_.EMPLOYEE_ID AS EMPLOYEE2_209_0_, erpemploye3_.EMPLOYEE_TYPE AS EMPLOYE20_209_0_, erpemploye3_.ENTRY_TYPE AS ENTRY21_209_0_, erpemploye3_.GRADUATE_SCHOOL AS GRADUAT22_209_0_, erpemploye3_.GRADUATE_TIME AS GRADUAT23_209_0_
	, erpemploye3_.HAS_EXTRA_SUBSIDY AS HAS24_209_0_, erpemploye3_.HAS_RELATIVES_IN_WORK AS HAS25_209_0_, erpemploye3_.HEALTH_CERT_BEGIN AS HEALTH26_209_0_, erpemploye3_.HEALTH_CERT_END AS HEALTH27_209_0_, erpemploye3_.HEALTH_CERT_FEE AS HEALTH28_209_0_
	, erpemploye3_.HEALTH_CERT_NO AS HEALTH29_209_0_, erpemploye3_.HEIGHT AS HEIGHT30_209_0_, erpemploye3_.HOBBY AS HOBBY31_209_0_, erpemploye3_.HOME_ADDR AS HOME32_209_0_, erpemploye3_.ID_ADDR AS ID33_209_0_
	, erpemploye3_.ID_AUTH_ORG AS ID34_209_0_, erpemploye3_.ID_CAT AS ID35_209_0_, erpemploye3_.ID_NUM AS ID36_209_0_, erpemploye3_.ID_VALID_BEGIN AS ID37_209_0_, erpemploye3_.ID_VALID_END AS ID38_209_0_
	, erpemploye3_.INTRODUCER_DPT_ID AS INTRODU39_209_0_, erpemploye3_.INTRODUCER_DPT_NAME AS INTRODU40_209_0_, erpemploye3_.INTRODUCER_ID AS INTRODU41_209_0_, erpemploye3_.INTRODUCER_NAME AS INTRODU42_209_0_, erpemploye3_.IS_PROBATION AS IS43_209_0_
	, erpemploye3_.LABOR_CONTRACT_BEGIN AS LABOR44_209_0_, erpemploye3_.LABOR_CONTRACT_END AS LABOR45_209_0_, erpemploye3_.LAST_ENTRY_DATE AS LAST46_209_0_, erpemploye3_.LAST_JOB_REC_ID AS LAST47_209_0_, erpemploye3_.LAST_LEAVE_DATE AS LAST48_209_0_
	, erpemploye3_.LAST_WORK_REC_ID AS LAST49_209_0_, erpemploye3_.LEGAL_PERSON_TYPE AS LEGAL50_209_0_, erpemploye3_.LOGICAL_TEST_RESULT AS LOGICAL51_209_0_, erpemploye3_.LOGICAL_TEST_RESULT_DATE AS LOGICAL52_209_0_, erpemploye3_.MARRY_STATUS AS MARRY53_209_0_
	, erpemploye3_.MOST_IMPRESSIVE_THING AS MOST54_209_0_, erpemploye3_.NAME AS NAME3_209_0_, erpemploye3_.NATIONALITY AS NATIONA55_209_0_, erpemploye3_.NATIVE_PLACE AS NATIVE56_209_0_, erpemploye3_.NO_PAYROLL AS NO57_209_0_
	, erpemploye3_.ONDUTY_TAG AS ONDUTY58_209_0_, erpemploye3_.PERFORMANCE_CYCLE AS PERFORM59_209_0_, erpemploye3_.PHONE AS PHONE60_209_0_, erpemploye3_.POLITICAL_STATUS AS POLITIC61_209_0_, erpemploye3_.PROBATION_END_DATE AS PROBATI62_209_0_
	, erpemploye3_.PROBATION_FLAG AS PROBATI63_209_0_, erpemploye3_.REL_PEOPLE_NAME AS REL64_209_0_, erpemploye3_.REL_PEOPLE_PHONE AS REL65_209_0_, erpemploye3_.REL_PEOPLE_TYPE AS REL66_209_0_, erpemploye3_.RELATIVES_EMPLOYEE_ID AS RELATIV67_209_0_
	, erpemploye3_.RELATIVES_PHONE_NUM AS RELATIV68_209_0_, erpemploye3_.RELATIVES_RELATION AS RELATIV69_209_0_, erpemploye3_.REPORT_TO AS REPORT70_209_0_, erpemploye3_.REST_PER_MONTH AS REST71_209_0_, erpemploye3_.SENIOR_MODE AS SENIOR72_209_0_
	, erpemploye3_.SERVING_DURATION AS SERVING73_209_0_, erpemploye3_.SEX AS SEX74_209_0_, erpemploye3_.SORT AS SORT75_209_0_, erpemploye3_.SPECIALTY AS SPECIAL76_209_0_, erpemploye3_.STATUS AS STATUS4_209_0_
	, erpemploye3_.UPDATE_DATE AS UPDATE77_209_0_, erpemploye3_.WORK_TIMES AS WORK78_209_0_, erpjobreco4_.ID AS ID1_368_1_, erpjobreco4_.ACCUMULATION_FUND AS ACCUMULA2_368_1_, erpjobreco4_.ACTION_TYPE AS ACTION3_368_1_
	, erpjobreco4_.BEGIN_TIME AS BEGIN4_368_1_, erpjobreco4_.BIG_MEDICAL AS BIG5_368_1_, erpjobreco4_.CITY AS CITY6_368_1_, erpjobreco4_.CITY_TYPE AS CITY7_368_1_, erpjobreco4_.CONTRACT_BEGIN_DATE AS CONTRACT8_368_1_
	, erpjobreco4_.CONTRACT_END_DATE AS CONTRACT9_368_1_, erpjobreco4_.CREATE_BY AS CREATE10_368_1_, erpjobreco4_.CREATE_DATE AS CREATE11_368_1_, erpjobreco4_.CREATE_NAME AS CREATE12_368_1_, erpjobreco4_.DEL_FLAG AS DEL13_368_1_
	, erpjobreco4_.DPT_ID AS DPT15_368_1_, erpjobreco4_.DIRECT_SUPERIOR_EVALUATION AS DIRECT14_368_1_, erpjobreco4_.DUTY_BONUS AS DUTY16_368_1_, erpjobreco4_.DUTY_SUBSIDY AS DUTY17_368_1_, erpjobreco4_.EDITABLE AS EDITABL18_368_1_
	, erpjobreco4_.EMPLOYEE_ID AS EMPLOYE19_368_1_, erpjobreco4_.EMPLOYMENT_SUBJECT AS EMPLOYM20_368_1_, erpjobreco4_.END_TIME AS END21_368_1_, erpjobreco4_.ENTRY_FLAG AS ENTRY22_368_1_, erpjobreco4_.EXTRA_BIG_MEDICAL AS EXTRA23_368_1_
	, erpjobreco4_.EXTRA_CHILD_EDUCATION AS EXTRA24_368_1_, erpjobreco4_.EXTRA_CONTINUING_EDUCATION AS EXTRA25_368_1_, erpjobreco4_.EXTRA_HOUSING_LOAN AS EXTRA26_368_1_, erpjobreco4_.EXTRA_HOUSING_RENT AS EXTRA27_368_1_, erpjobreco4_.EXTRA_SUPPORT_ELDERLY AS EXTRA28_368_1_
	, erpjobreco4_.FIXED_OVERTIME_SALARY AS FIXED29_368_1_, erpjobreco4_.JOB_ID AS JOB30_368_1_, erpjobreco4_.LEAVE_DESCRIPTION AS LEAVE31_368_1_, erpjobreco4_.LEAVE_FLAG AS LEAVE32_368_1_, erpjobreco4_.LEAVE_PARENT_TYPE AS LEAVE33_368_1_
	, erpjobreco4_.LEAVE_REASON AS LEAVE34_368_1_, erpjobreco4_.LEAVE_TYPE AS LEAVE35_368_1_, erpjobreco4_.LEVEL AS LEVEL36_368_1_, erpjobreco4_.MEDICAL AS MEDICAL37_368_1_, erpjobreco4_.PENSION AS PENSION38_368_1_
	, erpjobreco4_.PERFORM_SUBSIDY1 AS PERFORM39_368_1_, erpjobreco4_.PERFORM_SUBSIDY2 AS PERFORM40_368_1_, erpjobreco4_.REASON AS REASON41_368_1_, erpjobreco4_.SALARY AS SALARY42_368_1_, erpjobreco4_.SALARY_GRADE AS SALARY43_368_1_
	, erpjobreco4_.SALARY_TYPE AS SALARY44_368_1_, erpjobreco4_.SEQUENCE_ID AS SEQUENC45_368_1_, erpjobreco4_.SOCIAL_SECURITY_SUBSIDY1_RADIX AS SOCIAL46_368_1_, erpjobreco4_.SOCIAL_SECURITY_SUBSIDY2_RADIX AS SOCIAL47_368_1_, erpjobreco4_.SOURCE_FLAG AS SOURCE48_368_1_
	, erpjobreco4_.TOTAL_SOCIAL_SECURITY AS TOTAL49_368_1_, erpjobreco4_.UNEMPLOYMENT AS UNEMPLO50_368_1_, erpjobreco4_.UPDATE_BY AS UPDATE51_368_1_, erpjobreco4_.UPDATE_DATE AS UPDATE52_368_1_, erpjobreco4_.UPDATE_NAME AS UPDATE53_368_1_
	, erpjobreco5_.ID AS ID1_368_2_, erpjobreco5_.ACCUMULATION_FUND AS ACCUMULA2_368_2_, erpjobreco5_.ACTION_TYPE AS ACTION3_368_2_, erpjobreco5_.BEGIN_TIME AS BEGIN4_368_2_, erpjobreco5_.BIG_MEDICAL AS BIG5_368_2_
	, erpjobreco5_.CITY AS CITY6_368_2_, erpjobreco5_.CITY_TYPE AS CITY7_368_2_, erpjobreco5_.CONTRACT_BEGIN_DATE AS CONTRACT8_368_2_, erpjobreco5_.CONTRACT_END_DATE AS CONTRACT9_368_2_, erpjobreco5_.CREATE_BY AS CREATE10_368_2_
	, erpjobreco5_.CREATE_DATE AS CREATE11_368_2_, erpjobreco5_.CREATE_NAME AS CREATE12_368_2_, erpjobreco5_.DEL_FLAG AS DEL13_368_2_, erpjobreco5_.DPT_ID AS DPT15_368_2_, erpjobreco5_.DIRECT_SUPERIOR_EVALUATION AS DIRECT14_368_2_
	, erpjobreco5_.DUTY_BONUS AS DUTY16_368_2_, erpjobreco5_.DUTY_SUBSIDY AS DUTY17_368_2_, erpjobreco5_.EDITABLE AS EDITABL18_368_2_, erpjobreco5_.EMPLOYEE_ID AS EMPLOYE19_368_2_, erpjobreco5_.EMPLOYMENT_SUBJECT AS EMPLOYM20_368_2_
	, erpjobreco5_.END_TIME AS END21_368_2_, erpjobreco5_.ENTRY_FLAG AS ENTRY22_368_2_, erpjobreco5_.EXTRA_BIG_MEDICAL AS EXTRA23_368_2_, erpjobreco5_.EXTRA_CHILD_EDUCATION AS EXTRA24_368_2_, erpjobreco5_.EXTRA_CONTINUING_EDUCATION AS EXTRA25_368_2_
	, erpjobreco5_.EXTRA_HOUSING_LOAN AS EXTRA26_368_2_, erpjobreco5_.EXTRA_HOUSING_RENT AS EXTRA27_368_2_, erpjobreco5_.EXTRA_SUPPORT_ELDERLY AS EXTRA28_368_2_, erpjobreco5_.FIXED_OVERTIME_SALARY AS FIXED29_368_2_, erpjobreco5_.JOB_ID AS JOB30_368_2_
	, erpjobreco5_.LEAVE_DESCRIPTION AS LEAVE31_368_2_, erpjobreco5_.LEAVE_FLAG AS LEAVE32_368_2_, erpjobreco5_.LEAVE_PARENT_TYPE AS LEAVE33_368_2_, erpjobreco5_.LEAVE_REASON AS LEAVE34_368_2_, erpjobreco5_.LEAVE_TYPE AS LEAVE35_368_2_
	, erpjobreco5_.LEVEL AS LEVEL36_368_2_, erpjobreco5_.MEDICAL AS MEDICAL37_368_2_, erpjobreco5_.PENSION AS PENSION38_368_2_, erpjobreco5_.PERFORM_SUBSIDY1 AS PERFORM39_368_2_, erpjobreco5_.PERFORM_SUBSIDY2 AS PERFORM40_368_2_
	, erpjobreco5_.REASON AS REASON41_368_2_, erpjobreco5_.SALARY AS SALARY42_368_2_, erpjobreco5_.SALARY_GRADE AS SALARY43_368_2_, erpjobreco5_.SALARY_TYPE AS SALARY44_368_2_, erpjobreco5_.SEQUENCE_ID AS SEQUENC45_368_2_
	, erpjobreco5_.SOCIAL_SECURITY_SUBSIDY1_RADIX AS SOCIAL46_368_2_, erpjobreco5_.SOCIAL_SECURITY_SUBSIDY2_RADIX AS SOCIAL47_368_2_, erpjobreco5_.SOURCE_FLAG AS SOURCE48_368_2_, erpjobreco5_.TOTAL_SOCIAL_SECURITY AS TOTAL49_368_2_, erpjobreco5_.UNEMPLOYMENT AS UNEMPLO50_368_2_
	, erpjobreco5_.UPDATE_BY AS UPDATE51_368_2_, erpjobreco5_.UPDATE_DATE AS UPDATE52_368_2_, erpjobreco5_.UPDATE_NAME AS UPDATE53_368_2_, erpemploye6_.ID AS ID1_209_3_, erpemploye6_.BANK_CARD AS BANK5_209_3_
	, erpemploye6_.BANK_CARD_ADDR AS BANK6_209_3_, erpemploye6_.BANK_CARD_OWNER AS BANK7_209_3_, erpemploye6_.BANK_NAME AS BANK8_209_3_, erpemploye6_.BIRTH AS BIRTH9_209_3_, erpemploye6_.BLACKLIST_STATUS AS BLACKLI10_209_3_
	, erpemploye6_.COLOR_TEST_RESULT AS COLOR11_209_3_, erpemploye6_.COLOR_TEST_RESULT_DATE AS COLOR12_209_3_, erpemploye6_.CRT_DATE AS CRT13_209_3_, erpemploye6_.DEGREE AS DEGREE14_209_3_, erpemploye6_.DELAY_REASON AS DELAY15_209_3_
	, erpemploye6_.DEPART_REGION AS DEPART16_209_3_, erpemploye6_.DEPOSIT_BANK AS DEPOSIT17_209_3_, erpemploye6_.EDUCATION AS EDUCATI18_209_3_, erpemploye6_.EMAIL AS EMAIL19_209_3_, erpemploye6_.EMPLOYEE_ID AS EMPLOYEE2_209_3_
	, erpemploye6_.EMPLOYEE_TYPE AS EMPLOYE20_209_3_, erpemploye6_.ENTRY_TYPE AS ENTRY21_209_3_, erpemploye6_.GRADUATE_SCHOOL AS GRADUAT22_209_3_, erpemploye6_.GRADUATE_TIME AS GRADUAT23_209_3_, erpemploye6_.HAS_EXTRA_SUBSIDY AS HAS24_209_3_
	, erpemploye6_.HAS_RELATIVES_IN_WORK AS HAS25_209_3_, erpemploye6_.HEALTH_CERT_BEGIN AS HEALTH26_209_3_, erpemploye6_.HEALTH_CERT_END AS HEALTH27_209_3_, erpemploye6_.HEALTH_CERT_FEE AS HEALTH28_209_3_, erpemploye6_.HEALTH_CERT_NO AS HEALTH29_209_3_
	, erpemploye6_.HEIGHT AS HEIGHT30_209_3_, erpemploye6_.HOBBY AS HOBBY31_209_3_, erpemploye6_.HOME_ADDR AS HOME32_209_3_, erpemploye6_.ID_ADDR AS ID33_209_3_, erpemploye6_.ID_AUTH_ORG AS ID34_209_3_
	, erpemploye6_.ID_CAT AS ID35_209_3_, erpemploye6_.ID_NUM AS ID36_209_3_, erpemploye6_.ID_VALID_BEGIN AS ID37_209_3_, erpemploye6_.ID_VALID_END AS ID38_209_3_, erpemploye6_.INTRODUCER_DPT_ID AS INTRODU39_209_3_
	, erpemploye6_.INTRODUCER_DPT_NAME AS INTRODU40_209_3_, erpemploye6_.INTRODUCER_ID AS INTRODU41_209_3_, erpemploye6_.INTRODUCER_NAME AS INTRODU42_209_3_, erpemploye6_.IS_PROBATION AS IS43_209_3_, erpemploye6_.LABOR_CONTRACT_BEGIN AS LABOR44_209_3_
	, erpemploye6_.LABOR_CONTRACT_END AS LABOR45_209_3_, erpemploye6_.LAST_ENTRY_DATE AS LAST46_209_3_, erpemploye6_.LAST_JOB_REC_ID AS LAST47_209_3_, erpemploye6_.LAST_LEAVE_DATE AS LAST48_209_3_, erpemploye6_.LAST_WORK_REC_ID AS LAST49_209_3_
	, erpemploye6_.LEGAL_PERSON_TYPE AS LEGAL50_209_3_, erpemploye6_.LOGICAL_TEST_RESULT AS LOGICAL51_209_3_, erpemploye6_.LOGICAL_TEST_RESULT_DATE AS LOGICAL52_209_3_, erpemploye6_.MARRY_STATUS AS MARRY53_209_3_, erpemploye6_.MOST_IMPRESSIVE_THING AS MOST54_209_3_
	, erpemploye6_.NAME AS NAME3_209_3_, erpemploye6_.NATIONALITY AS NATIONA55_209_3_, erpemploye6_.NATIVE_PLACE AS NATIVE56_209_3_, erpemploye6_.NO_PAYROLL AS NO57_209_3_, erpemploye6_.ONDUTY_TAG AS ONDUTY58_209_3_
	, erpemploye6_.PERFORMANCE_CYCLE AS PERFORM59_209_3_, erpemploye6_.PHONE AS PHONE60_209_3_, erpemploye6_.POLITICAL_STATUS AS POLITIC61_209_3_, erpemploye6_.PROBATION_END_DATE AS PROBATI62_209_3_, erpemploye6_.PROBATION_FLAG AS PROBATI63_209_3_
	, erpemploye6_.REL_PEOPLE_NAME AS REL64_209_3_, erpemploye6_.REL_PEOPLE_PHONE AS REL65_209_3_, erpemploye6_.REL_PEOPLE_TYPE AS REL66_209_3_, erpemploye6_.RELATIVES_EMPLOYEE_ID AS RELATIV67_209_3_, erpemploye6_.RELATIVES_PHONE_NUM AS RELATIV68_209_3_
	, erpemploye6_.RELATIVES_RELATION AS RELATIV69_209_3_, erpemploye6_.REPORT_TO AS REPORT70_209_3_, erpemploye6_.REST_PER_MONTH AS REST71_209_3_, erpemploye6_.SENIOR_MODE AS SENIOR72_209_3_, erpemploye6_.SERVING_DURATION AS SERVING73_209_3_
	, erpemploye6_.SEX AS SEX74_209_3_, erpemploye6_.SORT AS SORT75_209_3_, erpemploye6_.SPECIALTY AS SPECIAL76_209_3_, erpemploye6_.STATUS AS STATUS4_209_3_, erpemploye6_.UPDATE_DATE AS UPDATE77_209_3_
	, erpemploye6_.WORK_TIMES AS WORK78_209_3_, erpjobreco7_.ID AS ID1_368_4_, erpjobreco7_.ACCUMULATION_FUND AS ACCUMULA2_368_4_, erpjobreco7_.ACTION_TYPE AS ACTION3_368_4_, erpjobreco7_.BEGIN_TIME AS BEGIN4_368_4_
	, erpjobreco7_.BIG_MEDICAL AS BIG5_368_4_, erpjobreco7_.CITY AS CITY6_368_4_, erpjobreco7_.CITY_TYPE AS CITY7_368_4_, erpjobreco7_.CONTRACT_BEGIN_DATE AS CONTRACT8_368_4_, erpjobreco7_.CONTRACT_END_DATE AS CONTRACT9_368_4_
	, erpjobreco7_.CREATE_BY AS CREATE10_368_4_, erpjobreco7_.CREATE_DATE AS CREATE11_368_4_, erpjobreco7_.CREATE_NAME AS CREATE12_368_4_, erpjobreco7_.DEL_FLAG AS DEL13_368_4_, erpjobreco7_.DPT_ID AS DPT15_368_4_
	, erpjobreco7_.DIRECT_SUPERIOR_EVALUATION AS DIRECT14_368_4_, erpjobreco7_.DUTY_BONUS AS DUTY16_368_4_, erpjobreco7_.DUTY_SUBSIDY AS DUTY17_368_4_, erpjobreco7_.EDITABLE AS EDITABL18_368_4_, erpjobreco7_.EMPLOYEE_ID AS EMPLOYE19_368_4_
	, erpjobreco7_.EMPLOYMENT_SUBJECT AS EMPLOYM20_368_4_, erpjobreco7_.END_TIME AS END21_368_4_, erpjobreco7_.ENTRY_FLAG AS ENTRY22_368_4_, erpjobreco7_.EXTRA_BIG_MEDICAL AS EXTRA23_368_4_, erpjobreco7_.EXTRA_CHILD_EDUCATION AS EXTRA24_368_4_
	, erpjobreco7_.EXTRA_CONTINUING_EDUCATION AS EXTRA25_368_4_, erpjobreco7_.EXTRA_HOUSING_LOAN AS EXTRA26_368_4_, erpjobreco7_.EXTRA_HOUSING_RENT AS EXTRA27_368_4_, erpjobreco7_.EXTRA_SUPPORT_ELDERLY AS EXTRA28_368_4_, erpjobreco7_.FIXED_OVERTIME_SALARY AS FIXED29_368_4_
	, erpjobreco7_.JOB_ID AS JOB30_368_4_, erpjobreco7_.LEAVE_DESCRIPTION AS LEAVE31_368_4_, erpjobreco7_.LEAVE_FLAG AS LEAVE32_368_4_, erpjobreco7_.LEAVE_PARENT_TYPE AS LEAVE33_368_4_, erpjobreco7_.LEAVE_REASON AS LEAVE34_368_4_
	, erpjobreco7_.LEAVE_TYPE AS LEAVE35_368_4_, erpjobreco7_.LEVEL AS LEVEL36_368_4_, erpjobreco7_.MEDICAL AS MEDICAL37_368_4_, erpjobreco7_.PENSION AS PENSION38_368_4_, erpjobreco7_.PERFORM_SUBSIDY1 AS PERFORM39_368_4_
	, erpjobreco7_.PERFORM_SUBSIDY2 AS PERFORM40_368_4_, erpjobreco7_.REASON AS REASON41_368_4_, erpjobreco7_.SALARY AS SALARY42_368_4_, erpjobreco7_.SALARY_GRADE AS SALARY43_368_4_, erpjobreco7_.SALARY_TYPE AS SALARY44_368_4_
	, erpjobreco7_.SEQUENCE_ID AS SEQUENC45_368_4_, erpjobreco7_.SOCIAL_SECURITY_SUBSIDY1_RADIX AS SOCIAL46_368_4_, erpjobreco7_.SOCIAL_SECURITY_SUBSIDY2_RADIX AS SOCIAL47_368_4_, erpjobreco7_.SOURCE_FLAG AS SOURCE48_368_4_, erpjobreco7_.TOTAL_SOCIAL_SECURITY AS TOTAL49_368_4_
	, erpjobreco7_.UNEMPLOYMENT AS UNEMPLO50_368_4_, erpjobreco7_.UPDATE_BY AS UPDATE51_368_4_, erpjobreco7_.UPDATE_DATE AS UPDATE52_368_4_, erpjobreco7_.UPDATE_NAME AS UPDATE53_368_4_, tsdepart8_.ID AS ID1_896_5_
	, tsdepart8_.parentdepartid AS parentd22_896_5_, tsdepart8_.acct_no AS acct2_896_5_, tsdepart8_.AREA AS AREA3_896_5_, tsdepart8_.check_dept_no AS check4_896_5_, tsdepart8_.CITY AS CITY5_896_5_
	, tsdepart8_.CLEANER_STAFFING AS CLEANER6_896_5_, tsdepart8_.CONTACT_EMPLOYEE_ID AS CONTACT7_896_5_, tsdepart8_.CREATE_DATE AS CREATE8_896_5_, tsdepart8_.DEL_FLAG AS DEL9_896_5_, tsdepart8_.departname AS departn10_896_5_
	, tsdepart8_.description AS descrip11_896_5_, tsdepart8_.FRANCHISEE_BOSS_ID AS FRANCHI12_896_5_, tsdepart8_.HEAD_EMPLOYEE_ID AS HEAD13_896_5_, tsdepart8_.IGNORE_HEALTH_CERT AS IGNORE14_896_5_, tsdepart8_.IS_BEAR AS IS15_896_5_
	, tsdepart8_.is_functional AS is16_896_5_, tsdepart8_.IS_REIMBURSE AS IS17_896_5_, tsdepart8_.kingdee_org_code AS kingdee18_896_5_, tsdepart8_.NO_ENTRY AS NO19_896_5_, tsdepart8_.org_code AS org20_896_5_
	, tsdepart8_.org_type AS org21_896_5_, tsdepart8_.PART_STAFFING AS PART23_896_5_, tsdepart8_.PARTNER_STAFFING AS PARTNER24_896_5_, tsdepart8_.PROVINCE AS PROVINC25_896_5_, tsdepart8_.SECURITY_STAFFING AS SECURIT26_896_5_
	, tsdepart8_.SORT AS SORT27_896_5_, tsdepart8_.STAFFING AS STAFFIN28_896_5_, tsdepart8_.STORE_ID AS STORE29_896_5_, tsdepart8_.UPDATE_DATE AS UPDATE30_896_5_, tsdepart8_.ZJB_YY_LEADER_ID AS ZJB31_896_5_
	, erpjobenti9_.ID AS ID1_364_6_, erpjobenti9_.APPROVE_LEVEL AS APPROVE2_364_6_, erpjobenti9_.CRT_DATE AS CRT3_364_6_, erpjobenti9_.DEL_FLAG AS DEL4_364_6_, erpjobenti9_.DUTY_BONUS AS DUTY5_364_6_
	, erpjobenti9_.DUTY_SUBSIDY AS DUTY6_364_6_, erpjobenti9_.GROUP_ID AS GROUP7_364_6_, erpjobenti9_.JOB_TITLE AS JOB8_364_6_, erpjobenti9_.LEVEL_MAX AS LEVEL9_364_6_, erpjobenti9_.LEVEL_MIN AS LEVEL10_364_6_
	, erpjobenti9_.MAX_MONTH_REST AS MAX11_364_6_, erpjobenti9_.NAME AS NAME12_364_6_, erpjobenti9_.PERIOD AS PERIOD13_364_6_, erpjobenti9_.SALARY AS SALARY14_364_6_, erpjobenti9_.SORT AS SORT15_364_6_
	, erpjobenti9_.UPDATE_DATE AS UPDATE16_364_6_, workflow1_.ID AS ID1_875_7_, workflow1_.APPROVAL_TILL_APPROVE_LEVEL AS APPROVAL2_875_7_, workflow1_.APPROVAL_TYPE AS APPROVAL3_875_7_, workflow1_.CC_DEPART_IDS AS CC4_875_7_
	, workflow1_.CC_EMPLOYEE_IDS AS CC5_875_7_, workflow1_.CC_ENTITY_DPT AS CC6_875_7_, workflow1_.CC_ENTITY_RELATIVE_RELATIONS AS CC7_875_7_, workflow1_.CC_JOB_WITH_DPT_IDS AS CC8_875_7_, workflow1_.CC_QYHSKJ AS CC9_875_7_
	, workflow1_.CC_RELATIVE_APPROVE_LEVELS AS CC10_875_7_, workflow1_.CC_SPONSOR_DPT AS CC11_875_7_, workflow1_.CODE AS CODE12_875_7_, workflow1_.CONDITION_ID AS CONDITI13_875_7_, workflow1_.CONDITIONS AS CONDITI14_875_7_
	, workflow1_.CREATE_DATE AS CREATE15_875_7_, workflow1_.CREATE_NAME AS CREATE16_875_7_, workflow1_.EMPLOYEE_CATE AS EMPLOYE17_875_7_, workflow1_.EX_DPT_IDS AS EX18_875_7_, workflow1_.EX_EMPLOYEE_IDS AS EX19_875_7_
	, workflow1_.EX_JOB_WITH_DPT_IDS AS EX20_875_7_, workflow1_.EX_RELATION_TYPES AS EX21_875_7_, workflow1_.EX_RELATIONS AS EX22_875_7_, workflow1_.MATCH_KEYWORD AS MATCH23_875_7_, workflow1_.MEMO AS MEMO24_875_7_
	, workflow1_.NAME AS NAME25_875_7_, workflow1_.SORT AS SORT26_875_7_, workflow1_.STATUS AS STATUS27_875_7_, workflow1_.TABLE_NAME AS TABLE28_875_7_, workflow1_.UPDATE_DATE AS UPDATE29_875_7_
	, workflow1_.UPDATE_NAME AS UPDATE30_875_7_
FROM simple_workflow_record this_
	LEFT JOIN erp_employee erpemploye3_ ON this_.EMPLOYEEID = erpemploye3_.ID
	LEFT JOIN erp_job_record erpjobreco4_ ON erpemploye3_.LAST_JOB_REC_ID = erpjobreco4_.ID
	LEFT JOIN erp_job_record erpjobreco5_ ON erpemploye3_.LAST_WORK_REC_ID = erpjobreco5_.ID
	LEFT JOIN erp_employee erpemploye6_ ON erpemploye3_.RELATIVES_EMPLOYEE_ID = erpemploye6_.ID
	LEFT JOIN erp_job_record erpjobreco7_ ON this_.JOB_RECORD_ID = erpjobreco7_.ID
	LEFT JOIN t_s_depart tsdepart8_ ON erpjobreco7_.DPT_ID = tsdepart8_.ID
	LEFT JOIN erp_job erpjobenti9_ ON erpjobreco7_.JOB_ID = erpjobenti9_.ID
	INNER JOIN simple_workflow workflow1_ ON this_.WORKFLOW_ID = workflow1_.ID
WHERE 
	workflow1_.MATCH_KEYWORD <>  ?
ORDER BY this_.UPDATE_DATE DESC, this_.CREATE_DATE DESC, this_.CREATE_DATE desc, this_.id desc
LIMIT 20;

【遇到的问题:问题现象及影响】 多表关联查询多次,导致CPU飙升,系统整体卡顿。单次SQL耗时19s
【资源配置】 均为500G/ 16核 / 32g
【附件:截图/日志/监控】

单表数据量都不大,都是几十w级别的。但是整体执行耗时19s左右。想知道:
集群服务器CPU飙升是否真的是由这种SQL造成, 如何鉴定

可以看看dashboard的top sql,看看里面使用资源最多的是不是这个sql

orm注定是一个失败的设计,生成的sql性能不可控,对db的优化需要开发同时熟悉orm中间件和对应的db特性,这就无限抬高了维护成本。

我很好奇这种已经被历史证明应该被扫进垃圾堆的东西,最近为啥又流行起来了?

我怀疑是上一代被orm坑过的研发都35+被优化掉了。于是历史开启了新一轮的循环。 :joy:

至于你这个问题,我觉得你直接看一下执行计划,应该就有结论。

一堆外关联还来个

WHERE 
	workflow1_.MATCH_KEYWORD <>  ?

看着都令人窒息。
也许有一定的概率这个sql并不是cpu飙升的真正原因,那这个sql起码也是一个需要优化,或者需要深入了解一下为什么要这么做的sql。

2 个赞

历史遗留代码了吧,这么老的db版本和框架,4.x还没top sql功能,所以上面写top sql的就用不上了,看看slow log 看看都有哪些慢查询,这条语句本身看不出啥问题来,看看执行计划,表不大的话把索引建上

看执行计划吧,或者查看日志 搜关键字 expensive

执行计划:TiFlash是后面建的,之前走的tikv,基本无影响。

Result_8.html (22.8 KB)

看执行计划优化SQL,按理来说,19s对大SQL也不算慢,这个是不是执行很频繁

最好升级下版本吧

已经不能算上个时代了,hibernate版本还是4,加上jsp里的级联引用,根本改不完,也不敢动

1 个赞

你好,帮忙看下,我找的位置对不。 这里rpc_time用了这么久,对应的是 关联表_this吗?那为啥这个表的rpc_time这么突出?

正在计划中。。

监控看100,101这两台高,估计这两台是tidb节点吧。你这个sql根本没办法下推tikv。大体的执行逻辑就是,tikv全表数据全部扫描出来提交给tidb节点,然后进行hash-join的join算法,排序获取数据。除非改代码,改表结构实现字段冗余,垂直扩容tidb节点。
tiflash问题的应该是版本太老了,mpp特性是5之后才有的,升级下版本把。 :joy:

1 个赞

这个sql肯定会卡,where条件太少,尽量多加where筛选条件把算子下推到tikv,否则几十万一张表,一大堆数据全都读到tidb再做jion加排序,慢死了

看看执行计划

image

其实我已经通过较少关联+强制校验条件 的方式改写,解决了这个问题。后续还是先升级,然后再系统解决这种问题,感谢

此话题已在最后回复的 60 天后被自动关闭。不再允许新回复。