Professional Documents
Culture Documents
1. Identify and collect Missing stats based on Join columns, PI/SI Indexes, and filter columns............................2
2. Identify and Refresh Old/Obsolete (more than 10% volume change) and incorrect stats on tables................2
3. Collect statistics on VALUE ORDERED INDEXED columns and DATE columns after loading data.......................3
4. Verify DDL for table - check PIs PI joins are better.........................................................................................3
5. Sample SQL to check for data skew based on PI and joins................................................................................3
6. Look into filtering the data, avoiding functions in joins, changing joins, and splitting the query......................3
7. Sample SQL - Database and Account settings...................................................................................................3
8. Sample SQL - View DDLs for table and view.....................................................................................................4
9. Sample SQL - Space by Database......................................................................................................................4
10. Sample SQL - Perm Space, Skew Ness, LastAccessDate, and LastAlterDate by Table...................................4
11. Sample SQL - Indexes by Table......................................................................................................................4
12. Sample SQL - Database Logs.........................................................................................................................4
13. Sample SQL - Skew ness by Spool Space.......................................................................................................5
14. Sample SQL - High CPU usage and Skew ness by CPU Usage........................................................................5
15. Sample SQL - High IO usage and Skew ness by IO Usage View DDLs for table and view...............................6
16. Sample SQL - Verify roles..............................................................................................................................7
17. Sample SQL - Verify Accounts/Users to which a Role is granted...................................................................7
18. Sample SQL - Verify Roles granted to an Account/User................................................................................7
19. Sample SQL - Verify privileges of a role (database/table level access to roles).............................................7
20. Sample SQL - Verify access granted to users without using roles (direct database/table level privileges)....7
21. Sample SQL - Verify access granted to users using Roles..............................................................................7
22. Sample SQL - Verify Objects created after DDL implementation View DDLs for table and view...................8
23. Sample SQL - Verify data distribution by amp based on existing PI or proposed PI......................................8
explain
<SQL>
2. Identify and Refresh Old/Obsolete (more than 10% volume change) and
incorrect stats on tables.
help stats MARCOM_INC.DM_PROMO_HIST;
Old stats:
Date Time Unique values Column Names
09/03/03 00:36:59 0 COMMUNICATION_ID,MARCOM_VENDOR_ID
New stats:
09/12/16 00:18:44 5,141,919 COMMUNICATION_ID,MARCOM_VENDOR_ID
Example:
HASHAMP(HASHBUCKET(HASHROW(SVC_TAG_ID))) Count(*)
---------------------------------------- -----------
166 120808
104 82918
50 62066
305 25793
16 21117
261 16997
300 11208
191 6881
219 6546
21 5617
299 4472
6. Look into filtering the data, avoiding functions in joins, changing joins, and
splitting the query.
10. Sample SQL - Perm Space, Skew Ness, LastAccessDate, and LastAlterDate
by Table
select * from DBA_TOOLS.TableSpace where databasename in ('DFSDWIR_T','DFSDWIR_INC_T')
order by 1,2;
select a.LogDate
,a.UserName
,a.AccountName
,a.PEAKSPOOL
,a.PEAKSPOOLSKEW
,(a.PeakSPOOL/800) AvgVProcSpool
,( (a.PeakSPOOL/800) / (1- (peakspoolskew/100)) ) MaxVprocspool
,(MaxVprocspool*800) SpoolReqDueToSkew
,a.MAXSPOOL
from pdcrinfo.Spoolspace_Hst a
where a.username='SERVICE_SRA_ETL'
and LogDate between '2010-08-01' and '2010-09-12'
order by 1 desc;
14. Sample SQL - High CPU usage and Skew ness by CPU Usage
SEL
LogDate,
UserName,
SessionID,
RequestNum,
AMPCPUTime,
MaxAMPCPUTime,
MinAMPCPUTime,
(AMPCPUTime/800) as AvgCPUTime,
(100 - ((AvgCPUTime/NULLIFZERO(MaxAMPCPUTime) )*100) ) as CPUSkewFactor,
substring(querytext from 1 for 100)
FROM PDCRINFO.DBQLogTbl
SEL
substring(querytext from 1 for 100) as QueryText100,
Avg(100 - (((AMPCPUTime/800)/NULLIFZERO(MaxAMPCPUTime) )*100)) as AvgCPUSkewFactor,
count(*) as QryCount,
Max(LogDate) as MaxLogDate,
Min(LogDate) as MinLogDate,
Avg(AMPCPUTime) as AvgAMPCPUTime,
Avg(MaxAMPCPUTime) as AvgMaxAMPCPUTime,
Avg(MinAMPCPUTime) as AvgMinAMPCPUTime,
Avg((AMPCPUTime/800)) as AvgAvgCPUTime
FROM PDCRINFO.DBQLogTbl
WHERE username in ('SERVICE_SRA_ETL')
and LogDate between '2010-08-01' and '2010-09-12'
and AMPCPUTime >800
and (100 - (((AMPCPUTime/800)/NULLIFZERO(MaxAMPCPUTime) )*100) ) >30
group by 1
15. Sample SQL - High IO usage and Skew ness by IO Usage View DDLs for
table and view
SEL
LogDate,
UserName,
SessionID,
RequestNum,
TotalIOCount,
MaxAMPIO,
MinAMPIO,
(TotalIOCount/800) as AvgIO,
(100 - ((AvgIO/NULLIFZERO(MaxAMPIO) )*100) ) as IOSkewFactor,
substring(querytext from 1 for 100)
FROM PDCRINFO.DBQLogTbl
WHERE username in ('SERVICE_SRA_ETL')
and LogDate between '2010-08-09' and '2010-08-15'
and TotalIOCount >100000
and IOSkewFactor>20
group by 1,2,3,4,5,6,7,8,10
order by 9 desc;
SEL
substring(querytext from 1 for 100) as QueryText100,
22. Sample SQL - Verify Objects created after DDL implementation View
DDLs for table and view
select databasename (format 'x(18)') , tablename (format 'x(27)') as ObjectName,
(case when TableKind ='T' then 'table'
when TableKind ='V' then 'view'
when TableKind ='M' then 'macro'
when TableKind ='P' then 'Procedure'
else null
end) as ObjectKind,
lastaltertimestamp, createtimestamp
from dbc.tables
where ( cast(createtimestamp as date) =date or cast(LastAlterTimeStamp as date) =date )
and trim(databasename) like 'DFSDWIR%'
order by 1,2,3,4;
Ex:
select HASHAMP(HASHBUCKET(HASHROW(SVC_TAG_ID ,ORDER_BUSINESS_UNIT_ID))),count(*)
from GBL_APOS_MART_INC_T.APOS_EMEA_4_FINAL
group by 1
order by 2;