注册

相同的SQL不同版本的DM执行计划不一样

kady ,wang 2026/04/21 438 4

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本1】:DM Database Server 64 V8
DB Version: 0x7000d
03134284404-20250801-286012-20164
Msg Version: 49
Gsu level(5) cnt: 0
[操作系统1]: Linux
[CPU]: x86

[DM版本2]:
DM Database Server 64 V8
DB Version: 0x7000c
03134284194-20240621-232765-20108
Msg Version: 12
Gsu level(5) cnt: 0
【操作系统2】:Mac
【CPU】: Arm M5
【问题描述】*:同一句SQL在两个数据库上执行计划不同,查询性能差异大, DM版本1上执行 216ms ,DM版本2上执行7s

操作过统计信息:
DBMS_STATS.GATHER_TABLE_STATS('ICME', 'M_SCORES_DETAIL_HISTORY');
DBMS_STATS.GATHER_TABLE_STATS('ICME', 'M_STUDENTS');
DBMS_STATS.GATHER_TABLE_STATS('ICME', 'M_TITLES');
DBMS_STATS.GATHER_TABLE_STATS('ICME', 'M_JOB_GROUPS');
DBMS_STATS.GATHER_TABLE_STATS('ICME', 'M_STU_QUALIFIED_HISTORY');

