为什么Netezza在解释计划中使用物化视图

时间:2016-10-14 13:53:53

标签: sql netezza materialized-views

我在Netezza中有一个物化视图,它在我的Customer表中的5列上。我写了一个查询,其中包含一个来自Customer的列(Customer_email),它不在物化视图中,当我在查询中解释时,它只显示物化视图,而不是Customer表,我没有了解。有没有人对此有解释?

CREATE MATERIALIZED VIEW CUSTOMER_DIM_MV
AS
SELECT 
    customer_key,
    persona_key,
    customer_birthdate,
    customer_zip,   
    update_datetime 
FROM 
    CUSTOMER_DIM
ORDER BY customer_key;


select 
  customer_key
, customer_birthdate
, customer_email
from (
select base.customer_key,
      cd.customer_birthdate,  
      cd.customer_email,
      row_number() over (partition by base.customer_key order by cd.update_datetime desc) trans_date
from extract_base base
join CUSTOMER_DIM cd on base.customer_key = cd.customer_key
) a
where a.trans_date = 1;

Sub-query Scan table "A" (cost=7881.4..7881.4 rows=1956474 width=11 conf=80)
   l: Aggregate (cost=7881.4..7881.4 rows=1956474 width=23 conf=0)
      l: Hash Join (cost=9.9..7870.8 rows=1956474 width=18 conf=64)
         l: Sequential Scan mview index  "_MCUSTOMER_DIM_MV" (cost=0.0..6867.3 rows=13132953 width=16 conf=80) 
         r: Hash (cost=5.1..5.1 rows=669425 width=8 conf=0)
            l: Sequential Scan table "BASE" (cost=0.0..5.1 rows=669425 width=8 conf=100) 

0 个答案:

没有答案