Select query through view spools out

Database
Teradata Employee

Select query through view spools out

I am running a simple select query which is part of a bigger code. The query is given below:

SyntaxEditor Code Snippet

select    event_id,agrmnt_id,
,card_no,mrchnt_nm
from view.data_view
where event_pl<0
    and bi_am is not null
    and card_no is not null
    and event_start_dt between ADD_MONTHS(DATE, -13)     AND DATE
    and source_start_dt between ADD_MONTHS(DATE, -13)     AND DATE
;

The view data_view is a view within a view on a large table (14 TB) approximately. I have checked the explain plan
and there is no data redistrubtion or duplication. Since there is no join in the query. As per the explain plan it
takes upto 559 GB of spool. Is there any way we can reduce the spool usage in the above query?

 

2 REPLIES
Highlighted
Teradata Employee

Re: Select query through view spools out

Is the 14TB table skewed at all?

 

SELECT

TABLENAME,

SUM(CURRENTPERM) /(1024*1024) AS CURRENTPERM,

(100 - (AVG(CURRENTPERM)/MAX(CURRENTPERM)*100)) AS SKEWFACTOR

FROM

DBC.TABLESIZE

WHERE DATABASENAME= <DATABASENAME>

AND TABLENAME =<TABLENAME>

GROUP BY 1;

Teradata Employee

Re: Select query through view spools out

the skew factor is 2.78