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

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

热度:90   发布时间:2023-12-09 17:09:12.0

一、     查询要求

 

Q1语句查询lineItem的一个定价总结报告。在单个表lineitem上查询某个时间段内,对已经付款的、已经运送的等各类商品进行统计,包括业务量的计费、发货、折扣、税、平均价格等信息。

Q1语句的特点是:带有分组、排序、聚集操作并存的单表查询操作。这个查询会导致表上的数据有95%到97%行被读取到。

 

 

二、     Oracle执行

 

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

select  /*+ parallel(n) */

         l_returnflag,

         l_linestatus,

         sum(l_quantity) as sum_qty,

         sum(l_extendedprice) as sum_base_price,

         sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,

         sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,

         avg(l_quantity) as avg_qty,

         avg(l_extendedprice) as avg_price,

         avg(l_discount) as avg_disc,

         count(*) as count_order

from

         lineitem

where

         l_shipdate <= date '1995-12-01&