Quantcast
Channel: Teradata Forums - Database
Viewing all 14773 articles
Browse latest View live

Incorrect Teradata explain estimates - forum topic by sribmsce

$
0
0

Hi,
I have a query where teradata expain is giving wrong esitmated time though the query is taking very few seconds.
It is estimating 9 mins due to which it is getting throttled.  Issue is in step 7. All the stats are ok and refreshed.
Could anyone pleae suggest what might be wrong.
 

DELETE FROM

    database1.TABLE1

WHERE

    SOURCE_SYSTEM_ID = '0009' 

    AND INVOICE_DATE>=

          ( SELECT MIN(INVOICE_DATE) 

               FROM db2.TAB2

               WHERE  SOURCE_SYSTEM_ID = '0009' )

AND     (REGID < 11   OR  REGID=20);

 

 This request is eligible for incremental planning and execution (IPE).

 The following is the static plan for the request.

  1) First, we lock a distinct db2."pseudo table" for read on a

     RowHash to prevent global deadlock for db2.TAB2.

  2) Next, we lock a distinct database1."pseudo table" for write on a

     RowHash to prevent global deadlock for

     database1.TABLE1.

  3) We lock db2.TAB2 for read, and we lock

     database1.TABLE1 for write.

  4) We do an all-AMPs SUM step to aggregate from

     db2.TAB2 by way of an all-rows scan with a

     condition of ("db2.TAB2.SOURCE_SYSTEM_ID = '0009'").

     Aggregate Intermediate Results are computed globally, then placed

     in Spool 3.  The size of Spool 3 is estimated with high confidence

     to be 1 row (19 bytes).  The estimated time for this step is 0.23

     seconds.

  5) We do an all-AMPs RETRIEVE step from Spool 3 (Last Use) by way of

     an all-rows scan into Spool 1 (all_amps), which is built locally

     on the AMPs.  The size of Spool 1 is estimated with high

     confidence to be 1 row (25 bytes).  The estimated time for this

     step is 0.01 seconds.

  6) We do an all-AMPs DISPATCHER RETRIEVE step from Spool 1 (Last Use)

     by way of an all-rows scan and send the rows back to the

     Dispatcher.  The size is estimated with high confidence to be 1

     row.  The estimated time for this step is 0.01 seconds.

  7) We do an all-AMPs DELETE from a single partition of

     database1.TABLE1 with a condition of (

     "database1.TABLE1.SOURCE_SYSTEM_ID = '0009'") with a

     residual condition of (

     "(database1.TABLE1.SOURCE_SYSTEM_ID = '0009') AND

     ((database1.TABLE1.INVOICE_DATE >= :%SSQ20) AND

     ((database1.TABLE1.REGID < 11) OR

     (database1.TABLE1.REGID = 20 )))").  The size is

     estimated with no confidence to be 3,534,316 rows.  The estimated

     time for this step is 9 minutes and 56 seconds.

  8) Finally, we send out an END TRANSACTION step to all AMPs involved

     in processing the request.

  -> No rows are returned to the user as the result of statement 1.

     The total estimated time is 9 minutes and 56 seconds.

 

Forums: 

Stored procedure for passing date values - forum topic by MaheshJessy

$
0
0

Hi Team, Would you please help me to write a procedure which should pass the parameters of date values. I just wanted use the procedure for passing values rather than hard-coding values in my filter condition,  How can I make this condition into procedure way.
Thanks in advance!

Existing condition:
and a.dlvr_dt between current_date - 365 and current_date

Output should be:

and a.dlvr_dt between current_date – CALL PROCEDURE(example)
and current_date

Mahesh

Forums: 

Is there a Teradata version which I an run on ESXi? - forum topic by snayeem

$
0
0

I saw some old discussion in the forum but couldn't find an option to run on esxi. Any help is appreciated.

Forums: 

Looking for TD 15 Database Installation on local system - forum topic by parasmehta7

$
0
0

