为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:dm8
【操作系统】:
【CPU】:
【问题描述】*:在创建视图时,sql特别慢。经过测试发现主要是有了order by 后特别慢,甚至查不出来
1 #NSET2: [58, 314, 472]
2 #PRJT2: [58, 314, 472]; exp_num(39), is_atom(FALSE)
3 #SORT3: [58, 314, 472]; key_num(1), is_distinct(FALSE), top_flag(0), is_adaptive(0)
4 #INDEX JOIN LEFT JOIN2: [57, 314, 472] join condition((pm.Year = fd.Year AND pm.Batch = fd.Batch AND exp11 = 8 AND pm.Code = exp11)) ret_null(0)
5 #SLCT2: [56, 157, 472]; (dl.Year = xl.Year AND dl.Batch = xl.Batch AND dl.Code = exp11 AND pm.AreaCode = dl.AreaCode AND pm.Year = dl.Year AND pm.Batch = dl.Batch)
6 #NEST LOOP INDEX JOIN2: [56, 157, 472]
7 #HASH2 INNER JOIN: [51, 78, 316]; KEY_NUM(4); KEY(xl.AreaCode=pm.AreaCode AND xl.Year=pm.Year AND xl.Batch=pm.Batch AND xl.Code=exp11) KEY_NULL_EQU(0, 0, 0, 0)
8 #SLCT2: [24, 4207, 156]; exp11 = 4
9 #CSCN2: [24, 168280, 156]; INDEX33556189(TD_MACHINE_TYPE_PUSH as xl)
10 #SLCT2: [24, 4207, 160]; exp11 = 6
11 #CSCN2: [24, 168280, 160]; INDEX33556189(TD_MACHINE_TYPE_PUSH as pm)
12 #BLKUP2: [5, 2, 4]; AreaCode_State(dl)
13 #SSEK2: [5, 2, 4]; scan_type(ASC), AreaCode_State(TD_MACHINE_TYPE_PUSH as dl), scan_range[(xl.AreaCode,min),(xl.AreaCode,max))
14 #BLKUP2: [1, 2, 8]; AreaCode_State(fd)
15 #SSEK2: [1, 2, 8]; scan_type(ASC), AreaCode_State(TD_MACHINE_TYPE_PUSH as fd), scan_range[(pm.AreaCode,min),(pm.AreaCode,max))
这里这个表,两次全表扫描,效率太差,需要建索引
已解决