{データウェアハウスの管理その他}スタークエリをチューニング

 

https://docs.oracle.com/cd/F19136_01/dwhsg/data-warehouse-optimizations-techniques.html#GUID-095A1BEC-E373-49B2-A3CF-E059D42B6E7A

https://blogs.oracle.com/oracle4engineer/post/ja-sample-data-for-oracle-database


cd ~/db-sample-schemas/sales_history/

vi sh_populate.sql

下記 LOAD文の後にcommit; 追加
LOAD costs costs.csv
LOAD customers customers.csv
LOAD promotions promotions.csv
LOAD sales sales.csv
LOAD times times.csv
LOAD supplementary_demographics supplementary_demographics.csv

bash /u01/app/oracle/product/19.0.0/dbhome_1/sqldeveloper/sqldeveloper/bin/sql sh/sh
alter session set nls_date_format='YYYY-MM-DD';

truncate table CHANNELS;
truncate table COUNTRIES;
truncate table PRODUCTS;

@sh_populate.sql

 

select count(*) from sales;
select count(*) from times;
select count(*) from customers;
select count(*) from channels;


show parameter star
alter session set star_transformation_enabled=true;
show parameter star

set autot on

SELECT ch.channel_class, c.cust_city, t.calendar_quarter_desc,
   SUM(s.amount_sold) sales_amount
FROM sales s, times t, customers c, channels ch
WHERE s.time_id = t.time_id
AND   s.cust_id = c.cust_id
AND   s.channel_id = ch.channel_id
AND   c.cust_state_province = 'CA'
AND   ch.channel_desc in ('Internet','Catalog')
AND   t.calendar_quarter_desc IN ('1999-Q1','1999-Q2')
GROUP BY ch.channel_class, c.cust_city, t.calendar_quarter_desc;