当前位置: 代码迷 >> 综合 >> 从 TPCH 测试学习性能优化技巧之 Q13
  详细解决方案

从 TPCH 测试学习性能优化技巧之 Q13

热度:67   发布时间:2023-12-09 17:06:43.0

一、     查询要求

 

Q13语句查询获得消费者的订单数量,包括过去和现在都没有订单记录的消费者。

Q13语句的特点是:带有分组、排序、聚集、子查询、左外连接操作并存的查询操作。

 

 

二、     Oracle执行

 

Oracle编写的查询SQL语句如下:

select  /*+ parallel(n) */

         c_count,

         count(*) as custdist

from (

         select

                   c_custkey,

                   count(o_orderkey) c_count

         from

                   customer left outer join orders on

                            c_custkey = o_custkey

                            and o_comment not like '%special%accounts%'

         group by

                   c_custkey

) c_orders

group by

         c_count

order by

         custdist desc,

         c_count desc;

其中/*+ parallel(n) */ 是Oracle的并行查询语法,n是并行数。

脚本执行时