Hi,
Can someone please advice How can i use Teradata 15 Database on my local system. I want to install it on my Windows 7 system to test some applications. I want to see changes in DBC/DBQL tables and advanced features.
I downloaded Teradata Studio 15.00 version but not sure if i can create Database in it.
Thanks,
Paras Mehta

Forums: 

Incorrect Teradata explain estimates - response (1) by VandeBergB

$
0
0

The time it takes for a query to execute has nothing to do with the labels used in teh explain plan.
There is absolutey no correlation between the labels on the cost values in an explain plan and clock time.  The words "days", "hours", "minutes" and "seconds" are all pronounced the same way when evaluating an explain plan, kost.  
Would you please post the table DDL and query, if you are able?
 
Cheers,
 

Defining two derived tables using WITH clause ?? - response (21) by ashk660

subtract- datediff 52 weeks to a date - forum topic by glory82

$
0
0

Hi, I write because I have a date (current_date) and I need substract 52 weeks and I dont know which function use.
 I think that with the syscalendar can do that but  I dont know how.
 
Thanks for your help.

Forums: 

subtract- datediff 52 weeks to a date - response (1) by dnoeth

$
0
0

52 weeks are 52*7 days, simply do current_date - 52*7


Looking for TD 15 Database Installation on local system - response (1) by dnoeth

$
0
0

Hi Paras,
Teradata Studio is only a client, you need a Teradata server.
You can download Teradata Express and run it on VMWare Player: VMware

COMPRESSION for TIMESTAMP field in TD14 - response (4) by lawrence.lakey@bnsf.com

$
0
0

Hi.  I tried the following and get an error.  Can you help with syntax?
 
EXPLAIN ALTER TABLE CWU_MRKT.TIFCST_WB_RTE_STN_DWL
ADD STN_DWL_MDN_D2S
COMPRESS ( INTERVAL '0 00:00:00.000000' )
;

Error while Executing a Dynamic SQL in Teradata Stored Procedure - response (3) by MaheshJessy

$
0
0

Stored procedure for passing date values

Hi Team, Would you please help me to write a procedure which should pass the parameters of date values. I just wanted use the procedure for passing values rather than hard-coding values in my filter condition,  How can I make this condition into procedure way.
Thanks in advance!

 

Existing condition:

and a.dlvr_dt between current_date - 365 and current_date

 

Output should be:

 

and a.dlvr_dt between current_date – CALL PROCEDURE(example)

and current_date

Mahesh

 

Merge History tables and alligning the time periods - forum topic by suresh vajpey

$
0
0

Hi Team,
I need your expert advice to find an the optimal solution for the below problem.
I have 1 driver table and 6 tables with 15-20 years history. Good thing, the key column is same in all..
The requirement is to extract few attributes for the key column from each of these history tables and populate into one table for reporting purposes..
Obviously the date ranges are varying for each row. So while loading into one table I would like to list all the required columns WITH VALUE that have a overlapping period, else Null.

Example below
TABLE1
id            Col1  STRT_D       END_D
ABCD123  01  01/01/2001 11/01/2001
ABCD123  02  12/01/2001 31/12/9999
TABLE2
id            Col1  STRT_D       END_D
ABCD123  AA  05/01/2001 21/01/2001
ABCD123  BB  22/01/2001 02/03/2005
TABLE3
id            Col1  STRT_D       END_D
ABCD123  X1  01/01/2005 10/03/2005
ABCD123  X2  11/03/2005 31/12/9999
 
FINAL TABLE
ID         COL1_T1     COL1_T2   COL1_T3            STRT_D                 END_D
ABCD123   01          NULL            NULL            01/01/2001            04/01/2001
ABCD123   01            AA              NULL            05/01/2001            11/01/2001
ABCD123   02            AA              NULL            12/01/2001            21/01/2001
ABCD123   02            BB             NULL             22/01/2001            31/12/2004
ABCD123   02            BB             X1                 01/01/2005            02/03/2005
ABCD123   02            NULL         X1                 03/03/2005            10/03/2005
ABCD123   02            NULL         X2                 11/03/2005            31/12/9999
Considering the huge record count, I can't join to a calendar table to generate records for each day,
Apprecaite any help.

Forums: 

Query - forum topic by Abhi93

$
0
0

Hi,
 
I have below data,
 
Name    Sum
A           10
B           8
C           6
D           4
From above i need to derive following:
Name    Sum      Diff
A           10         0
B           8           10-8
C           6           10-6
D           4           10-4
 
Thanks,
A
 

Forums: 

Query - response (1) by yuvaevergreen

$
0
0

If your TD version is 14, then first value can be used.
SEL NAME,DIFF,FIRST_VALUE(DIFF) OVER(ORDER BY NAME ASC ROWS UNBOUNDED PRECEDING)-DIFF FROM T1
 

Query - response (2) by adityapatel

$
0
0

I cant get this. Can you please expalin in detail.


Merge History tables and alligning the time periods - response (1) by VandeBergB

$
0
0

Hi Suresh,
It's difficult to understand how you're building the final table from the example you posted, but from what you've described, I advise you to spend some time familiarizing yourself with the period data type.  It has some very nice functionality with regard to overlapping time periods etc...
You can find the documentation online at http://www.info.teradata.com/HTMLPubs/DB_TTU_14_00/index.html#page/SQL_Reference/B035_1143_111A/Period_Data_Types.044.01.html
The documentation for the operators is just below the link above on the same page.
Cheers!

Query - response (3) by Abhi93

$
0
0

TD version is 12 
I need to calculate 'Diff' column using column 'Sum' for example - row 2 should B  8  2 (10-8) and row 3 should be C   6   4 (10-6)   

Query - response (4) by yuvaevergreen

$
0
0

SEL NAME,SUM,(SEL SUM FROM (SEL SUM FROM P1 QUALIFY ROW_NUMBER() OVER( ORDER BY NAME ASC)=1) A) - SUM
FROM P1
This sould work.
 
Thanks
Yuva
 
 

Query - response (5) by yuvaevergreen

$
0
0

 
 
SEL NAME,SUM,FIRST_VALUE(SUM) OVER(ORDER BY NAME ASC ROWS UNBOUNDED PRECEDING)-SUM FROM T1 ..This is the correct one..
@adityapatel
 

Problem with calling Java table operator from stored procedure - forum topic by MarkMarsh

$
0
0

I'm struggling to pass data into the custom clause of a table operator, using a string literal works fine but I can't get the procedure to compile when passing a parameter.

REPLACE PROCEDURE EXAMPLE ()

BEGIN

 INSERT INTO OUTPUT SELECT * FROM TBLOP (ON (SELECT * FROM WORKING) partition by X USING latency('A=1000:B=2000')) AS J1;

END;

 

Works fine but

 

REPLACE PROCEDURE EXAMPLE ()

BEGIN

 DECLARE LC VARCHAR;

 SET LC = 'A=1000:B=2000';

 INSERT INTO OUTPUT SELECT * FROM TBLOP (ON (SELECT * FROM WORKING) partition by X USING latency(:LC)) AS J1;

END;

 

Fails with the following error...

 

Executed as Single statement.  Failed [5526 : HY000] Stored Procedure is not created/replaced due to error(s).{Nested Failure Msg [5526 : HY000] SPL1027:E(L5), Missing/Invalid SQL statement'E(9688):Table operator's execution error: Wrong Data Type is found in Table Operator's Custom Clause..'.} 

 

 

 

I've tried using an integer and TD_ANYTYPE as the variable type with no success. I've also run it with the debugger active and, as expected, the procedure that does compile calls the contract function but the procedure that fails to compile does not, so I don't think it's anything I'm doing wrong there.
The table operator declaration is.

REPLACE FUNCTION TBLOP()

RETURNS TABLE VARYING USING FUNCTION Tblop_contract

LANGUAGE JAVA NO SQL

PARAMETER STYLE SQLTABLE

EXTERNAL NAME 'TeradataJarFile:com.td.Tblop.execute';

 
Any ideas?
 

Forums: 
Viewing all 14773 articles
Browse latest View live


Latest Images