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

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

热度:45   发布时间:2023-12-09 17:08:32.0

一、     查询要求

 

Q4语句查询得到订单优先级统计值。计算给定的某三个月的订单的数量,在每个订单中至少有一行由顾客在它的提交日期之后收到。

Q4语句的特点是:带有分组、排序、聚集操作、子查询并存的单表查询操作。子查询是相关子查询。

 

 

二、     Oracle执行

 

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

select  /*+ parallel(n) */

         o_orderpriority,

         count(*) as order_count

from

         orders

where

         o_orderdate >= date '1995-10-01'

         and o_orderdate < date '1995-10-01' + interval '3' month

         and exists (

                   select * from lineitem

                   where l_orderkey = o_orderkey and l_commitdate < l_receiptdate

         )

group by

         o_orderpriority

order by

         o_orderpriority;

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

脚本执行时间,单位: