Tuesday, October 23, 2012

What is High confidence, Low confidence and No confidence in EXPLAIN plan?


Explain gives the execution strategy based on dictionary information (stats) it has about object in questions.

  • HIGH CONFIDENCE: Statistics are collected.
  • LOW CONFIDENCE: Statistics are not collected.But the where condition is having the condition on indexedcolumn.Then estimations can be based on sampling.
  • NO CONFIDENCE: Statistics are not collected and the condition is on non indexed column

What are Global temporary tables and Volatile temporary tables?


 Global Temporary tables (GTT):

1. When they are created, its definition goes into Data Dictionary.
2. When materialized data goes in temp space.
3. That's why, data is active till the session persist, 
    and definition will remain there up-to its not dropped using Drop table statement.
    If dropped from some other session then its should be Drop table all;
4. you can collect stats on GTT.

Volatile Temporary tables (VTT):

1. Table Definition is stored in System cache
2. Data is stored in spool space.
3. That's why, data and table definition both are active till session persist.
4. No collect stats for VTT. 
5. If you are using volatile table, you can not put the default values on column level while creating table.

Monday, October 22, 2012

3668: A table listed in the Dictionary is not present


This error shows up when restore of table is failed in middle, and user tries to select from this table.

LOCKING Failed. 3668: A table listed in the Dictionary is not present. 

solution would be to drop the table and recreate/restore/copy with latest backup.


Saturday, October 20, 2012

How to query databases space of whole system.

We can query dbc.Diskspace to know all about space in system. here is query through which we can get idea about Maximum permanent space allocated, how much space is currently consumed and how much is free, with details about % of use and % of space usage skew.


SELECT Databasename AS "Database Name",
Max_perm_gb (DECIMAL (10,1)) AS "Max Perm (GB)",
current_perm_gb (DECIMAL (10,1)) AS "Current Perm (GB)",
EffectiveUsedSpace_Gb (DECIMAL (10,1)) AS "Effective Used Space (GB)",
Current_Perm_Percent AS "Current Perm %",
(Max_perm_gb (DECIMAL (10,1))) -( current_perm_gb (DECIMAL (10,1))) as "unused space in GB" ,
(100) - (Current_Perm_Percent)  as "unused %",
Peak_Perm_Gb (DECIMAL (10,1)) AS "Peak Perm (GB)",
Peak_Perm_Percent AS "Peak Perm %",
D_SKEW AS "Skew %"
FROM
(
SELECT
databasename, SUM(maxperm)/1024/1024/1024 AS Max_Perm_Gb,
SUM(currentperm)/1024/1024/1024 AS Current_Perm_Gb,
MAX(currentperm)*COUNT(*) /1024/1024/1024 AS EffectiveUsedSpace_Gb,
Current_Perm_Gb/Max_Perm_Gb * 100 AS Current_Perm_Percent,
SUM(peakperm)/1024/1024/1024 AS Peak_Perm_Gb,
Peak_Perm_Gb/Max_Perm_Gb * 100 AS Peak_Perm_Percent,
ZEROIFNULL((MAX(currentperm) - AVG(currentperm))/MAX(NULLIFZERO(currentperm)) * 100) AS D_SKEW
FROM dbc.diskspace
GROUP BY 1
) a
ORDER BY 2 DESC;

Friday, October 19, 2012

prepare script for enabling and disabling trigger in teradata


This kind of scripts are required when the system is going for maintenance.

SELECT 'Alter trigger '|| TRIM(databasename) || '.' || TRIM(triggername) || ' Disabled' ||';'
FROM dbc.triggers
WHERE  Enabledflag = 'Y'
ORDER BY databasename, tablename, triggername;

Thursday, October 18, 2012

List of Teradata Database Access Rights


Here is list of access right and their full-form.

AE = ALTER EXTERNAL PROCEDURE
AF = ALTER FUNCTION
AP = ALTER PROCEDURE
AS = ABORT SESSION
CA = CREATE AUTHORIZATION
CD = CREATE DATABASE
CE = CREATE EXTERNAL PROCEDURE
CF = CREATE FUNCTION
CG = CREATE TRIGGER
CM = CREATE MACRO
CO = CREATE PROFILE
CP = CHECKPOINT
CR = CREATE ROLE
CT = CREATE TABLE
CU = CREATE USER
CV = CREATE VIEW
D = DELETE
DA = DROP AUTHORIZATION
DD = DROP DATABASE
DF = DROP FUNCTION
DG = DROP TRIGGER
DM = DROP MACRO
DO = DROP PROFILE
DP = DUMP
DR = DROP ROLE
DT = DROP TABLE
DU = DROP USER
DV = DROP VIEW
E = EXECUTE
EF = EXECUTE FUNCTION
GC = CREATE GLOP
GD = DROP GLOP
GM = GLOP MEMBER
I = INSERT
IX = INDEX
MR = MONITOR RESOURCE
MS = MONITOR SESSION
NT = NONTEMPORAL
OD = OVERRIDE DELETE POLICY (Reserved for future use)
OI = OVERRIDE INSERT POLICY (Reserved for future use)
OP = CREATE OWNER PROCEDURE
OS = OVERRIDE SELECT POLICY (Reserved for future use)
OU = OVERRIDE UPDATE POLICY (Reserved for future use)
PC = CREATE PROCEDURE
PD = DROP PROCEDURE
PE = EXECUTE PROCEDURE
R = RETRIEVE/SELECT
RF = REFERENCE
RO = REPLCONTROL
RS = RESTORE
SA = SECURITY CONSTRAINT ASSIGNMENT
SD = SECURITY CONSTRAINT DEFINITION
SH = SHOW
SR = SET RESOURCE RATE
SS = SET SESSION RATE
ST = STATISTICS
TH = CTCONTROL
U = UPDATE
UM = UDT Method
UT = UDT Type
UU = UDT Usage

Wednesday, October 17, 2012

Teradata Show lock utility


When A table or database is being backed up, it put a HUT lock on the object, which is released when it finishes backup successfully. But sometime when backup fails or aborted HUT lock be there and query on those objects goes into blocking.  One way of find and release lock on object is to login into one of the node and use show lock utility.

Here is the steps we can follow...

1. start CNSTERM 6 by typing "cnsterm 6"


UAT2_1-9:/var/opt/teradata/DEV_108 # cnsterm 6
Attempting to connect to CNS...Completed.
Hello
Started 'dip' in window 1
 at Tue Oct 16 04:03:29 2012


Input Supervisor Command:
start updatedbc

Started 'updatedbc' in window 1
 at Tue Oct 16 04:18:18 2012


Input Supervisor Command:
enable all logons

12/10/16 05:11:03 Logons enabled.
Enable Logons of screen debug in ctl have been updated to All.


Input Supervisor Command:
start dip

Started 'dip' in window 1
 at Tue Oct 16 05:19:50 2012

2. Start "showlock utility" by typing "start showlocks" on CNSTERM 6 terminal.


Input Supervisor Command:
> start showlocks
start showlocks

Started 'showlocks' in window 1
 at Wed Oct 17 09:22:22 2012


Input Supervisor Command:
> 

 3. Start CNSTERM 1 in different putty session to see the hut lock..



UAT2_1-9:/var/opt/teradata/DEV_108 # cnsterm 1
Attempting to connect to CNS...Completed.
Hello
    USER arcuser4   MODE Excl     AMP All Amps

GL_TB.TRUNK_GS_SUMMARY
    USER arcuser4   MODE Excl     AMP All Amps

GL_TB.VERTICAL
    USER arcuser4   MODE Excl     AMP All Amps

GL_TB.ZZZ_GL_PARAMETER
    USER arcuser4   MODE Excl     AMP All Amps

GL_TB.ZZZ_TB_BI_DIM_STORE
    USER arcuser4   MODE Excl     AMP All Amps

GL_TB.ZZZ_TB_BI_DIM_STORE_OPER_HRS
    USER arcuser4   MODE Excl     AMP All Amps

GL_TB.base64
    USER arcuser4   MODE Excl     AMP All Amps

              --ShowLocks Processing Complete--

Now, once we get the list of object having HUT lock, we can login into the "arcmain" session and put release lock command on those object.

4. type "arcmain" and enter

5. type  “Logon 10.12.88.120/arcuser4,password;”

6. type “Release lock (GL_TB.TRUNK_GS_SUMMARY);”

7. Logoff;