:) Thanks Dieter... but i should have mentioned that the dates are passed as parameters into a table and we create a view on that table.
The view cannot be created on hard coded dates.
I used those dates to create a test case.
Here is the scenario:
We use Wherescape RED for our ETL builds and to store our environment's metadata.
There is a table called DSS_PARAMETER which stores parameter values defined in the tool.
We have defined parameters like 'Batch_Start_Window' and 'Batch_End_Window'.
Values for these parameters are incremented daily through a script and that's how we do our daily build.
CREATE SET TABLE D_BI_USRDB.DSS_PARAMETER
(dss_parameter_name VARCHAR(256) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL,
dss_parameter_value VARCHAR(4000) CHARACTER SET LATIN NOT CASESPECIFIC,
dss_parameter_comments VARCHAR(256) CHARACTER SET LATIN NOT CASESPECIFIC,
dss_parameter_type VARCHAR(1) CHARACTER SET LATIN NOT CASESPECIFIC)
UNIQUE PRIMARY INDEX ( dss_parameter_name );
SELECT DSS_PARAMETER_NAME, CAST(DSS_PARAMETER_VALUE AS TIMESTAMP)
FROM D_BI_USRDB.DSS_PARAMETER
WHERE DSS_PARAMETER_NAME IN ('BATCH_BEGIN_WINDOW', 'BATCH_END_WINDOW');
Batch_End_Window 3/13/2013 00:00:00.000000
Batch_Begin_Window 3/11/2013 00:00:00.000000
So, if i create a view like
REPLACE VIEW SSURI.CDC_BATCH AS
SELECT MAX(CASE WHEN DSS_PARAMETER_NAME = 'BATCH_BEGIN_WINDOW' THEN CAST(DSS_PARAMETER_VALUE AS TIMESTAMP) END) AS BATCH_START,
MAX(CASE WHEN DSS_PARAMETER_NAME = 'BATCH_END_WINDOW' THEN CAST(DSS_PARAMETER_VALUE AS TIMESTAMP) END) AS BATCH_END
FROM D_BI_USRDB.DSS_PARAMETER
WHERE DSS_PARAMETER_NAME IN ('BATCH_BEGIN_WINDOW', 'BATCH_END_WINDOW')
and use this view with a table to extract last 2 days data, the optimizer would ignore the partition elimination.
SELECT * FROM SSURI.CUSLDSFL_SI
CROSS JOIN SSURI.CDC_BATCH X
WHERE AUD_TIME BETWEEN X.BATCH_START AND X.BATCH_END
10) We do an all-AMPs JOIN step from Spool 7 (Last Use) by way of an
all-rows scan, which is joined to SSURI.CUSLDSFL_SI by way of an
all-rows scan with no residual conditions. Spool 7 and
SSURI.CUSLDSFL_SI are joined using a product join, with a join
condition of ("(SSURI.CUSLDSFL_SI.Aud_Time >= BATCH_START) AND
(SSURI.CUSLDSFL_SI.Aud_Time <= BATCH_END)"). The result goes into
Spool 6 (group_amps), which is built locally on the AMPs. The
size of Spool 6 is estimated with no confidence to be 203,482,229
rows (206,534,462,435 bytes). The estimated time for this step is
3 minutes and 22 seconds.
Sanjeev
:) Thanks Dieter... but i should have mentioned that the dates are passed as parameters into a table and we create a view on that table.
The view cannot be created on hard coded dates.
I used those dates to create a test case.
Here is the scenario:
We use Wherescape RED for our ETL builds and to store our environment's metadata.
There is a table called DSS_PARAMETER which stores parameter values defined in the tool.
We have defined parameters like 'Batch_Start_Window' and 'Batch_End_Window'.
Values for these parameters are incremented daily through a script and that's how we do our daily build.
CREATE SET TABLE D_BI_USRDB.DSS_PARAMETER
(dss_parameter_name VARCHAR(256) CHARACTER SET LATIN NOT CASESPECIFIC NOT NULL,
dss_parameter_value VARCHAR(4000) CHARACTER SET LATIN NOT CASESPECIFIC,
dss_parameter_comments VARCHAR(256) CHARACTER SET LATIN NOT CASESPECIFIC,
dss_parameter_type VARCHAR(1) CHARACTER SET LATIN NOT CASESPECIFIC)
UNIQUE PRIMARY INDEX ( dss_parameter_name );
SELECT DSS_PARAMETER_NAME, CAST(DSS_PARAMETER_VALUE AS TIMESTAMP)
FROM D_BI_USRDB.DSS_PARAMETER
WHERE DSS_PARAMETER_NAME IN ('BATCH_BEGIN_WINDOW', 'BATCH_END_WINDOW');
Batch_End_Window 3/13/2013 00:00:00.000000
Batch_Begin_Window 3/11/2013 00:00:00.000000
So, if i create a view like
REPLACE VIEW SSURI.CDC_BATCH AS
SELECT MAX(CASE WHEN DSS_PARAMETER_NAME = 'BATCH_BEGIN_WINDOW' THEN CAST(DSS_PARAMETER_VALUE AS TIMESTAMP) END) AS BATCH_START,
MAX(CASE WHEN DSS_PARAMETER_NAME = 'BATCH_END_WINDOW' THEN CAST(DSS_PARAMETER_VALUE AS TIMESTAMP) END) AS BATCH_END
FROM D_BI_USRDB.DSS_PARAMETER
WHERE DSS_PARAMETER_NAME IN ('BATCH_BEGIN_WINDOW', 'BATCH_END_WINDOW')
and use this view with a table to extract last 2 days data, the optimizer would ignore the partition elimination.
SELECT * FROM SSURI.CUSLDSFL_SI
CROSS JOIN SSURI.CDC_BATCH X
WHERE AUD_TIME BETWEEN X.BATCH_START AND X.BATCH_END
10) We do an all-AMPs JOIN step from Spool 7 (Last Use) by way of an
all-rows scan, which is joined to SSURI.CUSLDSFL_SI by way of an
all-rows scan with no residual conditions. Spool 7 and
SSURI.CUSLDSFL_SI are joined using a product join, with a join
condition of ("(SSURI.CUSLDSFL_SI.Aud_Time >= BATCH_START) AND
(SSURI.CUSLDSFL_SI.Aud_Time <= BATCH_END)"). The result goes into
Spool 6 (group_amps), which is built locally on the AMPs. The
size of Spool 6 is estimated with no confidence to be 203,482,229
rows (206,534,462,435 bytes). The estimated time for this step is
3 minutes and 22 seconds.
Sanjeev