Check for special character in a string - response (9) by GIRINJ
Acctg vs DBQL vs ResUsage - response (1) by GianTD
Its like...
Acctg - captures CPU & IO data on AccountString/UserID level. Same data can be found in DBQL also but difference being Accounting data tend to be more correct as DBQL doesn’t capture CPU & IO data for aborted or errored out queries and also some Work by Utilities.
Acctg will be used more for deptt wise usage.
DBQL- Captures resouces usage data for Queries.
ResUsage - Captures System wide performance/Usage data related to hardware components like Nodes, AWTs, CPU etc
List of Teradata Customers - response (1) by ap90792
Hi All,
As we are unable to find the list at one place,I request all to share the Teradata customer names which you are aware of. (To whom you worked with on Teradata system)
It would be of great help ,If i could prepare a list with which are excluded on above Teradata customers URL.
Look forward to your participation.(Do let me know if this discussion needs to be moved to other forums)
My List :
1. UHG
2.Wells Fargo
3.Barclays
4.L and T
5. Citi Bank
Complex analytical query help - forum topic by jnbalaji
Dear Folks,
I have a table with information like subscriber added/removed particular feature along with the date it added or removed. Also if he is active or canceled his subscription.
CREATE TABLE subscriber_feature (SUB_ID INTEGER, -- subscriber id feature_status VARCHAR(20) -- feature status change ex - 'preminum added' / 'preminum removed' feature_status_dttm TIMESTAMP(6), --feature added/removed dttm sub_status_change_dttm TIMESTAMP(6), -sub status change dttm sub_type_cd CHAR(5), -- ex value 'prep' Sub_stat_cd CHAR(1)) - ex value 'active', 'cancel' etc PRIMARY INDEX(sub_id);
I have to write SQL to give report in following format.
Jan-12 Feb-12 Mar-12 .....Dec-14 Jan-12 100 80 60 ..... Feb-12 0 100 80 .... Mar-12 0 0 100 . . Dec-14 total premium- 100 180 240 ............ Feature
First row is all Jan-12 data. for Jan-12, how many subscribed for the feature, then how many stays in it by every month end.
(Ex) 100 subscribed Jan-12 and 15 unsubscribed for premium feature and 5 canceled there subscription by feb-12. So first row should have 100 for Jan-12 and 80(100 - 15 - 5) for Feb-12 and so on for all months.
Second row is for Feb-12. Same like jan. Last row should have the total count of subscribers subscribed for preminum feature by all month end.
We need to calculate feature added and feature removed using both feature_status and feature_status_dttm. subscription cancel by Sub_stat_cd & sub_status_change_dttm.
Looks very very complex to me. Could some one help me with this? If we can store the result in volatile table and derive the report using another query also fine. Please help.
Thanks.
Complex analytical query help - response (1) by dnoeth
Can you elaborate on the rules how feature_status/feature_status_dttm and Sub_stat_cd/sub_status_change_dttm are related and add some sample inserts?
What's you TD release?
I would assume some combination of EXPAND ON/TD_SEQUENCED_COUNT plus GROUPING SETS will be able to return this result.
Complex analytical query help - response (2) by jnbalaji
Hi Dieter,
If feature added or removed both will be stored in feature_status. For both the action the event time is stored in Feature_status_dttm. Using the feature_status and Feature_status_dttm only i can determine when feature is added/removed.
If sub_stat_cd is 'cancel' then subscription cancel time will be stored in sub_status_change_dttm. Using this i can determine this subscriber is still with us or not.
Based on both i can determine how many subscribed for particular feature in month 1 and how many still using this feature for 3 years month by month.
Sample inserts below
insert into subscriber_feature values(1000, 'premium added', current_timestamp - interval '2' month, current_timestamp - interval '90' day,'prep', 'active');
--Subscriber 1000 added feature in Oct month.
insert into subscriber_feature values(1004, 'premium added', current_timestamp - interval '1' month, current_timestamp - interval '30' day,'prep', 'active');
--Subscriber 1004 added feature Nov month.
insert into subscriber_feature values(1000, 'premium removed', current_timestamp - interval '1' month, current_timestamp - interval '30' day,'prep', 'active');
--Subscriber 1000 removed feature nov month.
insert into subscriber_feature values(1004, 'premium added',
current_timestamp - interval '2' month,
current_timestamp ,'prep', 'cancel');
--Subscriber 1004 canceled his subscription today (Dec).
insert into subscriber_feature values(1005, 'premium added',
current_timestamp,
current_timestamp ,'prep', 'Active');
--New Subscriber 1005 added feature today (Dec).
Report by end of december
Oct-14 Nov-14 Dec-14
Oct -14 1 0 0
Nov-14 0 1 0
Dec-14 0 0 1
Total 1 1 1
Thanks
How to execute a stored procedure from vba excel - response (3) by teradatauser2
I found a solution to this problem. i ran the stored procedure in a bteq and captured the log in a log file from vba. the bteq is run in windows. The o/p success / failure message is displayed and captured in the log after the SP is executed. then in the vba code you can parse the o/p message and find if the SP failed on succeeded. i think it is not possible to get back the message from TD Sp as i initially intened.
--Samir
Fallback Table Restriction in System - response (1) by Sandeepyadav
Hi Experts,
Any suggestion ??
Identify error record in case of VT insert statement failure - response (5) by ashishagg2005
Hi ,
I read about logging errors , but it seems to be working on permanent tables, however in my case , its all VT tables.
Please advise
Thanks,
Ashish
Complex analytical query help - response (3) by jnbalaji
I am using TD14
Complex analytical query help - response (4) by dnoeth
First you need the logic to determine the period when a subscription was active, something like this:
SELECT SUB_ID ,feature_status ,sub_type_cd ,Sub_stat_cd ,TRUNC(feature_status_dttm, 'mon') AS start_dt -- 1st day of month ,TRUNC(MIN(CASE WHEN feature_status = 'premium removed' -- last day of the previous month before subscription ended OR Sub_stat_cd = 'cancel' THEN sub_status_change_dttm END) OVER (PARTITION BY SUB_ID ORDER BY sub_status_change_dttm ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) , 'mon') -1 AS end_dt FROM subscriber_feature QUALIFY feature_status = 'premium added' -- only start of subscription AND Sub_stat_cd = 'Active'
Of course you might add some conditions to get only rows from the last 36 months...
Then you count the number of rows for each start/end combination:
SELECT start_dt ,COALESCE(end_dt, DATE '9999-12-01') AS end_dt ,COUNT(*) AS CNT FROM (previous query returning subscription start/end) GROUP BY start_dt, end_dt
Finally you need to cross join it to a table with one row for each month:
SELECT CASE WHEN GROUPING (mth) = 0 THEN (mth (FORMAT 'mmm-yy') (CHAR(6))) ELSE 'Total' END ,... ,SUM(CASE WHEN mth = start_dt AND DATE '2014-09-01' BETWEEN start_dt AND end_dt THEN CNT ELSE 0 END) AS "Sep-14" ,SUM(CASE WHEN mth = start_dt AND DATE '2014-10-01' BETWEEN start_dt AND end_dt THEN CNT ELSE 0 END) AS "Oct-14" ,SUM(CASE WHEN mth = start_dt AND DATE '2014-11-01' BETWEEN start_dt AND end_dt THEN CNT ELSE 0 END) AS "Nov-14" ,SUM(CASE WHEN mth = start_dt AND DATE '2014-12-01' BETWEEN start_dt AND end_dt THEN CNT ELSE 0 END) AS "Dec-14" FROM ( -- any query returning one row per 1st of month, e.g. SELECT DISTINCT calendar_date AS mth FROM sys_calendar.CALENDAR WHERE calendar_DATE BETWEEN ADD_MONTHS(CURRENT_DATE,-36) AND CURRENT_DATE-1 AND day_of_month = 1 ) AS cal CROSS JOIN (previous query returning counts per period) GROUP BY GROUPING SETS ((mth), ()) ORDER BY mth NULLS LAST
Hope I got your logic correct :-)
But there's no way to dynamically name the 36 month columns, you need to add/remove them manually as needed.
Identify error record in case of VT insert statement failure - response (6) by dnoeth
Hi Ashish,
you can't create Error Tables for Volatile Tables.
Either materialize the VTs in "real" tables or add more regular expressions to check for invalid data.
Fallback Table Restriction in System - response (2) by dnoeth
Hi Sandeep,
no, you can't.
Simply set the database default to NO FALLBACK and hope the end users don't overwrite it.
Maybe add a scheduled job which mails the users when they do and submits ALTER TABLE, NO FALLBACK...
Help with avoiding redistribution using a hash index - response (5) by ps.suma@gmail.com
Thank you Dieter. I modified the query as you suggester(clever!), changed the varchar columns to varchar(95) for address and varchar(25) for name, created a join index and collected stats on the index columns. Now the query runs in one-third the original CPU-time it used to take, uses two STAT steps and does not redistribute the data. The Teradata version is 14.10.
Current explain plan:
1) First, we lock a distinct cdw_sandbox."pseudo table" for read on a RowHash to prevent global deadlock for cdw_sandbox.suma_xref_prep_1. 2) Next, we lock cdw_sandbox.suma_xref_prep_1 for read. 3) We do an all-AMPs STAT FUNCTION step from cdw_sandbox.suma_xref_prep_1 by way of an all-rows scan with no residual conditions into Spool 5 (Last Use), which is assumed to be redistributed by value to all AMPs. The result rows are put into Spool 3 (all_amps), which is built locally on the AMPs. The size is estimated with high confidence to be 731,330,867 rows ( 293,263,677,667 bytes). 4) We do an all-AMPs RETRIEVE step from Spool 3 (Last Use) by way of an all-rows scan with a condition of ("(Party_Xref_Start_Dt > Field_14) OR (Field_14 IS NULL)") into Spool 1 (used to materialize view, derived table, table function or table operator dt) (all_amps), which is built locally on the AMPs. The result spool file will not be cached in memory. The size of Spool 1 is estimated with high confidence to be 731,330,867 rows ( 107,505,637,449 bytes). The estimated time for this step is 49.20 seconds. 5) We do an all-AMPs STAT FUNCTION step from Spool 1 (Last Use) by way of an all-rows scan into Spool 12 (Last Use), which is assumed to be redistributed by value to all AMPs. The result rows are put into Spool 8 (group_amps), which is built locally on the AMPs. The size is estimated with high confidence to be 731,330,867 rows (196,728,003,223 bytes). 6) Finally, we send out an END TRANSACTION step to all AMPs involved in processing the request. -> The contents of Spool 8 are sent back to the user as the result of statement 1.
Appreciate your help on this.
I looked up the difference between hash and join indexes in the below url and understand a hash index is only a subset of join index capabilities:
http://www.info.teradata.com/htmlpubs/DB_TTU_14_00/index.html#page/SQL_Reference/B035_1184_111A/Create_Hash_Index-Details.010.006.html
However I don't understand why a join index avoids redistribution but a hash index doesn't in this context. I would appreciate it if anyone can explain the reason for this.
Thank you
Suma
Complex analytical query help - response (5) by jnbalaji
Hi Dieter,
Thanks a lot, This is exactly what i was looking for and also learnt some new functions that i never came across in teradata.
Thanks a lot,
Naga
bad query - response (7) by teradatauser2
I believe, you need to specify a range of dates for which you need to take out the top 5 spool consuming query. Logdate is PPI on all of the dbql tables (atleast dbqllogtbl for sure i know). The data in these tables is very huge as all data gets logged depending on the logging rules that has been enabled. So, it makes sense to query logtable for a period of time and not the full table. the data is dbql tables is purged after a period of time (or backed up to tapes) as it grows very fast. for example in my current installatiom, data older that 3 months is purged. So, if you specify a range of value for Logdate , it will work very fast.
--Samir
Connection pooling in Glassfish server with teradata - response (2) by kishore.jena@gmail.com
Hi,
I am getting below error while ping from glassfish for teradata. I saw a number of properties asking to set for connection pool in "additional properties" section. There are 39 properties are there in the "additional properties" section. Certain properties are repeated twice. Can you please share the additional properties configuration section for teradata.
WARNING: RAR8054: Exception while creating an unpooled [test] connection for pool [ TeradataPool ], Exception while destroying physical connection
SEVERE: RestResponse.getResponse() gives FAILURE. endpoint = 'http://localhost:4848/management/domain/resources/ping-connection-pool.json'; attrs = '{id=TeradataPool}'
Where clause in MLOAD import mode - forum topic by mayya@teradataforum
Hi All,
In import mode of Mload, update's and delete's to be sucessful, they must refer Primary Index in the where clause.
Please let me know the exact reason for the above statement ?
what happens if I wont specify PI in where clause in delete/update statement in Mload(import mode) ?
Date data type - forum topic by shruti1
Hi people,
One of the values in a date datatype column is "<error>" this is a small table with just about 3k rows and all the other values seem to be fine except for one particular entry. I am new to teradata and this is beyond my level of comprehension. How can <error> be stored as a value in a date datatype column? Could it be because of an error while loading data into the table? Please advice
thanks in advance
Where clause in MLOAD import mode - response (1) by ulrich
"exact reason" - what do you expect?
multiload was designed to avoid journaling and therefore it came up with some rules - one is that the full PI has to be refered as it need to know which blocks are affected. Only exception is "multiload delete" run type.
Did you read the manuals?
"what happens if I wont specify PI" - you get an error message and nothing will be processed.
Thanks a lot!! This is exactly what I wanted !
GIRINJ