SQL脚本:
select
count(*)
from
"m_scores_detail_history" mscoresdet0_
cross join "m_students" mstudents1_
cross join "m_titles" mtitles2_
cross join "m_job_groups" mjobgroups3_
where
mtitles2_."jobgroup_id" = mjobgroups3_."id"
and mscoresdet0_."student_id" = mstudents1_."id"
and (mstudents1_."institution_id" in (13, 4693, 4697, 4699, 4701, 4705, 4708, 4711, 4717, 4720, 4724, 4729, 4732, 4734, 4739, 4744, 4749, 4751, 4756, 4759, 4805, 4813, 4816, 4819, 4821, 4823, 4826, 4828, 4831, 4835, 4838, 4840, 4843, 4846, 4847, 4851, 4853, 4854, 4855, 4857, 4860, 4889, 4892, 4893, 4896, 4900, 4901, 4904, 4905, 4911, 4936, 4937, 4941, 4942, 4943, 4945, 4949, 4953, 4954, 4956, 4958, 4960, 4963, 4978, 4988, 4992, 4996, 5000, 5004, 5006, 5010, 5011, 5017, 5020, 5024, 4663, 4665, 4668, 4672, 4676, 4680, 4685, 4689, 3270, 3271, 3272, 3273, 3274, 3275, 3276, 3277, 3278, 3285, 3302, 3308, 3311, 3327, 3339, 3341, 3344, 3345, 3346, 3347, 3348, 3422, 3423, 3425, 3429, 3432, 3435, 3438, 3439, 3450, 3453, 3454, 3458, 3461, 3464, 3473, 3475, 3476, 3479, 3482, 3484, 3486, 3488, 3490, 3491, 3492, 3493, 3494, 3495, 3496, 3497, 3498, 3500, 3502, 3504, 3507, 3510, 3511, 3514, 3515, 3519, 3521, 3522, 3523, 3524, 3525, 3530, 3532, 3534, 3535, 3537, 3539, 3542, 3545, 3548, 3567, 3571, 3572, 3574, 3577, 3578, 3579, 3580, 3581, 3583, 3589, 3590, 3591, 3592, 3593, 3594, 3595, 3597, 3602, 3604, 3606, 3607, 3611, 3615, 3618, 3621, 3656, 3658, 3660, 3665, 3668, 3669, 3672, 3674, 3677, 1041, 1042, 1043, 1047, 1049, 1050, 1052, 1053, 3130, 3148, 3679, 3681, 3683, 3686, 3687, 3688, 3691, 3692, 3693, 3698, 3699, 3700, 3701, 3702, 3704, 3705, 3706, 3707, 3708, 3709, 3710, 3711, 3712, 3713, 3714, 3715, 3716, 3717, 3718, 3719, 3720, 3721, 3722, 3723, 3725, 3727, 3728, 3730, 3731, 3733, 3735, 3737, 3739, 3740, 3742, 3744, 3746, 3748, 3750, 3752, 3753, 3754, 3755, 3757, 3759, 3762, 3764, 3765, 3766, 3768, 3800, 3805, 3809, 3812, 3816, 3819, 3823, 3824, 3825, 3826, 3827, 3828, 3829, 3830, 1571, 1573, 1575, 1577, 1578, 1580, 1581, 1582, 1583, 1593, 1595, 1597, 1599, 1600, 1601, 1602, 1603, 1604, 1607, 1609, 1622, 1626, 1628, 1629, 1631, 1632, 1634, 1636, 1637, 1639, 1641, 1643, 1645, 1646, 1648, 1652, 1658, 1679, 1682, 1684, 1693, 1696, 1698, 1701, 1703, 1714, 1716, 1719, 1720, 1722, 1726, 1728, 1730, 1732, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1759, 1761, 1765, 1766, 1768, 1769, 1771, 1773, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1807, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1057, 1090, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1101, 1102, 1104, 1105, 1109, 1112, 1117, 1122, 1125, 1128, 1130, 1133, 1136, 1263, 1265, 1266, 1268, 1269, 1271, 1273, 1275, 1276, 1277, 1279, 1281, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1491, 1494, 1496, 1499, 1501, 1504, 1507, 1510, 1513, 1516, 1517, 1518, 1519, 1520, 1522, 1523, 1524, 1526, 1527, 1529, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1565, 1566, 1569, 8323, 8357, 8367, 8385, 8447, 8455, 8483, 8484, 8485, 8541, 8557, 8582, 8583, 8584, 8585, 8586, 8587, 8588, 8591, 8592, 9505, 9506, 9508, 9509, 9510, 9511, 9512, 9513, 9514, 9517, 9518, 9519, 9520, 9521, 9522, 9523, 9524, 9525, 9580, 9581, 9582, 9583, 9584, 9585, 9586, 9587, 9588, 9589, 9590, 9591, 9592, 9593, 9594, 9595, 9596, 9597, 9598, 9599, 9600, 9601, 9602, 9603, 9604, 9605, 9606, 9607, 9609, 9610, 9611, 9612, 9621, 9857, 9880, 9883, 9884, 9885, 9887, 9928, 9929, 9975, 9976, 9986, 9987, 10050, 10051, 10052, 10053, 10054, 10055, 10056, 10061, 10067, 10075, 10095, 10096, 10098, 10099, 10100, 10101, 10350, 10351, 10352, 10353, 10354, 10355, 10356, 10357, 10358, 10359, 10360, 10364, 10374, 9049, 9071, 9130, 9131, 9135, 9312, 9339, 9340, 9365, 9388, 9413, 9414, 9415, 9424, 9425, 9426, 9427, 9430, 9433, 9434, 9435, 10966, 10973, 11250, 11281, 11289, 11296, 11314, 11315, 11316, 11317, 11357, 11358, 11359, 11360, 11361, 11362, 11363, 11364, 11365, 11366, 11367, 11368, 11369, 11370, 11371, 11372, 11373, 11374, 11375, 11376, 11377, 11378, 11379, 11380, 11381, 11382, 11383, 11384, 11385, 11386, 11387, 11388, 11389, 11390, 11397, 11398, 11404, 11405, 11406, 11408, 11409, 11410, 11411, 11412, 11413, 11414, 11415, 11416, 11417, 11418, 11420, 11423, 11424, 11425, 11426, 11427, 11428, 11429, 11430, 11431, 11432, 11433, 11434, 14469, 14489, 14537, 14560, 14667, 14677, 14696, 14697, 14761, 14762, 14777, 14780, 14781, 14782, 14783, 14784, 14785, 14786, 14787, 14788, 14789, 14790, 14791, 14792, 14803, 14804, 11960, 11985, 11986, 11998, 12003, 12020, 12021, 12022, 12089, 12090, 12319, 12320, 12402, 10476, 10477, 10479, 10480, 10481, 10482, 10483, 10484, 10488, 10489, 10502, 10503, 10514, 10531, 10557, 10564, 10565, 10602, 10662, 10743, 13463, 13487, 13558, 13559, 13560, 13561, 13562, 13563, 13564, 13565, 13566, 13570, 13571, 13867, 13868, 13869, 13870, 13899, 13980, 13982, 13983, 13984, 13985, 13986, 13987, 14013, 14026, 14066, 14085, 14128, 14129, 14142, 14187, 12938, 12939, 12940, 12941, 12942, 12943, 13008, 14278, 14344, 13109, 13111, 13112, 13113, 13114, 13115, 13116, 13117, 13118, 13119, 13120, 13121, 13122, 13123, 13124, 13125, 13126, 13127, 13128, 13129, 13130, 13131, 13132, 13133, 13134, 13135, 13136, 13137, 13138, 13139, 13140, 13141, 13142, 13143, 13144, 13145, 13146, 13147, 13148, 14405, 13149, 13150, 13151, 13152, 13153, 13154, 13155, 14407, 13156, 13157, 13158, 13159, 13160, 13161, 13162, 13163, 13164, 13165, 13166, 13167, 13168, 13169, 14421, 13170, 13171, 13172, 13173, 13174, 13198, 13199, 13200, 13204, 13205, 13206, 13207, 13208, 13209, 13210, 13211, 13212, 13213, 13214, 13215, 13216, 13217, 13218, 13219, 13220, 13221, 13222, 13223, 13224, 13225, 13226, 13227, 13228, 13229, 13230, 13231, 13232, 13233, 13234, 13235, 13236, 13237, 13238, 13239, 13240, 13241, 13242, 13243, 13244, 13245, 13246, 13247, 13248, 13249, 13250, 13259, 13268, 13296, 13298, 13327, 13342, 13343, 13345, 13346, 13348, 13349, 13350, 13351, 13360, 13361, 13362, 13363, 12438, 12499, 12526, 12544, 12553, 12568, 12581, 12607, 12689, 12836, 12877, 12880, 12899, 12912, 12913, 12914, 12915, 12916, 12917, 12918, 12919, 12920, 12921, 12922, 12923, 12924, 12925, 12926, 12927, 12928, 12929, 12930, 12931, 12932, 12933, 12934, 12935, 12936, 12937, 11449, 11451, 11452, 11453, 11454, 11455, 11456, 11457, 11458, 11459, 11460, 11461, 11462, 11463, 11464, 11465, 11466, 11467, 11468, 11469, 11470, 11471, 11472, 11473, 11474, 11475, 11476, 11477, 11478, 11479, 11480, 11481, 11482, 11483, 11484, 11485, 11486, 11487, 11488, 11489, 11490, 11491, 11492, 11493, 11494, 11495, 11496, 11497, 11498, 11499, 11500, 11501, 11502, 11503, 11504, 11505, 11506, 11507, 11508, 11509, 11515, 11613, 11614, 11615, 11884, 11893))
and mstudents1_."vocationalqualification_id" = 1
and mstudents1_."title_id" = mtitles2_."id"
and mscoresdet0_."status_id" = 1
and mscoresdet0_."year" = 2024
and mscoresdet0_."scorecomplete" = 1
and (mscoresdet0_."student_id" not in (select
mstuqualif8_."student_id"
from
"ICME_TEST"."m_stu_qualified_history" mstuqualif8_
where
mstuqualif8_."student_id" = mscoresdet0_."student_id"
and mstuqualif8_."year" = 2025))
limit 20;

回答 0
暂无回答
扫一扫
联系客服