workload management api

454
Teradata Database Workload Management API: PM/API and Open API Release 13.0 B035-1090-098A April 2009

Upload: bajmi

Post on 26-May-2015

962 views

Category:

Technology


1 download

DESCRIPTION

Teradata Workload management API

TRANSCRIPT

Page 1: Workload management api

Teradata Database

Workload Management API:PM/API and Open API

Release 13.0B035-1090-098A

April 2009

Page 2: Workload management api

The product or products described in this book are licensed products of Teradata Corporation or its affiliates.

Teradata, BYNET, DBC/1012, DecisionCast, DecisionFlow, DecisionPoint, Eye logo design, InfoWise, Meta Warehouse, MyCommerce, SeeChain, SeeCommerce, SeeRisk, Teradata Decision Experts, Teradata Source Experts, WebAnalyst, and You’ve Never Seen Your Business Like This Before are trademarks or registered trademarks of Teradata Corporation or its affiliates.

Adaptec and SCSISelect are trademarks or registered trademarks of Adaptec, Inc.

AMD Opteron and Opteron are trademarks of Advanced Micro Devices, Inc.

BakBone and NetVault are trademarks or registered trademarks of BakBone Software, Inc.

EMC, PowerPath, SRDF, and Symmetrix are registered trademarks of EMC Corporation.

GoldenGate is a trademark of GoldenGate Software, Inc.

Hewlett-Packard and HP are registered trademarks of Hewlett-Packard Company.

Intel, Pentium, and XEON are registered trademarks of Intel Corporation.

IBM, CICS, RACF, Tivoli, and z/OS are registered trademarks of International Business Machines Corporation.

Linux is a registered trademark of Linus Torvalds.

LSI and Engenio are registered trademarks of LSI Corporation.

Microsoft, Active Directory, Windows, Windows NT, and Windows Server are registered trademarks of Microsoft Corporation in the United States and other countries.

Novell and SUSE are registered trademarks of Novell, Inc., in the United States and other countries.

QLogic and SANbox are trademarks or registered trademarks of QLogic Corporation.

SAS and SAS/C are trademarks or registered trademarks of SAS Institute Inc.

SPARC is a registered trademark of SPARC International, Inc.

Sun Microsystems, Solaris, Sun, and Sun Java are trademarks or registered trademarks of Sun Microsystems, Inc., in the United States and other countries.

Symantec, NetBackup, and VERITAS are trademarks or registered trademarks of Symantec Corporation or its affiliates in the United States and other countries.

Unicode is a collective membership mark and a service mark of Unicode, Inc.

UNIX is a registered trademark of The Open Group in the United States and other countries.

Other product and company names mentioned herein may be the trademarks of their respective owners.

THE INFORMATION CONTAINED IN THIS DOCUMENT IS PROVIDED ON AN “AS-IS” BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY NOT APPLY TO YOU. IN NO EVENT WILL TERADATA CORPORATION BE LIABLE FOR ANY INDIRECT, DIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS OR LOST SAVINGS, EVEN IF EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

The information contained in this document may contain references or cross-references to features, functions, products, or services that are not announced or available in your country. Such references do not imply that Teradata Corporation intends to announce such features, functions, products, or services in your country. Please consult your local Teradata Corporation representative for those features, functions, products, or services available in your country.

Information contained in this document may contain technical inaccuracies or typographical errors. Information may be changed or updated without notice. Teradata Corporation may also make improvements or changes in the products or services described in this information at any time without notice.

To maintain the quality of our products and services, we would like your comments on the accuracy, clarity, organization, and value of this document. Please e-mail: [email protected]

Any comments or materials (collectively referred to as “Feedback”) sent to Teradata Corporation will be deemed non-confidential. Teradata Corporation will have no obligation of any kind with respect to Feedback and will be free to use, reproduce, disclose, exhibit, display, transform, create derivative works of, and distribute the Feedback and derivative works thereof without limitation on a royalty-free basis. Further, Teradata Corporation will be free to use any ideas, concepts, know-how, or techniques contained in such Feedback for any purpose whatsoever, including developing, manufacturing, or marketing products or services incorporating Feedback.

Copyright © 2000 – 2009 by Teradata Corporation. All Rights Reserved.

Page 3: Workload management api

Workload Management API: PM/API and Open API 3

Preface

Purpose

This book, Workload Management API: PM/API and Open API, describes the workload management application programming interface (API), which consists of interfaces to System Performance Monitor and Production Control (PMPC), also called PM/APIs, and open APIs.

Use the workload management APIs described in this book to interface with your own custom applications when performance monitoring tools such as Performance Monitor (PMON) or the Resource Usage (ResUsage) reports do not provide the information you need.

Audience

This book is intended for developers creating third-party applications, and end-users writing their own custom applications, requiring the acquisition and use of Teradata Database workload management and performance data.

Supported Software Release

This book supports Teradata® Database 13.0.

Prerequisites

Users of the PM/API should have some knowledge of Call-Level Interface version 2 (CLIv2), basic Teradata SQL terminology, and overall Teradata Database architectural concepts.

Information on CLIv2 is available in the following books:

• Teradata Call-Level Interface Version 2 Reference for Channel-Attached Systems

• Teradata Call-Level Interface Version 2 Reference for Network-Attached Systems

• Database Design

For sample programs using CLI, see Appendix A: “Sample PM/API Application.”

Page 4: Workload management api

PrefaceChanges to This Book

4 Workload Management API: PM/API and Open API

Changes to This Book

Release Description

Teradata Database 13.0

April 2009

• Added the ProxyUser field and examples to the MONITOR SESSION, MonitorSession, and MonitorMySessions sections.

• Changed the monitor software version ID value to 7 on all PM/API mon_ver_id fields.

• Added Response Group V data fields to the MONITOR SESSION section.

• Added the VSS vproc to the VprocType field and the SubPoolId to the SessLogCount field in the MONITOR VIRTUAL RESOURCE and MonitorVirtualResource sections.

• Added to the NVMemAllocSegs field description how the value is computed for the vproc-level on Windows and Linux and a note stating that this field is called “Max I/O Time” in PMON and “Maximum I/O Time” in MONITOR VIRTUAL RESOURCE and MonitorVirtualResource.

• Updated some of the field descriptions to include the VSS vproc for MONITOR VIRTUAL CONFIG and MonitorVirtualConfig.

• Updated the TDWM STATISTICS, TDWMThrottleStatistics, and TDWMGetDelayedQueries sections with new fields and example outputs.

Teradata Database 12.0

September 2007

• Added a note to the MONITOR SESSION section, which lists the AMP CPU fields in the MONITOR SESSION response that are normalized for the current release.

• Renamed the DeltaAmpSpool field to “Request_AMPSpool” in MonitorSession and MonitorMySessions.

• Added two PEState response values: SESDELAYED and QTDELAYED.

• Added open APIs to the following chapters: “PMPC APIs,” “Teradata Dynamic Workload Management APIs,” and “Query Band APIs.

• Added the following PM/APIs: EVENT STATUS, USER EVENT CONTROL, MONITOR AWT RESOURCE, and updated existing APIs in the “Teradata Dynamic Workload Management APIs” chapter.

Page 5: Workload management api

PrefaceAdditional Information

Workload Management API: PM/API and Open API 5

Additional Information

To maintain the quality of our products and services, we would like your comments on the accuracy, clarity, organization, and value of this document. Please e-mail: [email protected]

References to Microsoft Windows and Linux

This book refers to “Microsoft Windows” and “Linux.” For Teradata Database 13.0, these references mean:

• “Windows” is Microsoft Windows Server 2003 64-bit.

• “Linux” is SUSE Linux Enterprise Server 9 and SUSE Linux Enterprise Server 10.

URL Description

http://www.info.teradata.com/ Use the Teradata Information Products Publishing Library site to:

• View or download a manual:

1 Under Online Publications, select General Search.

2 Enter your search criteria and click Search.

• Download a documentation CD-ROM:

1 Under Online Publications, select General Search.

2 In the Title or Keyword field, enter CD-ROM, and click Search.

• Order printed manuals:

Under Print & CD Publications, select How to Order.

http://www.teradata.com The Teradata home page provides links to numerous sources of information about Teradata. Links include:

• Executive reports, case studies of customer experiences with Teradata, and thought leadership

• Technical information, solutions, and expert advice

• Press releases, mentions and media resources

http://teradatauniversitynetwork.com Teradata University Network fosters education on data warehousing, business intelligence (BI) and database administration (DBA).

Page 6: Workload management api

PrefaceReferences to Microsoft Windows and Linux

6 Workload Management API: PM/API and Open API

Page 7: Workload management api

Workload Management API: PM/API and Open API 7

Table of Contents

Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3

Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3

Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3

Supported Software Release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3

Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3

Changes to This Book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4

Additional Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5

References to Microsoft Windows and Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5

Chapter 1: Workload Management Concepts and Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

What the Workload Management API Provides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

What PM/API Is . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Disadvantages of Using PM/API. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

What the Open API Is. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Differences Between Open API and PM/API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

System PMPC Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

Setting Sampling and Logging Intervals. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

System-Level Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Session-Level Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Monitoring Locks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Teradata Dynamic Workload Management Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Query Banding Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

System PMPC Applications Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Resource Supervisor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Idle Session Logoff . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

Workload Management API Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

Query Band API Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

API Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

System PMPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Teradata Dynamic Workload Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Query Bands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Page 8: Workload management api

Table of Contents

8 Workload Management API: PM/API and Open API

Requirements for Using the API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31

CLIv2 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31

SQL Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31

Required Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31

Chapter 2: MONITOR Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33

PM/API Request Processing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33

Creating a Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33

Setting Indicator or Record Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34

Response Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35

Parcel Ordering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35

Buffer Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36

Abort Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37

Logging On . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38

Logging Off . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39

Warning and Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39

Comparisons Between PM/API and Teradata SQL Requests . . . . . . . . . . . . . . . . . . . . . . . . . . .39

Similarities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39

Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39

Keywords/Reserved Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .40

Teradata SQL Users Can Issue GRANT and REVOKE . . . . . . . . . . . . . . . . . . . . . . . . . . . .40

PM/API Users Can Issue ABORT SESSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41

PM/API Dynamic Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41

Monitoring Rates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42

Session-Level Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42

Resource Usage Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42

Logging Resource Usage Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43

Sampling and Logging Rates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .45

Chapter 3: PMPC APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49

CLIv2 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50

Common Warning and Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50

ABORT SESSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54

IDENTIFY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67

MONITOR AWT RESOURCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75

MONITOR PHYSICAL CONFIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82

MONITOR PHYSICAL RESOURCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88

Page 9: Workload management api

Table of Contents

Workload Management API: PM/API and Open API 9

MONITOR PHYSICAL SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

MONITOR SESSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

How Session Data is Collected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

Unreported Session Partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

A Down Processor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

Internal Sessions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

Response Parcel Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

MONITOR SQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

MONITOR VERSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

MONITOR VIRTUAL CONFIG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

MONITOR VIRTUAL RESOURCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

MONITOR VIRTUAL SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

SET RESOURCE RATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

SET SESSION ACCOUNT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204

SET SESSION RATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

SQL Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

AbortSessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

AbortListSessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220

IdentifyDatabase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223

IdentifySession . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224

IdentifyTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

IdentifyUser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

MonitorAWTResource. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

MonitorMySessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

MonitorPhysicalConfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245

MonitorPhysicalResource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247

MonitorPhysicalSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

MonitorSession . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262

MonitorSessionRate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276

MonitorSQLCurrentStep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

MonitorSQLSteps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280

MonitorSQLText. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

MonitorVirtualConfig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

MonitorVirtualResource . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

MonitorVirtualSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297

SetResourceRate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305

SetSessionAccount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308

SetSessionRate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310

Page 10: Workload management api

Table of Contents

10 Workload Management API: PM/API and Open API

Chapter 4: Teradata Dynamic Workload Management APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .311

CLIv2 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .312

EVENT STATUS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .313

PERFGROUPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .321

TDWM DELAY REQUEST CHANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .325

TDWM LIST WD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .329

TDWM STATISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333

TDWM SUMMARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .341

TDWM WD ASSIGNMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .345

USER EVENT CONTROL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .349

SQL Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .352

TDWMAbortDelayedRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .353

TDWMApply. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .355

TDWMAssignWD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .357

TDWMEventControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .359

TDWMEventMapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .361

TDWMEventStatus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .363

TDWMGetDelayedQueries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .367

TDWMGetDelayedUtilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .370

TDWMInquire . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .372

TDWMListWDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .373

TDWMLoadUtilStatistics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .375

TDWMObjectAssn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .376

TDWMReleaseDelayedRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .378

TDWMRuleControl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .380

TDWMSetLimits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .381

TDWMSummary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .382

TDWMSummaryRate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .384

TDWMThrottleStatistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385

Chapter 5: Query Band APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .389

CLIv2 Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .390

MONITOR QUERYBAND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .391

SQL Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .395

Page 11: Workload management api

Table of Contents

Workload Management API: PM/API and Open API 11

GetQueryBand. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396

GetQueryBandPairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397

GetQueryBandSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399

GetQueryBandValue. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400

GetQueryBandValueSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402

MonitorQueryBand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403

Appendix A: Sample PM/API Application . . . . . . . . . . . . . . . . . . . . . . . 405

Sample Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405

Header File for Sample PMPC Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419

Appendix B: Combination PEState and AMPState Response Values for MONITOR SESSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431

Sample MONITOR SESSION Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437

Page 12: Workload management api

Table of Contents

12 Workload Management API: PM/API and Open API

Page 13: Workload management api

Workload Management API: PM/API and Open API 13

CHAPTER 1 Workload ManagementConcepts and Features

This chapter provides an overview of the workload management application programming (API) interface. It describes the functionality and features of the System Performance Monitor and Production Control (PMPC), Teradata Dynamic Workload Management, and Query Band APIs.

What the Workload Management API Provides

The workload management API consists of interfaces to System PMPC and open APIs. These interfaces are used with client components (for example, Teradata Manager, Teradata Dynamic Workload Manager, and Performance Monitor [PMON]) to:

• Monitor system and session-level activities.

• Manage Teradata Dynamic Workload Management rules and update components stored in a custom database called TDWM. The TDWM database is shared by Teradata Dynamic Workload Manager and Teradata Query Scheduler. For more information about TDWM, see Teradata Dynamic Workload Manager User Guide.

• Track system usage and manage task priorities.

For a complete description of the programming interfaces used to perform these functions, see:

• “Chapter 3 PMPC APIs” on page 49

• “Chapter 4 Teradata Dynamic Workload Management APIs” on page 311

• “Chapter 5 Query Band APIs” on page 389

For more information on the features of the workload management API, see:

• “System PMPC Features” on page 16

• “Teradata Dynamic Workload Management Features” on page 19

• “Query Banding Features” on page 22

What PM/API Is

PM/API provides access to PMPC routines resident within Teradata Database. The PMPC subsystem is available through a logon partition called MONITOR, using a specialized PM/API subset of Call-Level Interface version 2 (CLIv2).

Page 14: Workload management api

Chapter 1: Workload Management Concepts and FeaturesWhat the Open API Is

14 Workload Management API: PM/API and Open API

The PM/API, and applications built around it (such as PMON and Teradata Manager), have the following advantages:

• CLIv2 data is acquired in near real time, with less overhead, and with minimal possibility of being blocked. These capabilities allow frequent in-process performance analysis.

• A CLIv2 interface saves the raw data in an in-memory buffer where a client application program can easily retrieve the data for real-time analysis or importing into custom reports.

• A CLIv2 interface provides access to data that the resource usage does not, for example, session-level resource usage data, and data on application locks and which application is being blocked.

Use of the PM/API may not be the right choice for all performance monitoring requirements. Standard performance monitoring tools and reports (such as resource usage macros and tables) may be sufficient.

For more information on how the PMPC subsytem manages CLIv2 interfaces, see:

• “Teradata Dynamic Workload Management Features” on page 19

• “PM/API Request Processing” on page 33

Disadvantages of Using PM/API

Some of the disadvantages of using the PM/API include:

• A custom CLI application in C or some other programming language must be written.

• CLIv2 interface data is not as detailed as resource usage data.

• CLIv2 interface data is not written to tables; therefore, whatever resource usage data is not examined at the end of a particular sample interval may be overwritten and lost.

• Large amounts of CLIv2 interface data cannot be accumulated over a long period of time and, therefore, cannot be used for the following:

• Examining trends and patterns

• Planning system upgrades

• Deciding when to add new applications to heavily utilized systems

• Building baseline resource usage profiles for operations

Note: CLIv2 interface trend data can be collected and saved into tables by Teradata Manager.

What the Open API Is

The open API provides an SQL interface to System PMPC through user-defined functions (UDFs) and external stored procedures.

The following are examples of some of the UDFs and external stored procedures used:

Page 15: Workload management api

Chapter 1: Workload Management Concepts and FeaturesWhat the Open API Is

Workload Management API: PM/API and Open API 15

Most of the SQL interfaces available to System PMPC provide similar functionality to the CLIv2 interfaces.

Note: Most open APIs do not follow transaction rules. If, within a transaction, a UDF or external stored procedure is called that performs an action (for example, setting a session account string) and the transaction rolls back, the action of the UDF or external stored procedure is not rolled back.

However, those interfaces that update the Teradata Dynamic Workload Management database, such as the TDWMRuleControl, TDWMObjectAssn, and TDWMSetLimits procedures, must follow transaction rules. If one of these interfaces is called within a transaction, the update will be rolled back if the transaction is aborted.

Differences Between Open API and PM/API

The following table describes the differences between the open API (that is, SQL interfaces consisting of UDFs or external stored procedures) and the PM/API.

Use the ... To ...

AbortSessions function abort queries submitted by a set of users that have been running longer than 10 minutes and have been skewed by more than 10% for 5 minutes.

TDWMRuleControl function temporarily enable a rule to block an application from accessing a database while it is synchronized between two active systems.

GetQueryBandValue procedure query the DBQLogTbl based on specified names and values in the QueryBand field.

Open APIs ... WHERE PM/APIs ...

are issued in the current SQL partition require logging on to the MONITOR partition.

require EXECUTE privilege on the function or external stored procedure

require MONITOR privileges.

use SQL parsing, dispatching steps, and UDF processing

require use of a custom CLI application in C or some other programming language.

run in priority of account string or Teradata Dynamic Workload Management classification

run in the system priority.

can be placed on a Teradata Dynamic Workload Management delay queue and can block system resources

do not block.

use AMP Worker Tasks (AWTs) are not subject to running out of resources (AWTs).

Page 16: Workload management api

Chapter 1: Workload Management Concepts and FeaturesSystem PMPC Features

16 Workload Management API: PM/API and Open API

Related Topics

For more information on the SQL interfaces described in this section, see:

• Chapter 3: “PMPC APIs”

• Chapter 4: “Teradata Dynamic Workload Management APIs”

• Chapter 5: “Query Band APIs”

System PMPC Features

The section explains the most important System PMPC features.

Setting Sampling and Logging Intervals

Performance monitoring tasks (except MONITOR VERSION and MONITOR SQL) are based on periodic data collection. The rates at which the data is gathered (sample rate) and written to tables (logging rate), are set separately.

You can control two session-level sampling rates, two resource usage sampling rates, and two resource logging rates. You can set all sampling rates for any interval between 0 and 3600 seconds. For other rules governing the relationship between data collection and logging rates, see Resource Usage Macros and Tables.

A single master resource sampling system within the Teradata Database collects all performance monitoring data. It can be accessed in a number of ways, such as using CLIv2 or SQL interfaces. Sampling rates that are set this way may be reset by way of other performance monitoring utilities, including PMON, RSSMON, and Database Window.

If this happens, warning messages are returned in cases where parameters have been changed (external to the PMPC application) since the last sampling interval. Care should be taken to integrate the various performance monitoring tasks on your system to avoid potential conflicts.

Note: Because system-wide AMP/PE and node resource usage data is collected in different memory repositories than session-level data, changes in the resource collection rate have no impact on session-level usage data, and vice versa.

The following table describes the various types of monitoring rates that are set usingthe SET RESOURCE RATE request or the SetResourceRate function.

Page 17: Workload management api

Chapter 1: Workload Management Concepts and FeaturesSystem PMPC Features

Workload Management API: PM/API and Open API 17

• Data sampling rates must be set to a nonzero value for all data fields called by a CLIv2 or SQL interface or the fields will not contain any data.

• The logging rate should be set to one or more even multiples of the sample rate so that old data is not written to tables.

• Resource logging rate capability allows you to set the logging rate for resource usage data. Because all rates, except for the local session monitoring rate, are saved on disk every time they are altered, they are “remembered” during restarts.

• The Virtual and Physical Resource rates must be the same, but not for the Logging rates.

Related Topics

For comparative information on setting sample and logging rates among various performance monitoring alternatives, see:

• “Database Window (xdbw)” in Utilities

• Resource Usage Macros and Tables

• SQL Data Definition Language

• Teradata Dynamic Workload Manager User Guide

Rate Description

Global session (SesMonitorSys) monitoring

Sets the system-wide (across all sessions) frequency at which session-level data is updated.

Local session (SesMonitorLoc) monitoring

Sets the frequency at which session-level data is updated with your session. This rate is not saved on disk and is lost during a system outage.

Note: A change to the local sampling rate could affect the cumulative data that other users see because all session usage data is stored in the same memory repository.

Because changes to either the system or local rate can reset the starting point at which data is collected and may alter cumulative session usage data, it is important to restrict the granting of session monitoring privilege to users trained in the use of system monitoring tools, for example, the system or database administrator or certain application programmers.

Virtual Resource (ResMonitor) monitoring

Sets the frequency at which AMP and PE resource usage data is updated.

Physical Resource (ResMonitor) monitoring

Sets the frequency at which node resource usage data is updated.

Virtual Resource Usage (ResLogging) logging

Sets the frequency at which AMP and PE resource usage data is written to the ResUsage tables.

Physical Resource Usage (ResLogging) logging

Sets the frequency at which node resource usage data is written to the ResUsage tables.

Page 18: Workload management api

Chapter 1: Workload Management Concepts and FeaturesSystem PMPC Features

18 Workload Management API: PM/API and Open API

System-Level Monitoring

System PMPC allows you to perform two types of system monitoring:

• Physical resources

• Nodes availability

• BYNET availability

• General system utilization

• Virtual resources (vprocs)

• Access Module Processor (AMP) status, performance and utilization

• Parsing Engine (PE) status, performance and utilization

The way that AMP/PE and node resource data is collected and reported is different from the way that session resource data is collected and reported. Both CLIv2 and SQL interfaces collect resource utilization data for a specific sample period and report the data for that sample period. For example, if you set the resource usage sampling interval to 60 seconds and issue a MONITOR VIRTUAL RESOURCE request (or a MonitorVirtualResource function) or MONITOR PHYSICAL RESOURCE request (or MonitorPhysicalResource function), a report is issued for that specific 60-second interval.

Any data you do not examine within the 60 seconds is lost when it is overwritten by data collected during the next 60-second sampling interval.

The AMP/PE and node resource usage data and session-level usage data are deposited in separate global data collection areas. The data in the repository is updated once each sampling period. All users share the data, which is used to generate responses to both queries and CONTINUE requests.

Session-Level Monitoring

Session-level monitoring tasks return the following information:

• Identification of blocking users, sessions and locked databases or tables

• Session-level usage data on:

• AMPs

• CPUs

• Identification of problem SQL requests, including:

• Current session

• Current step

• SQL text EXPLAIN data

As the number of sessions, nodes, AMPs, and PEs you monitor increases, system performance may start to decrease.

Session-level utilization data is collected cumulatively. The sampling period is used to limit the frequency at which cumulative data is updated. For example, if you set the session usage sampling interval to 60 seconds and issue a MONITOR SESSION request, session-level usage

Page 19: Workload management api

Chapter 1: Workload Management Concepts and FeaturesTeradata Dynamic Workload Management Features

Workload Management API: PM/API and Open API 19

data is cumulatively totaled and updated every 60 seconds. The session-level data reported includes data for the beginning 60 seconds as well as for subsequent intervals.

Monitoring Locks

Locks may occur when sessions, utilities, and applications being run by specific users block access to databases or tables normally available from the Teradata Database. Interfaces to System PMPC can help you monitor locks.

To help determine the user causing a block and the locked database or table, you can use the MONITOR SESSION request or the MonitorSession function. Then, to get more specific information about the blocking session and the object being blocked, you can use the IDENTIFY request or IdentifySession, IdentifyUser or IdentifyTable functions.

To learn more about the interfaces used to perform these functions, see Chapter 3: “PMPC APIs.”

Teradata Dynamic Workload Management Features

Teradata Dynamic Workload Management is a rule-oriented management system capable of detecting and acting on events. It is a key component of Teradata Active System Management (Teradata ASM).

Teradata ASM is a set of products, including system tables and logs, that interact with each other and a common data source. It helps manage the system automatically and reduces the effort required by database administrators, application developers, and support personnel. Teradata ASM can improve and optimize your workload management and performance. It can also improve response times and ensure more consistent response times for critical work.

Teradata Dynamic Workload Management is implemented with two components related to Teradata DWM rules:

• A client component that provides a graphical user-interface for rules configuration (for example, Teradata Manager and Teradata Dynamic Workload Manager [Teradata DWM]).

• A server component within Teradata Database that enforces the rules.

It provides database administrators the ability to regulate system events through an event/state methodology (where an event is any condition or indication that is pertinent to workload management and a state is a complete set of working values for a rule set).

Teradata Dynamic Workload Management uses events to manage a system. These events are separated into two classes: system conditions (SysCon) and operating environments (OpEnv).

Events are found under System Regulation in Teradata Dynamic Workload Manager (Teradata DWM) and provide the following functionality:

• Detect various hardware failures

• Monitor the system flow control and AWT thresholds

Page 20: Workload management api

Chapter 1: Workload Management Concepts and FeaturesTeradata Dynamic Workload Management Features

20 Workload Management API: PM/API and Open API

• Change the state of the system that in turn can automatically adjust throttle values of rules

• Declare user-defined events that can change the system state

When event combinations (that is, one or more events) occur, the variable attributes of Teradata Dynamic Workload Management rules defined by the database administrator can be affected. The behavior of the rules can also be affected through interfaces to Teradata Dynamic Workload Management, or through Teradata Manager.

The defined set of rules cause the database to classify and prioritize incoming requests. The database delays or denies the processing of some requests when system activity levels are too high to make the most efficient use of database resources and, therefore, enhance system performance.

For more information about event classes, states, rule sets, and event combinations, see Teradata Dynamic Workload Manager User Guide.

The following table describes the three categories of Teradata Dynamic Workload Management rules.

Category Name Description

1 Filters Denies requests based on the following:

• The database object the query is attempting to access

• The database resources required to process the query

Filters are state-based; that is, any change to the state of the system can cause the Category 1 rule to be enabled or disabled. For details, see Teradata Dynamic Workload Manager User Guide.

When the request is restricted by a filter, it is rejected by the database and an error message is returned to the user.

Note: Filter rules are checked first by the system. For example, if a query passes those rules defined, then it is permitted to run.

2 Throttles Limits the number of enabled:

• Active sessions

• Query requests

• Group or global objects, where group is all users associated with an account or profile and global is the account or profile

• Utilities, for example: FastLoad, MultiLoad, FastExport and Teradata Archive /Recovery (ARC)

Throttles are state-based; that is, any change to the state of the system can cause the Category 2 rule to be enabled or disabled or cause it to adjust the limit itself. Throttles are checked after filters.

Page 21: Workload management api

Chapter 1: Workload Management Concepts and FeaturesTeradata Dynamic Workload Management Features

Workload Management API: PM/API and Open API 21

Through interfaces to Teradata Dynamic Workload Management, database administrators can:

• Apply updates to rule categories

• Monitor delayed requests

• Release or abort requests from the delay queue

• Change or display the workload definition of a query

• Determine the current status of Teradata Dynamic Workload Management rules and rule sets

• Review statistics on how Teradata Dynamic Workload Management rules are affecting request processing

• Enable or disable filter or throttle rules, and update the throttle limits of a rule for Dual Active Support

• Retrieve information about the current status of all event-related constructs

• Add or remove an object association in Teradata Database for batch management

• Enable or disable user-defined events for event management

For examples on performing these functions, see “Workload Management API Examples” on page 25.

The information available to applications is collected and stored by the diswqm task. You can request this information at any time. However, depending on the API issued, some of the APIs may be restricted by what category of Teradata Dynamic Workload Management is currently enabled. For example, if the data requested by a specific interface is not available because the corresponding rule category is disabled, then an error is returned.

For more information about the rules and detailed set-up and operation of Teradata DWM, see Teradata Dynamic Workload Manager User Guide.

Most interfaces to Teradata Dynamic Workload Management require that Category 2 or 3 rules are enabled in Teradata DWM for the request to succeed. To determine if the required rules category is enabled, do the following:

• Execute the TDWMInquire SQL interface.

If the error code 3302 returns, then the required category is disabled.

• If the category is disabled, you must use Teradata DWM to enable the category.

To learn more about these interfaces, see Chapter 4: “Teradata Dynamic Workload Management APIs.”

3 Workload Classification (also called Workloads or Workload Definitions [WDs])

Groups requests based on their operational properties. The definition of workload class requires the specification of several groups of parameters, for classification, execution, exceptions, and logging aspects of the workload class, as well as any new Priority Scheduler parameters.

Category Name Description

Page 22: Workload management api

Chapter 1: Workload Management Concepts and FeaturesQuery Banding Features

22 Workload Management API: PM/API and Open API

Query Banding Features

Query banding is a method for tracking system usage and managing task priorities. A query band is a list of “name=value” pairs in a string contained within single quotation marks that is defined by the user or middle-tier application as shown below.

'org=Finance;report=EndOfYear;universe=west;'

Note: The name-value pairs are separated by a semicolon.

There are two types of query bands:

• A session query band, which is stored in the session table and recovered after a system reset.

• A transaction query band, which is discarded when the transaction ends (for example, a commit, rollback, or abort).

You can set a query band for the transaction and session using the SQL statement, SET QUERY_BAND. For information on SET QUERY_BAND, see SQL Data Definition Language.

By setting a query band you can:

• Identify the user, application, or report that originated the request from a middle-tiered application.

• Identify what user, application, report, and even what part of an application issued a request (for example, a query band can be used for accounting, troubleshooting, and in other types of system management operations).

• Give requests a higher priority. For example, a query band can make a request issued for an interactive report a higher priority than one issued for a report that generates output files.

• Increase the priority of an urgent job. For example, if the CEO needs a report for a board review that starts in 20 minutes, a query band can be used to expedite the job.

• Create requests that make up a “job” to be grouped for accounting and control purposes.

There are several uses for query bands. A query band can be:

• Logged by Database Query Log (DBQL). DBQL reports are created using the query band name-values pairs to provide additional refinement for accounting and resource allocation purposes and to assist in troubleshooting performance problems.

• Used for rule checking and workload classification. For Teradata Dynamic Workload Management, query band name-value pairs can be associated with filter rules and defined as workload classification attributes.

• Used to determine the origin of a request that may be consuming system resources or blocking other requests.

• Used as a system variable. A query band can be set for a session and retrieved using APIs.

Through these interfaces, the following information can be retrieved:

• The concatenated transaction and session query band for the specified session.

• The concatenated query band for the current transaction and session.

Page 23: Workload management api

Chapter 1: Workload Management Concepts and FeaturesSystem PMPC Applications Examples

Workload Management API: PM/API and Open API 23

• The name and value pairs in the query band.

• The value of the specified name in the current query band.

For examples on performing these functions, see “Query Band API Examples” on page 26.

To learn more about these interfaces and how to retrieve query bands, see Chapter 5: “Query Band APIs.”

System PMPC Applications Examples

This section explains two advanced examples of potential job control support applications that use the Performance Monitor:

• Resource Supervisor

• Idle Session Logoff

They are explained at a high level so that, by understanding the concepts, you can develop similar applications at a customer site for monitoring and controlling the use of Teradata Database resources.

Resource Supervisor

A Resource Supervisor prevents runaway queries. Runaway queries are sometimes a problem at a site where end users can access the Teradata Database to make ad hoc Teradata SQL requests. A badly formulated query—for example, one missing constraint on a WHERE clause—could inadvertently cause a product join, which consumes more resources than the user intended. Further, a user making an ill-formed SQL statement might request a join on two big tables, which unintentionally results in a Cartesian product join. The Resource Supervisor aborts transactions that exceed a certain resource usage threshold.

You can write a Resource Supervisor for Teradata Database to use features available in the request as shown in the example below.

1 Program the SET SESSION RATE request to set a reasonable session-level collection rate, for example, 10 minutes.

2 Based on the session-level rate, program the client application to issue a MONITOR SESSION request for all sessions or for a subset of sessions (for example, if users from a specific client are the only ones to be governed).

3 For each session returned to the client, program the client application to check some site-specific criteria to see if the session is a candidate for the Resource Supervisor.

For example, interactive users are required to have INTERACTIVE as the first word of their account string. If only interactive users are to be monitored by the Resource

Page 24: Workload management api

Chapter 1: Workload Management Concepts and FeaturesSystem PMPC Applications Examples

24 Workload Management API: PM/API and Open API

Supervisor, all sessions that do not include INTERACTIVE as the first word of the UserAccount value returned by a MONITOR SESSION request are ignored.

4 For those sessions that are candidates for the Resource Supervisor, program the client application to look at the AMPCPUSec, PECPUSec, and AMPIO values to determine if some site-specific maximum acceptable value has been exceeded.

These session values are cumulative and may not be appropriate for use as a Governor limit because you are limiting the total resource usage of a session and not of a request.

5 Program the client application to keep a history of all previous cumulative values of AMPCPUSec, PECPUSec, and AMPIO, plus current XactCount (transaction count) and ReqCount (request count) values for each session.

The difference between the historical value and the current value tells you the resources used. The request count and transaction count values tell you if they are consumed as part of the current transaction or as part of the new request.

6 If the Resource Supervisor determines that a particular session has exceeded site-specific limits, program the client application to issue an ABORT SESSION request for those session that have exceeded the limits.

The client application can specify the logoff option for the ABORT SESSION request, depending on how severely the offending session is controlled.

Idle Session Logoff

An Idle Session Logoff application automatically logs off users whose sessions have been idle for a certain length of time. This job control support feature prevents users from walking away from a terminal and allowing unauthorized users access to sensitive information.

You can write an Idle Session Logoff application program using the requests described below.

1 Program the SET SESSION RATE request to set a reasonable session-level collection rate, for example, 10 minutes.

2 Based on the session-level rate, program the client application to issue a MONITOR SESSION request for all sessions or for a subset of sessions (for example, if users from a specific client are the only ones to be monitored for idle sessions).

3 For each session returned to the client, check some site-specific criteria to see if the session is a candidate for Idle Session Logoff.

For example, interactive users are required to have INTERACTIVE as the first word of their account string. If only interactive users are to be monitored by the Resource Supervisor, all sessions that did not have INTERACTIVE as the first word of the UserAccount value returned by a MONITOR SESSION request are ignored. Those sessions with the INTERACTIVE label proceed through the next step.

4 For sessions that are candidates for Idle Session Logoff, program the client application to verify the following conditions to determine whether the session has been inactive for the duration of the collection period:

• AMPState and PEState are idle.

• The session was idle during the last MONITOR SESSION request.

Page 25: Workload management api

Chapter 1: Workload Management Concepts and FeaturesWorkload Management API Examples

Workload Management API: PM/API and Open API 25

• XactCount and ReqCount values did not change during the last MONITOR SESSION request.

If all these conditions are met, the session has been inactive for the duration of the collection interval and is a candidate for automatic logoff.

5 Program the client application to issue an ABORT SESSION request with the logoff option for the sessions that are candidates for automatic logoff.

Workload Management API Examples

The following examples show how the interfaces to System PMPC and Teradata Dynamic Workload Management are used.

Examples Using System PMPC APIs

The following table describes the different uses of the System PMPC APIs.

Examples Using Teradata Dynamic Workload Management PMPC APIs

The following table describes the different uses of Teradata Dynamic Workload Management PMPC APIs.

You can ... To ...

execute the MonitorMySessions and the MonitorSQLText functions

display only your running queries.

execute the MonitorSession and AbortSessions functions

create a query that aborts queries submitted by a set of users that have been running longer than 10 minutes and have been skewed by more than 30% for 20 minutes.

execute the MonitorSession and SetSessionAccount functions

change the Account string to $HReport of all active sessions with an account string of $MReport.

execute the MonitorSession or MonitorSQLText functions

display the SQL of all active sessions that have run over 20 minutes.

select the blocked fields of the MonitorSession function

display the block information of all blocked sessions.

You can execute the .. To ...

TDWMSummary function display the current workload summary statistics.

TDWMThrottleStatistics function display the current delay queue statistics.

Page 26: Workload management api

Chapter 1: Workload Management Concepts and FeaturesQuery Band API Examples

26 Workload Management API: PM/API and Open API

Query Band API Examples

The following table describes the different uses of the query band APIs.

MonitorSession and TDWMGetDelayedQueries function

display all sessions, for example, on delay queue 1011.

TDWMEventStatus function display all active events.

TDWMGetDelayedQueries and TDWMReleaseDelayedRequest functions

release all delayed queries for a specified workload.

TDWMRuleControl function temporarily enable a rule to block an application for accessing a database while it is synchronized between two active systems.

TDWMEventControl function change the active system condition or operating environment on the system to adjust the throttles and Priority Scheduler Facility weights to handle the other dual active system being down.

MonitorSession and TDWMAssignWD functions

change the workload to WD-Report-High of all active requests with a workload of WD-Report-Low.

You can execute the .. To ...

You can use .. To ...

MONITOR QUERYBAND or MonitorQueryBand

return the concatenated query band for session number 1102 on host ID 20 running on vproc 16383.

GetQueryBand or GetQueryBandSP return the concatenated query band string for the current transaction and session.

GetQueryBandValue query the DBQLogTbl based on names and values specified in the query band name input argument.

GetQueryBandValueSP search the session name-value pairs in the query band and return the value that corresponds to the query band name “aa.”

GetQueryBandPairs return the query band in name and value columns.

Page 27: Workload management api

Chapter 1: Workload Management Concepts and FeaturesAPI Categories

Workload Management API: PM/API and Open API 27

API Categories

The workload management APIs are grouped into three categories:

• System PMPC

• Teradata Dynamic Workload Management

• Query Bands

These categories describe the different System PMPC, Teradata Dynamic Workload Management, and Query Banding functionality and the interfaces used to perform them.

System PMPC

The following table describes the System PMPC interfaces that are used to show how efficiently Teradata Database is using its resources, to identify problem sessions and users, and to abort sessions and users having a negative impact on system performance.

IF you want to ...THEN use the following SQL interface...

OR use the following CLIv2 interface ...

abort any outstanding requests or transactions of one or more sessions, or optionally log those sessions off Teradata Database

“AbortSessions” on page 218

or

“AbortListSessions” on page 220

“ABORT SESSION” on page 54

return the name of a user, by session, who is causing a block

“IdentifySession” on page 224 “IDENTIFY” on page 67

return the name of the locked table

“IdentifyTable” on page 225 “IDENTIFY” on page 67

return the name of the specified user ID who is causing a block.

“IdentifyUser” on page 226 “IDENTIFY” on page 67

return information about AMP Worker Task (AWT) usage

“MonitorAWTResource” on page 227

“MONITOR AWT RESOURCE” on page 75

return the session information for the current user on the current host

“MonitorMySessions” on page 231

collect overall information on node availability. Node status information is returned for all nodes in the system

“MonitorPhysicalConfig” on page 245

“MONITOR PHYSICAL CONFIG” on page 82

collect node resource usage data

“MonitorPhysicalResource” on page 247

“MONITOR PHYSICAL RESOURCE” on page 88

Page 28: Workload management api

Chapter 1: Workload Management Concepts and FeaturesAPI Categories

28 Workload Management API: PM/API and Open API

collect global summary information, such as CPU, disk, and BYNET usage; rate information, and current software release and version number

“MonitorPhysicalSummary” on page 257

“MONITOR PHYSICAL SUMMARY” on page 108

return current status and activity information

“MonitorSession” on page 262 “MONITOR SESSION” on page 116

returns the duration of the sample period in seconds

“MonitorSessionRate” on page 276

“MONITOR SESSION” on page 116

return data about the currently running step

“MonitorSQLCurrentStep” on page 278

“MONITOR SQL” on page 147

return the step information for a particular session

“MonitorSQLSteps” on page 280

“MONITOR SQL” on page 147

return the SQL text string of the running request

“MonitorSQLText” on page 283 “MONITOR SQL” on page 147

collect information on virtual processor (vproc) availability

“MonitorVirtualConfig” on page 285

“MONITOR VIRTUAL CONFIG” on page 159

return performance information for each AMP or PE, on a vproc by vproc basis

“MonitorVirtualResource” on page 287

“MONITOR VIRTUAL RESOURCE” on page 166

return the summary information on system utilization such as disk and CPU usage, AMP and PE usage, the number of logged on sessions, and rate information

“MonitorVirtualSummary” on page 297

“MONITOR VIRTUAL SUMMARY” on page 188

set the following rates:

• VprocMonitor

• VprocLogging

• ResMonitor

• ResLogging

“SetResourceRate” on page 305 “SET RESOURCE RATE” on page 199

change the account string for a session or for the next request.

“SetSessionAccount” on page 308

“SET SESSION ACCOUNT” on page 204

set the system-wide and local rates for updating session-level statistics within memory

“SetSessionRate” on page 310 “SET SESSION RATE” on page 209

IF you want to ...THEN use the following SQL interface...

OR use the following CLIv2 interface ...

Page 29: Workload management api

Chapter 1: Workload Management Concepts and FeaturesAPI Categories

Workload Management API: PM/API and Open API 29

Teradata Dynamic Workload Management

The following table describes the interfaces of Teradata Dynamic Workload Management that are used to return workload definitions, delayed query lists, summary data, and statistics; and update the components stored in tdwm, a database shared by Teradata Dynamic Workload Manager and Teradata Query Scheduler. For more information about tdwm, see Teradata Dynamic Workload Manager User Guide.

IF you want to ...THEN use the following SQL interface...

OR use the following CLIv2 interface ...

change the workload a session or request is assigned to

“TDWMAssignWD” on page 357

“TDWM WD ASSIGNMENT” on page 345

activate updates to the rules in one or more Teradata Dynamic Workload Management categories

“TDWMApply” on page 355 —

abort a request or utility session on the Teradata Dynamic Workload Management delay queue

“TDWMAbortDelayedRequest” on page 353

“TDWM DELAY REQUEST CHANGE” on page 325

activates or deactivates a user-defined event

“TDWMEventControl” on page 359

“USER EVENT CONTROL” on page 349

list all objects that make up the system state

“TDWMEventMapping” on page 361

“EVENT STATUS” on page 313

return the currently defined events

“TDWMEventStatus” on page 363

“EVENT STATUS” on page 313

report if each category is active or not

“TDWMInquire” on page 372 —

release a request or utility session on the Teradata Dynamic Workload Management delay queue

“TDWMReleaseDelayedRequest” on page 378

“TDWM DELAY REQUEST CHANGE” on page 325

return a list of the workload definitions

“TDWMListWDs” on page 373 “TDWM LIST WD” on page 329

return the object delay queue and the workload delay queue

“TDWMGetDelayedQueries” on page 367

“TDWM STATISTICS” on page 333

return the utility delay queue “TDWMGetDelayedUtilities” on page 370

“TDWM STATISTICS” on page 333

display the statistics on the utilities that are active in the system

“TDWMLoadUtilStatistics” on page 375

“TDWM STATISTICS” on page 333

Page 30: Workload management api

Chapter 1: Workload Management Concepts and FeaturesAPI Categories

30 Workload Management API: PM/API and Open API

Note: The updates in the TDWMObjectAssn, TDWMRuleControl, and TDWMSetLimits procedures must be committed before calling the TDWMApply procedure. A self-deadlock occurs if the external stored procedures that update tdwm database and the TDWMApply are called within a transaction, for example:

Bt;Call TDWMRuleControl()

The updates are not committed because the TDWMRuleControl procedure is in a transaction (that is, the rows are locked for write).

Call TDWMApply(200, 'Y','N','N','N');

Database tdwm waits on the locked tables.

Query Bands

The following table describes the query band interfaces that are used to track system usage and manage task priorities.

return the query statistics for throttled database objects

“TDWMThrottleStatistics” on page 385

“TDWM STATISTICS” on page 333

return the TDWM Summary data fields

“TDWMSummary” on page 382 “TDWM SUMMARY” on page 341

return the first record of the TDWM SUMMARY request which is the Sample Rate

“TDWMSummaryRate” on page 384

“TDWM SUMMARY” on page 341

add or remove an object association from a rule

“TDWMObjectAssn” on page 376

set a rule to enabled or disabled by updating the EnabledFlag of the rule in tdwm database

“TDWMRuleControl” on page 380

update the throttle limits of a rule in tdwm database

“TDWMSetLimits” on page 381 —

IF you want to ...THEN use the following SQL interface...

OR use the following CLIv2 interface ...

IF you want to ...THEN use the following SQL interface...

THEN use the following CLIv2 interface...

return the name and value pairs in the query band

“GetQueryBandPairs” on page 397

return the concatenated query band for the current transaction and session

“GetQueryBand” on page 396

or

“GetQueryBandSP” on page 399

Page 31: Workload management api

Chapter 1: Workload Management Concepts and FeaturesRequirements for Using the API

Workload Management API: PM/API and Open API 31

Requirements for Using the API

CLIv2 Interfaces

The CLIv2 libraries must be installed on all nodes if you use PM/API.

CLIv2 is already required by PDE and should be installed on all Teradata Database nodes.

SQL Interfaces

To use the SQL interfaces:

• For System PMPC and query bands, use the SQL DIPDEM script to install the related external routines into the SYSLIB database. For information on the DIPDEM scripts, see Utilities.

The UDFs used to access the System PMPC data are written in VARCHAR_LATIN data type. The session character set of the user who installs the UDFs must be LATIN.

• For workload management or updates to tdwm, use Teradata Manager Database Setup to install the related external routines into tdwm database.

Required Privileges

The following requirements apply to all APIs described in this chapter unless otherwise stated in the relevant section:

• The user must have ABORTSESSION, and sometimes MONSESSION, privileges to issue CLIv2 interfaces.

• The user must have MONRESOURCE privileges to issue the MONITOR AWT RESOURCE CLIv2 interface.

• The DBA must grant EXECUTE FUNCTION and EXECUTE PROCEDURE privileges on UDFs and external stored procedures in order for a user to access them. These privileges are not granted by default.

• A minimum response buffer size of 32,000 bytes is required for CLIv2.

return the value of the specified name in the current query band

“GetQueryBandValue” on page 400

or

“GetQueryBandValueSP” on page 402

return the concatenated query band string for the specified session

“MonitorQueryBand” on page 403

“MONITOR QUERYBAND” on page 391

IF you want to ...THEN use the following SQL interface...

THEN use the following CLIv2 interface...

Page 32: Workload management api

Chapter 1: Workload Management Concepts and FeaturesRequirements for Using the API

32 Workload Management API: PM/API and Open API

Related Topics

For more information ... See ...

on the response buffer “Buffer Allocation” on page 36.

on defining the buffer size as part of the API input

“Sample Input” on page 162.

on how to code an application that uses the CLIv2 interfaces in this book

Teradata Call-Level Interface Version 2 Reference for Channel-Attached Systems or Teradata Call-Level Interface Version 2 Reference for Network-Attached Systems.

Page 33: Workload management api

Workload Management API: PM/API and Open API 33

CHAPTER 2 MONITOR Processing

This chapter describes how each MONITOR request processes the CLIv2 interfaces (also called requests) issued to Teradata Database by an end-user application interface on a client. The client can be either a channel-attached mainframe or a network-attached workstation.

PM/API Request Processing

The Call-Level Interface version 2 (CLIv2) is used to write end-user application interfaces to PM/API routines. CLIv2, a Teradata proprietary API and library, is the interface between your application and the Teradata Director Program. Teradata Director Program is the interface between CLIv2 and the Teradata Database. For an example of CLIv2, see Appendix A: “Sample PM/API Application.”

Whether the client application interface you develop is a simple utility or a complex system, the process is the same. Because the PM/API uses CLIv2 directly, it processes requests and responses in much the same way that CLIv2 does for a Teradata SQL application. No changes are required in CLIv2 to support PM/API. As a result, PM/API capabilities on Teradata Database are available on any client platform that supports CLIv2. If you can write a CLIv2 program, you can access PM/API routines.

For more detailed information on the uses of CLIv2 for the interfaces described in this chapter, see:

• Teradata Call-Level Interface Version 2 Reference for Channel-Attached Systems

• Teradata Call-Level Interface Version 2 Reference for Network-Attached Systems

Creating a Request

Your client application program tells CLIv2 what to do by creating a request string consisting of:

• A request parcel (when the response is desired in record mode) or an IndicReq parcel (when the response is desired in indicator mode).

When the response mode option is set in CLI, CLIv2 automatically uses the correct request parcel format.

• A USING Data String, which contains the input data.

Unlike Teradata SQL, PM/API does not use a USING Phrase to name the variables and reserve space in the request parcel. Instead, each MONITOR request has a USING Data String of a particular fixed format that determines the order of items, their data types, and lengths.

Page 34: Workload management api

Chapter 2: MONITOR ProcessingPM/API Request Processing

34 Workload Management API: PM/API and Open API

Because a USING Data String is required, either a data parcel must follow a request parcel or an IndicData parcel must follow an IndicReq parcel.

An IndicData parcel is recommended, because several of the fields in the USING Data String can be NULL.

Generating an IndicReq parcel results in a response that contains a PclDataInfo parcel, which describes the number of response columns. Each Record parcel returned begins with a number of presence bits, that supply the NULL indicators for the result columns.

To pass PM/API requests to Teradata Database as the text portion (body field) of the request parcel, the application program calls the CLIv2 DBCHCL routine with the DBCAREA function code (4) set to the Initiate Request operation. Code your application program to do the following before calling CLIv2 for the Initiate Request operation:

• Set the request pointer to the address of a character string containing the request name.

Note: For the IDENTIFY request, set the request pointer to the address of a character string containing one of the following:

• IDENTIFY SESSION

• IDENTIFY DATABASE

• IDENTIFY USER

• IDENTIFY TABLE

• Set the request length to the length in bytes of the character string.

• Set the USING Data pointer to the address of the USING Data String.

• Set the USING Data Length to the length in bytes of the USING Data String.

Setting Indicator or Record Mode

You can send the USING Data String in either indicator mode or record mode. CLI must inform CLIv2 which mode is used by setting the appropriate use presence bits option in the DBCAREA.

IF you want... THEN...

to send the USING Data String in indicator mode

the indicator (presence) bits must be provided by CLI.

Note: The use presence bits option is usually set to a default value for the site.

to change the default value do the following:

1 Set change options to Y in the application program.

2 Set the use presence bits option in the DBCAREA to Y.

Note: This also allows the application program to send null data to the Teradata Database system.

Page 35: Workload management api

Chapter 2: MONITOR ProcessingPM/API Request Processing

Workload Management API: PM/API and Open API 35

Response Processing

PM/API requests are processed similarly to Teradata SQL requests because CLIv2 is used for both. Response processing is similar in both parcel ordering and buffer allocation. For an example CLI program, see Appendix A: “Sample PM/API Application.”

Just as input data can be sent to the Teradata Database in indicator or record mode, the response can be returned from the Teradata Database in either indicator or record mode, depending on how the response mode option is set in CLIv2. You can set response mode to be independent of input data mode. For example, it may be more convenient to send the input data in record mode, but the response may require indicator mode if null values are expected.

Response mode is usually set to a default value for the site. If you want to change the default value set, change options to Y in the application program.

Note: Field mode, represented by F, is not supported in a PM/API request.

Also note that the Performance Monitor reports on Parsing Engine (PE) resource usage data regardless of whether the PE is channel- or LAN-connected.

Parcel Ordering

The response returned from a MONITOR request is a series of parcels constructed by Teradata Database and sent to the client.

The basic parcel layout for a successful response is the same for most MONITOR requests, except the following:

• MONITOR SQL

• MONITOR VERSION

Some MONITOR requests such as:

• MONITOR SESSION

• MONITOR VIRTUAL CONFIG

the USING Data String sent in record mode

do the following:

1 Set change options to Y in the application program.

2 Set the use presence bits option to N in the DBCAREA in the application program.

IF you want... THEN...

IF you want to return data in… THEN set the response mode option in DBCAREA to…

indicator mode I for Indicator. CLIv2 automatically uses the correct request parcel format.

record mode R for Record. CLIv2 automatically uses the correct request parcel format.

Page 36: Workload management api

Chapter 2: MONITOR ProcessingPM/API Request Processing

36 Workload Management API: PM/API and Open API

• MONITOR PHYSICAL CONFIG

• MONITOR VIRTUAL RESOURCE

• MONITOR PHYSICAL RESOURCE

behave like multi-statement requests, for which multiple record parcels are returned. For request-specific parcel layout, see Chapter 3: “PMPC APIs.”

The following table shows the parcel layout for an unsuccessful response is the same for all MONITOR requests -- either a Failure or an Error parcel is returned.

Buffer Allocation

The Performance Monitor, like a Teradata SQL application, requires space for a:

• Response buffer, containing the parcels transmitted back from the Teradata Database.

• Request buffer, containing the parcels sent to the Teradata Database.

Space for these two buffers is allocated for the application by CLIv2 based on the setting of DBCAREA arguments at the time a session is established. Default buffer sizes are controlled by the HSHSPB (control block containing site specific information), which is created during installation when CLI defaults are specified. The maximum size of a response buffer and request buffer are approximately 1 MB each.

If your response buffer is not large enough, your application program may receive the following error messages:

• Response buffer size is insufficient to hold one record.

This error occurs if the minimum number of bytes that can be returned to the host is larger than the host application has specified in a RESP or KEEPRESP parcel. You can find the minimum size specification in the Info field of the Error parcel.

• Response buffer size is insufficient to hold one record 32KB.

This error occurs if you specify a response buffer of 32KB but the actual data is 32KB. You can find the minimum size specification in the Info field of the Error parcel.

• Response buffer size is insufficient to hold one record 64KB.

This occurs if you specify a response buffer of 64KB but the actual data is 64KB. For this error code, the Info field in the error parcel will have the number of 512 Bytes required for

Parcel Name

Parcel Flavor

Field Length Comments/Key Parcel Body Fields

Failure 9 15 to 267 Message code and message text: description of cause of failure; request could not be processed. For example, the request is aborted.

Error 49 15 to 267 Message code and message text: description of cause of error. Application can fix the problem and resubmit the request. For example, response buffer is too small to hold entire response row.

Page 37: Workload management api

Chapter 2: MONITOR ProcessingPM/API Request Processing

Workload Management API: PM/API and Open API 37

the buffer size. You should read this number, multiply by 512 and allocate the new buffer size.

You must increase the response buffer size, resend the request, and resubmit the fetch operation. Alternatively, you can set the response buffer to the maximum of 1 MB. This may be a good option for sites with not too many users running MONITOR sessions.

Abort Processing

To abort your session or transaction, you can execute an asynchronous abort by using the CLIv2 routine DBCHCL, with the DBCAREA function code (7) set to the Abort Request operation. You can attempt an asynchronous abort on any of your MONITOR query operations, on any rate changing operations, or on an ABORT SESSION operation itself.

If you are responsible for monitoring performance, you can abort a session or group of sessions. For instructions, see “ABORT SESSION” on page 54.

The impact of the abort depends on the type of operation running. For the following query operations:

• IDENTIFY

• MONITOR PHYSICAL CONFIG

• MONITOR PHYSICAL RESOURCE

• MONITOR PHYSICAL SUMMARY

• MONITOR SESSION

• MONITOR SQL

• MONITOR VERSION

• MONITOR VIRTUAL CONFIG

• MONITOR VIRTUAL RESOURCE

• MONITOR VIRTUAL SUMMARY

The impact of the abort is described below.

For rate alterations (SET SESSION RATE or SET RESOURCE RATE), processing is identical to Teradata SQL treatment of a single-statement transaction as shown on the following table.

IF... THEN...

no portion of the response to the query has been sent to the session

an Asynchronous Abort causes the Monitor to terminate its processing of the query and transmit a failure parcel to the client. The failure indication is user-initiated abort.

a portion of the response to the query has been sent, but more remains to be sent

the abort and the request response have crossed in the mail. The Monitor ignores the abort.

all of the response has been sent to the session

the abort and the request response have crossed in the mail. The Monitor ignores the abort.

Page 38: Workload management api

Chapter 2: MONITOR ProcessingPM/API Request Processing

38 Workload Management API: PM/API and Open API

Logging On

A PM/API application logs on similar to a Teradata SQL application. However, there are the important following differences:

• The partition name is MONITOR. Set the following within your PM/API application:

• The run pointer to the address of the character string containing the word MONITOR.

• The run length to the length in bytes of the character string containing the word MONITOR.

• Your logon fails if:

• You do not have the appropriate MONITOR privilege.

• The PE or client that the MONITOR session is logged on to is already supporting its maximum number of four MONITOR sessions.

Note: Currently on the PE, the load balancing mechanism does not support MONITOR partition sessions. Session Control allocates MONITOR session requests to the PE on which a MONITOR session is logged until the four sessions per PE limit is reached. In such cases, even though another PE is available to handle a MONITOR session, you may get error message 3278:

Monitor Access Denied: No Monitor Session available

• The system-wide limitation of 128 concurrent MONITOR sessions is reached.

When your logon fails, any of the following error messages may display.

IF the response to the request has... THEN the...

not yet been sent to the session Monitor terminates its processing of the request, backs out any alteration already made by the request, and transmits a failure parcel to the client. The failure indication is user-initiated abort.

already been sent to the session abort and the request response have crossed in the mail. The Monitor ignores the abort.

Message Explanation

Monitor Access Denied: User has no Monitor Privileges

User has not been granted the privilege to execute any MONITOR requests.

Monitor Access Denied: No Monitor session available

All available MONITOR sessions are currently in use for the client from which you are logging on. Each online PE can only support up to four MONITOR sessions.

There are no more Monitor Sessions available.

Teradata Database system-wide limitation of 128 concurrent MONITOR sessions has been reached, even though the client you are logged on to or the PE the session was assigned to has not encountered its limit.

Page 39: Workload management api

Chapter 2: MONITOR ProcessingComparisons Between PM/API and Teradata SQL Requests

Workload Management API: PM/API and Open API 39

Logging Off

A PM/API application logs off the same way a Teradata SQL application does with one exception. If you log off a session that has a local session monitoring rate (SesMonitorLoc) of nonzero, the rate is changed to zero. This change is added to the DBC.SW_Event_Log table (accessible from the DBC.Software_Event_LogV view), which is similar to what occurs if you had issued a SET SESSION RATE request prior to logging off.

Warning and Error Messages

A general statement is made at the end of each request section in Chapter 3: “PMPC APIs” about specific error and warning messages that may be returned in response to the request.

For a general discussion on common warning and error messages that may be returned in response to various requests, see “Common Warning and Error Messages” on page 50.

For detailed information on the meaning of individual error and warning messages and the response required, see Messages.

Comparisons Between PM/API and Teradata SQL Requests

There are both similarities and differences between PM/API applications and Teradata SQL applications, such as Basic Teradata Query (BTEQ), special utilities (for example, FastLoad), and third party software.

Similarities

The similarities between a Performance Monitor based application and a Teradata SQL based application include:

• Data types supported for input and output data in PM/API applications are a subset of those data types supported by Teradata SQL.

• Fixed length character data is blank padded on the right.

• Null values returned for the PclRecordType response parcel are equal to the null values returned by Teradata SQL (see “Response Parcel Groups” on page 123).

Differences

The differences between a Performance Monitor based application and a Teradata SQL based application are:

• A PM/API application issues requests through a session partition named MONITOR.

• The MONITOR partition does not support the capabilities found in a Teradata SQL partition. The following table shows how the MONITOR partition reacts to the Teradata SQL partition capabilities.

Page 40: Workload management api

Chapter 2: MONITOR ProcessingComparisons Between PM/API and Teradata SQL Requests

40 Workload Management API: PM/API and Open API

• Keywords used by the MONITOR PM/API requests are different from keywords in Teradata SQL. However, both have the same rules for identifiers.

• MONITOR query processing, unlike Teradata SQL, produces dynamic data.

• A Using Data String, which defines the input data, is always required in a PM/API application. In Teradata SQL, it is optional.

Keywords/Reserved Words

The following keywords are Teradata Database reserved words:

• ABORTSESSION

• MONITOR

• MONRESOURCE

• MONSESSION

• SETRESRATE

• SETSESSRATE

The following keywords are Teradata Database non-reserved words that are permitted as object names, but discouraged because of the possible confusion that may result:

• MONSQL

• MONVERSION

For a complete list of words that are unavailable for use as object names, see SQL Fundamentals.

Teradata SQL Users Can Issue GRANT and REVOKE

In rare cases, a change in privileges could temporarily block the request of an active MONITOR session because the system must look up the new privileges before accepting any more requests from the affected user. If the system query is blocked by a lock on a Teradata Database dictionary table or if there is some other type of system processing bottleneck, the affected user cannot issue any MONITOR requests until the user acquires the new set of privileges. However, MONITOR requests submitted from the system console are not blocked

IF you use the Teradata SQL partition capability...

THEN the MONITOR partition returns one of the following error messages...

Keep Response processing mode • Either

Error 3748 Parcel kind or ordering is invalid.

• Or

Error 3749 Options Parcel information is invalid.

Execute a rewind operation

Run the start-up operation

Field mode request

CleanUp request

P (Prepare) or S (Setup) request processing option of the DBCAREA

Page 41: Workload management api

Chapter 2: MONITOR ProcessingPM/API Dynamic Data

Workload Management API: PM/API and Open API 41

by a change in privileges, because no privileges are necessary to issue MONITOR requests on the system console.

PM/API Users Can Issue ABORT SESSION

With the proper privileges granted, the PM/API user can abort and log off a Teradata Database user.

The error message is not returned to the user of the affected session until ABORT SESSION completes rolling back the current transaction or, if applicable, the session is logged off.

The status of an active session determines when the error message is received.

PM/API Dynamic Data

When you issue a request through the Monitor partition, current and dynamic data is reported. PM/API requests place data in a global repository (in memory), not in an intermediary spool file (on disk). AMP, PE, node, and session-level usage data are each collected in independent data collection global areas.

As a result, changes in the resource collection rate have no impact on session-level data, and vice versa. Any MONITOR request, except MONITOR VIRTUAL CONFIG, MONITOR PHYSICAL CONFIG, and IDENTIFY, may cause the memory repository to be updated on demand (specifically, once each sample period). All users share the data in the repository, which is used to generate responses to both queries and CONTINUE requests.

Note: If, after issuing a PM/API request, the Monitor partition session returns an error parcel with empty error text, run the Database Initialization Program (DIP) option 1 (DIPERR), then wait up to 60 minutes to reload the error text cache in the Monitor partition. After the

IF the ABORT SESSION command... THEN the Teradata Database user receives...

targets a current Teradata Database request or session

Error 3265 Transaction has been Aborted By Administrator or Operations Staff.

targets a request or session after the user has logged off from Teradata Database

Error 3256 No such Session is currently logged on.

IF, at the time you issue an ABORT REQUEST statement and... THEN the...

a request is outstanding for the user session

error message is sent as a response to the current request.

no request is outstanding, but a session is in progress

user receives the error message when the next request is received.

Page 42: Workload management api

Chapter 2: MONITOR ProcessingPM/API Dynamic Data

42 Workload Management API: PM/API and Open API

error text cache is reloaded, the error parcels will have the proper error texts. For instructions on how to run DIP, see Utilities.

Monitoring Rates

You should be aware of the rate at which your PM/API client application requests performance data. If a PM/API client application requests data more frequently than the corresponding data collection rate, an individual request could potentially include data from one sample period mixed in with data from a subsequent sample period initiated by a different MONITOR user because common global data is shared.

However, the impact need not be detrimental. The data collected from one request when compared with the next request may not show a change in resource usage. Follow the simple rule that the PM/API client application must request data at the same rate, or a less frequent rate, than the rate at which the Teradata Database collects that data.

The virtual monitoring rate is a PM/API sampling rate that sets the maximum frequency at which AMP and PE resource usage data is updated in memory. Whereas, the physical monitoring rate is a PM/API sampling rate that sets the maximum frequency at which node resource usage data is updated in memory.

There are significant differences in the way AMP and PE, node, and session utilization data are collected and reported by the MONITOR partition. For details, see “Sampling and Logging Rates” on page 45.

Session-Level Data

Session-level data is collected cumulatively. The sample period is used to limit the frequency of this update.

For example, if you set the SET SESSION RATE to 120 seconds and then issue a MONITOR SESSION request, session usage data is collected and cumulatively totaled every 120 seconds.

Note: Session-level data is lost in the event of a system outage.

Data reported includes data for the beginning 120 seconds as well as for subsequent intervals.

For more information on how session usage data is collected, see “System-Level Monitoring” on page 18.

Resource Usage Data

Resource usage data is collected based on activity during a sample period and does not reflect cumulative data for a sequence of sample periods. For example, if you set the SET RESOURCE RATE to 120 seconds and issue a MONITOR VIRTUAL RESOURCE or MONITOR PHYSICAL RESOURCE request, resource usage data is collected at 120-second intervals.

If you do not examine the data within 120 seconds or enable ResUsage tables for logging, it is lost when overwritten by data collected during the next 120-second sampling interval.

Page 43: Workload management api

Chapter 2: MONITOR ProcessingPM/API Dynamic Data

Workload Management API: PM/API and Open API 43

Logging Resource Usage Data

You can retain sampled data for subsequent historical analysis by enabling one or more resource usage tables for logging. The fields associated with each table and type of PM/API request are listed below. For details on the resource usage tables and pre-defined report macros, see Resource Usage Macros and Tables.

To control the resource usage logging option, such as setting the logging rate and enabling one or more log tables or subtables, use the ctl utility (on Linux or Windows) or the xctl utility (on MP-RAS). For instructions on using ctl or xctl, see Utilities.

Table Field PM/API Request

Node Resource Usage Table Group

ResUsageIpma NetAUse

NetBUse

NetUse

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL SUMMARY

Page 44: Workload management api

Chapter 2: MONITOR ProcessingPM/API Dynamic Data

44 Workload Management API: PM/API and Open API

ResUsageSpma AvgCPU

AvgDiskIO

CPUUse

DiskReads

DiskWrites

HighCPUUse

HighDiskIO

LowCPUUse

LowDiskIO

MemAgings

MemAllocateKB

MemAllocates

MemFailures

NetReads

NetUse

NetWrites

NVMemAgings

NVMemAllocSegs

NVMemAllocate

PercentIOWait

PercentKernel

PercntService

PercentUser

SwapDrops

SwapReads

SwapWrites

MONITOR PHYSICAL SUMMARY

MONITOR PHYSICAL SUMMARY

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL SUMMARY

MONITOR PHYSICAL SUMMARY

MONITOR PHYSICAL SUMMARY

MONITOR PHYSICAL SUMMARY

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

Vproc Resource Usage Table Group

ResUsageShst CICUse

HostBlockReads

HostBlockWrites

MONITOR PHYSICAL RESOURCE

MONITOR PHYSICAL RESOURCE

MONITOR VIRTUAL RESOURCE

ResUsageSldv(Storage Devices)

AMPAvgDisk

DiskOutReqAvg

HiDiskAMP

LoDiskAMP

MONITOR VIRTUAL SUMMARY

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL SUMMARY

MONITOR VIRTUAL SUMMARY

Table Field PM/API Request

Page 45: Workload management api

Chapter 2: MONITOR ProcessingPM/API Dynamic Data

Workload Management API: PM/API and Open API 45

Sampling and Logging Rates

You can control the rate at which resources are monitored (sampled) and, if you enable ResUsage logging, the interval at which a data row is to be inserted into the log table.

Setting Sampling Rates

The following table describes the sampling rates that can be set at the system (global) or session (local) level for virtual and/or physical devices.

ResUsageSvpr AMPAvgCPU

AMPAvgDiskIO

CPUUse

DiskReads

DiskWrites

HiCPUAMPUse

HiCPUPEUse

HiDiskAMPIO

LoCPUAMPUse

LoCPUPEUse

LoDiskAMPIO

MemAllocateKB

MemAllocates

NVMemAllocSegs

NetReads

NetWrites

PEAvgCPU

PercntAMPWT

PercntDispatcher

PercntParser

PercntService

MONITOR VIRTUAL SUMMARY

MONITOR VIRTUAL SUMMARY

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL SUMMARY

MONITOR VIRTUAL SUMMARY

MONITOR VIRTUAL SUMMARY

MONITOR VIRTUAL SUMMARY

MONITOR VIRTUAL SUMMARY

MONITOR VIRTUAL SUMMARY

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL SUMMARY

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL RESOURCE

MONITOR VIRTUAL RESOURCE

ResUsageSvdsk OutReqTime MONITOR VIRTUAL RESOURCE

Table Field PM/API Request

Page 46: Workload management api

Chapter 2: MONITOR ProcessingPM/API Dynamic Data

46 Workload Management API: PM/API and Open API

Setting Logging Rates

You can enable logging of sampled data into the ResUsage tables. In this case, you also set a logging rate that specifies how often a data row is to be inserted.

Logging is not required to collect and retrieve current data, but it does preserve data that would otherwise be lost at the next sampling interval.

Note: The Virtual and Physical Resource rates must be the same, but not for the Logging rates.

If you decide to enable logging, set the logging rate according to the type of monitoring and rate of sampling you specify, as explained in the following table.

Sampling Rate Description

Global session monitoring

Sampling rate that sets the maximum frequency at which session-level data across all sessions is updated within memory. The rate is saved on disk every time it is reset. Use the SET SESSION RATE request to set this rate by specifying a global rate change.

Set this rate at any interval within the range of 0 and 3600 seconds, with increments of one. A rate of zero turns off the sampling capability. The value of this rate is returned as SesMonitorSys in a MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY request.

For more information, see Resource Usage Macros and Tables.

Local session monitoring

Sampling rate that sets within a session the maximum frequency at which session-level data is updated in memory. This rate overrides the global session monitoring rate. This rate is not saved on disk and is lost during a system outage. Use the SET SESSION RATE request to set this rate by specifying a local rate change.

Set this rate at any interval within the range of 0 and 3600 seconds. A rate of zero turns off the sampling capability. The value of this rate is returned as SesMonitorLoc in a MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY request.

Virtual resource monitoring

Sampling rate that sets the maximum frequency at which AMP, PE, and/or pdisk resource usage data is updated in memory. The rate is saved on disk every time it is changed. Use the SET RESOURCE RATE request to set this rate.

Set this rate at any interval within the range of 0 and 3600 seconds. A rate of zero turns off the sampling capability. The value of this rate is returned as ResMonitor in a MONITOR VIRTUAL SUMMARY request.

Physical resource monitoring

Sampling rate that sets the maximum frequency at which node or storage device resource usage data is updated in memory. The rate is saved on disk every time it is changed. Use the SET RESOURCE RATE request to set this rate.

Set this rate at any interval within the range of 0 and 3600 seconds. A rate of zero turns off the sampling capability. The value of this rate is returned as ResMonitor in a MONITOR PHYSICAL SUMMARY request.

Page 47: Workload management api

Chapter 2: MONITOR ProcessingPM/API Dynamic Data

Workload Management API: PM/API and Open API 47

Resource Usage Logging Rate Description

Virtual resource logging Sets the frequency at which AMP and PE resource usage data is written to the ResUsage tables. The rate is saved on disk every time it is altered. Use the SET RESOURCE RATE request to set this rate.

Also, this rate:

• Can be set at any interval within the range of 0 and 3600 seconds.

• Must be a multiple of the Virtual Resource Monitoring rate.

• With a value of zero indicates that logging is not being performed.

• Returns the value ResLogging in a MONITOR VIRTUAL SUMMARY request.

Physical resource logging

Sets the frequency at which node resource usage data is written to the ResUsage tables. The rate is saved on disk every time it is altered. Use the SET RESOURCE RATE request to set this rate.

Also, this rate:

• Can be set at any interval within the range of 0 and 3600 seconds.

• Must be a multiple of the Physical Resource Monitoring rate.

• With a value of zero indicates that logging is not being performed.

• Returns the value ResLogging in a MONITOR PHYSICAL SUMMARY request.

Page 48: Workload management api

Chapter 2: MONITOR ProcessingPM/API Dynamic Data

48 Workload Management API: PM/API and Open API

Page 49: Workload management api

Workload Management API: PM/API and Open API 49

CHAPTER 3 PMPC APIs

This chapter discusses how to use the System Performance Monitor and Production Control (PMPC) interfaces to monitor system and session-level performance and to identify and abort problem sessions and users having a negative impact on system performance.

PMPC data is available through two types of APIs: CLIv2 interfaces and SQL interfaces consisting of user-defined functions (UDFs).

To learn more about the different types of interfaces, see:

• “CLIv2 Interfaces” on page 50

• “SQL Interfaces” on page 217

Before using the System PMPC APIs, you may want to familiarize yourself with the following topics:

• “What PM/API Is” on page 13

• “What the Open API Is” on page 14

• “System PMPC Features” on page 16

• “System PMPC Applications Examples” on page 23

Page 50: Workload management api

Chapter 3: PMPC APIsCLIv2 Interfaces

50 Workload Management API: PM/API and Open API

CLIv2 Interfaces

This section describes the System PMPC interfaces that use CLIv2 to access the PMPC data. These interfaces are referred to as PM/API requests.

It also describes the common warning and error messages returned when using these requests.

Note: The PM/API requests described in this section are shown in uppercase, although mixed case interfaces are also supported.

Common Warning and Error Messages

Most of the monitor requests covered in this chapter depend on periodic sampling of data. When this sampling process is disturbed, the returned data can temporarily become confusing or inaccurate.

If this happens, the user receives a warning message indicating that the data returned may not give a true picture of system or user activity.

The following are some common situations in which a warning message is provided:

• The data returned may have been affected by a system restart or a single processor recovery. Resource/Session usage values may not be realistic until requests on the Teradata Database re-attain their normal level of activity.

• Data may also be incomplete in cases where:

• A full data collection period has not transpired since the Teradata Database has gone through a recovery.

• A full data collection period has not transpired since the related monitoring rate was changed.

The following table describes the general warning and error messages that may be returned in response to most requests at logon or logoff.

Message Number Description

3250 User does not have the necessary Access Right for this request.

Remedy: Obtain the necessary access right and resubmit the request.

3251 Required Input Data Parcel missing or wrong size for this request.

Remedy: Correct the error and resubmit the request. For example, if the using_data_len field has an unexpected length, set the using_data_len field to 39(sizeof(monsess_t)) for MONITOR SESSION:

dbc.using_data_len = 39;

For details on how the monsess_t structure is defined, see Appendix A: “Sample PM/API Application.”

3253 Monitor Access Denied: User has no Monitor Privileges.

Remedy: Obtain the proper access right and resubmit the request.

Page 51: Workload management api

Chapter 3: PMPC APIsCLIv2 Interfaces

Workload Management API: PM/API and Open API 51

Warnings and error messages that are specific to a particular type of request are presented at the end of the request section.

For more detailed information on warning and error messages, see Messages.

Errors Resulting from PMPC Subsystem Failures

All MONITOR requests get their information from the PMPC subsystem. In the event of a PMPC internal software failure, the system will generate one of several possible errors. Each of

3254 The specified version is not supported.

Remedy: Correct the error and resubmit the request.

3256 No such Session is currently logged on.

Remedy: Correct the error and resubmit the request.

3270 Warning: DBC Recovery has occurred.

Remedy: This message is informational. Its purpose is to warn the user that the usage values may not reach a steady state until the requests on the Teradata Database system attain their normal level of activity.

3277 An informative event was logged.

Remedy: The messages generated under this code are informational.

3278 Monitor Access Denied: No Monitor Session available.

Remedy: Attempt to logon on through a different PE that has not reached its Monitor session limit or logon later when there is a Monitor session available.

3279 There are no more Monitor Sessions available.

Remedy: Wait for a logged-on Monitor user to log off and resubmit the logon request.

3280 Request not allowed now. System is not online.

Remedy: Resubmit the request after the Teradata Database system has come fully online.

3281-3287 Internal errors.

3288 Warning: Response limit exceeded. Logoff and start over again.

Remedy: Change the application to keep fetching the response until the end of the record is reached or log off the session to clean up all pending requests.

3706 The request contains a syntax error. The quote (') identifies the approximate location of the error or identifies the syntax problem. For example, if you receive the following error message, you have logged on to the wrong partition.

Expected something between the beginning of the request and the 'MONITOR' keyword.

Remedy: Correct the syntax and resubmit the request. In this case, set the run string (dbcarea.run_ptr) to “MONITOR” to log on to Monitor partition. For an example, see Appendix A: “Sample PM/API Application.”

Message Number Description

Page 52: Workload management api

Chapter 3: PMPC APIsCLIv2 Interfaces

52 Workload Management API: PM/API and Open API

these errors causes the PMPC subsystem to discontinue the current session to prevent the error from crashing the entire system.

If the system encounters such an error, it takes a snapshot dump and does one of the following:

• If the internal software error occurs during the initial parsing of the System PMPC request, the session and the interface that caused the error will be discontinued. The user can log on again and submit other System PMPC requests, however, sometimes the internal software error will persist. On the third instance that a PE sees the internal software error, the PE will be shutdown for further logons. Even if this happens the PMPC subsystem may still be available through other PEs.

• If an internal software error occurs during a subsequent request processing task, the system will take a snapshot dump both of the problem task and parsing task. Then it will shut down the entire PMPC subsystem from further logons.

Even though the PMPC subsystem may be partially or fully shut down due to an internal software error, the shut down avoids a crash and allows the system to process other types (non-PMPC) of requests. Although the system resources are cleaned up as much as possible after such an internal software error, there may be leftover resources or tasks that stay hung waiting on a response from the task that originally caused the error.

Subsequent MONITOR SESSION requests may return error 3296. This is not a normally expected error, but it is an indication that one or more of the tasks involved in MONITOR SESSION request processing may be hung or very slow.

After encountering a PMPC subsystem internal failure, especially if a subsequent MONITOR request results in a 3296 error, the administrator should do a manual DBS restart as soon as possible (taking care not to unnecessarily disrupt users) to rid the system of task and resource fragments. The administrator should also report the snapshot dump and any related errors in the event log to the Teradata Support Center.

The following table describes the errors that may occur in the event of a PMPC internal software failure.

Message Number Description

3296 PMPC request processing timed out.

This is a general timeout indicating a non-fatal error during SET SESSION ACCOUNT or MONITOR SESSION request processing.

Remedy: Retry or check the session itself.

Page 53: Workload management api

Chapter 3: PMPC APIsCLIv2 Interfaces

Workload Management API: PM/API and Open API 53

3320 Monitor Access Denied: Fatal Error Count Exceeded the Maximum.

The user is denied the logon because the fatal error count exceeded the maximum allowed on the given PE. When a fatal error is encountered in initial parsing of the request, the problem PE tries to abort the request and logoff the session. On the third time, an online PE sees the fatal error, it aborts the session and no longer allows logons onto that PE. Only a DBS restart will reset the fatal error count to zero.

Remedy: Attempt to logon through a different PE that has not reached its MONITOR session fatal count limit or schedule a manual DBS restart.

3321 Monitor Subsystem Has Been Shut Down Due To Internal Error.

The PMPC Monitor Subsystem has been shut down due to an internal processing error. No PMPC requests/logons will be allowed until next DBS restart.

Remedy: Schedule a manual DBS restart.

Message Number Description

Page 54: Workload management api

Chapter 3: PMPC APIsABORT SESSION

54 Workload Management API: PM/API and Open API

ABORT SESSION

PurposeAborts any outstanding request or transaction of one or more sessions, and optionally logs those sessions off the Teradata Database system.

Input Data

Warning: If an ABORT SESSION request is submitted when host_id, user_name, or session_no is either left blank or set to NULL, an attempt is made to abort all hosts, all users, or all sessions. For example, if you specify 127 for host_id, FRR for user_name, and NULL for session_no, ABORT SESSION attempts to abort every and all sessions currently logged on from host 127 as user FRR.

ElementData Type/ Range

Length (Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6 or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

host_id SMALLINT, NULLABLE, range 0-1023

2 The logical ID of a host (or client) with sessions logged on. For example, a hostid of zero identifies internal sessions or system console sessions.

host_id cannot exceed 1023.

session_no INTEGER, NULLABLE, range 0-4294967295

4 The session number. session_no combined with the host_id represents a unique session ID.

user_name CHAR, NULLABLE

30 The user who is running the sessions.

Page 55: Workload management api

Chapter 3: PMPC APIsABORT SESSION

Workload Management API: PM/API and Open API 55

list CHAR, NULLABLE

1 Indicator of whether or not to display a list of sessions.

To display a list of all session_no sessions, specify y or Y. If you do not want to display a list of sessions, specify n, N, NULL, or blank.

Caution: Do not use list when large numbers of sessions are being aborted. Otherwise, system degradation can result, especially when the abort list contains more than 1500 sessions. The slowdown occurs because all of the impacted sessions must be buffered and then sorted on a single processor. During the sort, the processor is unavailable for requests from any other MONITOR session logged on to that PE. Furthermore, in extremely rare cases, perhaps involving an abort of 10,000 sessions, the number of sessions needed to be sorted can exhaust scratch space on the processor and cause a system restart.

Note: If your site is running Two-Phase Commit (2PC), the following information applies. For more information on 2PC, see Database Design.

• Do not use ABORT SESSION to abort or log off Teradata Director Program internal sessions used for 2PC processing. To log off the sessions, use the Teradata Director Program command DISABLE IRF instead.

• Be sure to issue DISABLE IRF before executing ABORT SESSION using the host_id.* or *.* parameters to avoid any possible problem with the Teradata Director Program.

• To identify Teradata Director Program internal sessions, run the Teradata Director Program command DISPLAY SESSIONS. Teradata Director Program internal sessions have the job name *TDPINT*. (The MONITOR SESSION request cannot identify Teradata Director Program internal sessions.)

logoff CHAR, NULLABLE

1 An indicator of whether or not to log session_no sessions off the Teradata Database in addition to aborting them.

To log session_no sessions off the Teradata Database, specify y or Y. To simply abort session_no sessions, specify n, N, NULL, or blank.

ElementData Type/ Range

Length (Bytes) Description

Page 56: Workload management api

Chapter 3: PMPC APIsABORT SESSION

56 Workload Management API: PM/API and Open API

Performance and the list Option

The ABORT SESSION request is different from other PM/API requests, because as soon as processing begins, the ABORT SESSION operation is not abortable.

Except for a small timing window (which closes when the PM/API acknowledges the ABORT SESSION request) any Asynchronous Abort operation is ignored.

The ABORT SESSION cannot be stopped even if list displays some sessions that were included by mistake.

Usage Notes

Aborting a session is useful when a session causes a production job to block other sessions waiting for locks, or when a session takes up many resources that a critical application is running too slowly.

A user must have ABORTSESSION privilege to execute this request.

override CHAR, NULLABLE

1 An indicator of whether or not to override an ABORT SESSION failure.

Specify y or Y if you do not want the ABORT SESSION request to fail in any of the following cases:

• An identified session is being session-switched.

• An identified session is executing its own ABORT SESSION request.

• An identified session has a PEState of IDLE: IN-DOUBT as a result of a 2PC.

Note: Sessions are marked IN-DOUBT by the 2PC protocol, which governs how transactions are committed by multiple systems that do not share memory. The protocol guarantees that either all systems commit or all roll back.

Therefore, when you specify y or Y, session_no sessions that fit one of the above criteria are ignored, and all sessions that do not fit any of the above criteria are aborted.

If you specify n, N, NULL, or blank, and at least one identified session fits one of the above criteria, the ABORT SESSION request will fail.

If you specify n or N, or do not specify this option, the entire ABORT SESSION operation fails if any non-abortable session is encountered. Sessions are not aborted (including those in abortable states) and a 3286 error message is returned.

ElementData Type/ Range

Length (Bytes) Description

Page 57: Workload management api

Chapter 3: PMPC APIsABORT SESSION

Workload Management API: PM/API and Open API 57

By default, the ABORT SESSION request aborts the current transaction for the specified sessions and logs those sessions off the Teradata Database.

The ABORT SESSION request is logged to the DBC.SW_Event_Log table (accessible from the DBC.Software_Event_LogV view). If you specify y or Y for logoff, records are added to DBC.SW_Event_Log table.

On Windows, the request is logged to the Windows Event log, which can be viewed with Windows Event Viewer.

ABORT SESSION will not abort nor log off a session under any of the following conditions:

• The session status is IN-DOUBT.

• The session is currently being session-switched.

• The session is a Database Query Log (DBQL)/Teradata Dynamic Workload Manager (Teradata DWM) artificial internal session.

• The actual session is currently executing an ABORT SESSION request.

If you attempt to abort such a session, either a diagnostic message displays indicating that the ABORT SESSION request was not accepted, or, the ABORT SESSION request aborts any identified sessions that do not meet the above conditions.

Although this request may abort and log off other PM/API sessions, it ignores the session from which it was submitted. To abort your own session, use the asynchronous abort available through Call-Level Interface (CLI). For an example CLI program, see “Appendix A Sample PM/API Application” on page 405.

At least one of the transactions you want to abort either cannot be aborted or already is being aborted if:

• A session is in the final stage of an ALTER TABLE operation and cannot be aborted.

• A user-initiated abort must complete before whatever caused the ABORT SESSION request to be executed can be done. Therefore, if you specify list, that list will indicate sessions that are:

• Currently IN-DOUBT

• Being session-switched

• Already aborting or committing their own transactions

• Executing an ABORT SESSION request

The ABORT SESSION request has the following impact as described in the table below.

Page 58: Workload management api

Chapter 3: PMPC APIsABORT SESSION

58 Workload Management API: PM/API and Open API

Type of Session

Impact of ABORT SESSION Option Comments

A session with a transaction that is currently being committed or rolled back

None with or without logoff

The ABORT SESSION request does not fail. Instead, the stage 1 response from the Teradata Database includes a warning that identified sessions are in the process of committing or rolling back their transactions.

An internal session

None The activity of such sessions is vital to the continued execution of Teradata Database and is always considered to be more important than any user-initiated work that may be blocked. The Teradata Database system acts as if the internal sessions do not appear in the optional list of sessions identified by this request.

Note: Specify a host_id of zero to abort console Basic Teradata Query (BTEQ) sessions.

A DBQL/Teradata DWM artificial internal session

Does not work

This is not a real session and cannot be aborted. If you attempt to abort this session, a 3267 error message is returned:

No sessions meet the Abort criteria.

A client utility user

Little Client utility locks are designed to survive system outages or interruptions in the archive process, and are not necessarily associated with an active session. Instead, they are associated with the user who originally submitted the dump or restore job. Therefore, an ABORT SESSION request does not necessarily remove locks placed by the client utility and does not necessarily cause whatever activity any such locks were blocking to become unblocked. However, such sessions still appear in the optional list of sessions identified by this request.

Page 59: Workload management api

Chapter 3: PMPC APIsABORT SESSION

Workload Management API: PM/API and Open API 59

Processing Messages

Unlike other PM/API requests, ABORT SESSION has an unpredictable execution time and could take hours to roll back a transaction.

Therefore, upon receipt of an ABORT SESSION request, the Teradata Database sends one or more of the following processing messages:

• Indicates that the ABORT SESSION request has been received and is in one of the following states:

• Has been accepted and is in execution.

• Cannot be accepted because resources are exhausted, because of either a heavy workload or several ABORT SESSION requests are queued and waiting to finish processing. Information is recorded in the error log and the following message is displayed in the Teradata Database Window:

3268 Command Disallowed: An identified session is not currently Abortable.

Teradata Database should not restart as a result of this error. Depending on the available resources, this request will be processed to completion after all the queued abort requests have completed processing.

• Cannot be accepted for some other reason. See “Warning and Error Messages” on page 63 for more details.

MLOAD, FASTLOAD, HUTCTL, HUTPARSE, and/or DBCUTIL partition sessions

Does not work

without logoff

Sessions within these partitions do not have transactions or locks associated with them. Also, many of these partitions do not include the Teradata SQL or PM/API ability to recover from an interrupted request without terminating the application. That is, these partitions are designed to be restarted, but not rolled back. As a result, when a FastLoad, MultiLoad, or Archive operation needs to be terminated, the ABORT SESSION request typically specifies that all sessions associated with the utility job be aborted and logged off. These utility-related sessions appear in the optional list of sessions identified by this request.

It is easier to kill a FastLoad, MultiLoad, Archive and Recovery, or FastExport job by user_name instead of by session_no. These utilities have multiple sessions under one user_name and it makes little sense to abort one utility session running under that user_name and not another. However, be aware that the same user_name may be running other sessions at the same time and these sessions would also be aborted and logged off.

Type of Session

Impact of ABORT SESSION Option Comments

Page 60: Workload management api

Chapter 3: PMPC APIsABORT SESSION

60 Workload Management API: PM/API and Open API

• Lists how many sessions have been affected by the executing request (if Y was entered into the list field).

• Indicates the request is complete when all identified sessions have been aborted.

• Indicates that all session have been logged off (if Y was entered into the logoff field).

Parcels

Because of the unpredictable execution time of ABORT SESSION, the Teradata Database system handles ABORT SESSION as if it were a two-statement request, with each statement generating a response.

The two-statement response contains the following sequence of parcel types.

The only difference between the parcels returned with the list option set to y or Y, and those returned with the list option set to n, N, blank, or NULL, is that one or more Record parcels are added when you specify the former.

In the first response, the Teradata Database indicates that the request was accepted and is being executed. It also lists the affected sessions and their status if you specify y or Y for list.

Parcel Sequence

Parcel Flavor Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo =1

ActivityCount = Number of sessions identified by the ABORT SESSION request

ActivityType = 86 (PCLABTSESS)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Data or IndicData list of sessions. This parcel is present only if you specified list.

EndStatement 11 6 StatementNo = 2-byte integer.

Success 8 18 to 273 StatementNo = 2

ActivityCount = 0 (Number of sessions identified by the ABORT SESSION request)

ActivityType = 86 (PCLABTSESS)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

EndStatement 11 6 StatementNo = 2-byte integer.

EndRequest 12 4 None.

Page 61: Workload management api

Chapter 3: PMPC APIsABORT SESSION

Workload Management API: PM/API and Open API 61

Statement Type: 1

The Record parcel in the first statement of the response returns the list of sessions in increasing order of HostId. The following table shows the values returned from the first statement.

If you do not specify logging off sessions, the Success parcel produced for the first statement, when applicable, includes a warning that identified sessions are in the process of committing or rolling back their transactions. An ABORT with logoff completes normally and does not produce any warnings.

Field Name Data TypeLength (Bytes) Description

HostId SMALLINT, NULLABLE

2 The logical host ID associated with a PE or session. For a PE, the Host ID identifies one of the hosts or LANs associated with the described PE. For a session, the combination of a host ID and a session number uniquely identifies a user session on the system.

Note: This value is NULL for AMPs. A value of zero represents the Supervisor window.

UserName VARCHAR 30 The user name of the session. This is the name specified when the user is created; it is used to log on to a session. Within Teradata Database, user name is almost equivalent to database name.

SessionNo INTEGER 4 The number of the current session. Together with a given host ID, a session number uniquely identifies a session on the Teradata Database system. This value is assigned by the host (or client) at logon time.

AbortStatus SMALLINT, NULLABLE

1 Information on the status of the associated session. The following values apply:

• I = In-Doubt

• A = Aborting a transaction

• C = Committing a transaction

• E = Executing an ABORT SESSION request

• S = Switching

• NULL = In some state other than the above

For an ABORT without LOGOFF, any status except NULL indicates the reason the request could not impact the associated session.

For an ABORT with LOGOFF, an I, E, or S status value indicates that the associated session cannot be aborted or logged off.

Page 62: Workload management api

Chapter 3: PMPC APIsABORT SESSION

62 Workload Management API: PM/API and Open API

Statement Type: 2

In the second response, the Teradata Database indicates that the request is complete. The completion response is sent only after all impacted sessions have been aborted and, if requested, logged off.

Sample Input

The following example illustrates how the parcels for an ABORT SESSION request built by CLIv2 look when sent to the Teradata Database server using a host_id of 348, session_no of 1000, user_name of user_01, list of Y, logoff of N, and override of N. In this example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

With a host_id of 52, session_no of 2521, user_name of DBC, list of y, and logoff of y, this request might return the following values in character text format. Your application program may return the values in a different format or display.

Success parcel:StatementNo: 1 ActivityCount: 1ActivityType: 86 FieldCount: 4

DataInfo iparcel:FieldCount: 4

Record parcel.Parcel flavor: 10 Parcel body length: 38HostId = 52, UserName = "DBC", SessionNo = 2521,AbortStatus = ' '.

EndStatement.Success parcel:StatementNo: 2 ActivityCount: 0ActivityType: 86 FieldCount: 0

DataInfo parcel:FieldCount: 0

Flavor Length Body

Num Name Bytes Field Char/Decimal

0001 Req 17 Request ABORT SESSION

0003 Data 47 MonVerID 2

HostId 348

SessionNo 1000

UserName user_01

ListOption Y

Logoff N

Override N

0004 Resp 6 BufferSize 32731

Page 63: Workload management api

Chapter 3: PMPC APIsABORT SESSION

Workload Management API: PM/API and Open API 63

EndStatement.EndRequest.

Warning and Error Messages

The following table describes the error messages that may be returned by an ABORT SESSION request.

For a discussion of common warning and error messages that may appear in response to ABORT SESSION and other requests, see “Common Warning and Error Messages” on page 50.

For more information on warning and error messages, see Messages.

Message Number Description

3252 Invalid Session ID/User Name Pair. Name does not match SessionID.

Remedy: Correct the error and resubmit the request. The IDENTIFY SESSION request can be used to determine the correct user name if the session ID and host ID are known.

3256 No such Session is currently logged on.

Remedy: Correct the error and resubmit the request.

3259 The LIST SESSIONS option must have a value of Y, y, N, n, BLANK, or NULL.

Remedy: Correct the error and resubmit the request.

3260 The LOGOFF SESSIONS option must have a value of Y, y, N, n, BLANK, or NULL.

Remedy: Correct the error and resubmit the request.

3261 The OVERRIDE option must have a value of Y, y, N, n, BLANK, or NULL.

Remedy: Correct the error and resubmit the request.

3265 Transaction has been Aborted by Administrator or Operations Staff.

Remedy: None.

3266 Transaction has been Aborted and Session Logged Off by Operations Staff.

Remedy: None.

3267 No sessions meet the Abort criteria.

Remedy: Resubmit the request after modifying the criteria.

3268 Command Disallowed: An identified session is not currently Abortable. See “Processing Messages” on page 59 for details.

Remedy: Determine the cause for the failure, correct the problem, and resubmit the request.

3269 Warning: An identified session is not currently Abortable.

Remedy: This warning is informational only.

Page 64: Workload management api

Chapter 3: PMPC APIsABORT SESSION

64 Workload Management API: PM/API and Open API

Relationship Between ABORT SESSION and MONITOR SESSION

When sessions are being aborted or sessions are being blocked by the sessions being aborted, data returned from subsequent MONITOR SESSION queries may be affected. After the abort operation starts, you can immediately notice the changes from aborting sessions. However, you will not notice the changes resulting from sessions that were blocked by aborting sessions in MONITOR SESSION responses until the abort operation is complete.

Aborted Sessions

For aborted sessions, expect the following types of changes in the response returned from a subsequent MONITOR SESSION query:

• PEState changes to PARSING. AMPState changes to ABORTING.

• AMPCPUSec is updated due to its continued tracking of the CPU time used during the transaction rollback process. Resources consumed during a transaction rollback are charged to the user the same way as any other form of resource usage.

• AMPIO is updated due to its tracking of logical I/O necessary during the transaction rollback process.

• Request_AMPSpool decreases if there are spool files in use by the aborted request, because those spool files are discarded.

• After the abort operation has completed and if the aborted sessions are not logged off, the sessions become IDLE (PEState) while they wait for subsequent requests.

If the aborted sessions are logged off, they are no longer tracked by subsequent MONITOR SESSION requests.

Blocked Sessions

For sessions blocked or slowed down by aborted sessions, expect the following types of changes in the response returned from a subsequent MONITOR SESSION query:

• The following response fields related to the aborted sessions are removed (that is, they are reported as NULLS because the blocking session is gone):

• Blk_x_HostId

• Blk_x_SessNo

• Blk_x_UserID

• Blk_x_LMode

• Blk_x_OType

• Blk_x_ObjDBId

• Blk_x_ObjTId

• Blk_x_Status

For example, the following describes the information that can be inferred from the returned data:

• Within a MONITOR SESSION, response fields show Session 1 blocked by Sessions 2 and 3.

• After an ABORT SESSION, Session 2 is removed.

Page 65: Workload management api

Chapter 3: PMPC APIsABORT SESSION

Workload Management API: PM/API and Open API 65

• Within a subsequent MONITOR SESSION, response fields show Session 1 blocked by Session 3.

• The MoreBlockers field may return data indicating there are no additional lock conflicts.

Because removing an aborted session allows another blocking session to be reported, there may be no remaining locks to report.

• If the aborted sessions are no longer blocking other sessions, the AMPState of those other sessions changes from BLOCKED to ACTIVE.

• For sessions that have changed to ACTIVE, or that are only slowed down by the aborted sessions, all resource usage fields may show a more rapid increase in resource usage. For example, the AMPCPUSec, AMPIO, and Request_AMPSpool fields may change more rapidly due to reduction in competition for those resources.

Before You Execute the ABORT SESSION Request

Execute the MONITOR SESSION before you execute the ABORT SESSION request to get a list of current sessions. Therefore, you can evaluate which sessions to abort. You can use the host ID, session number, and user name returned by the MONITOR SESSION request as input data to an ABORT SESSION request.

Some of the values returned by MONITOR SESSION can help you determine which session is not actively processing or has a long-running transaction. For example, look at PEState for the session in question. If PEState is not PARSING-WAIT, PARSING, DISPATCHING, BLOCKED, or ACTIVE, that session may be a good candidate for an abort. As another example, look at the ratio of AMPCPUSec to XactCount to determine which transaction has been running for a long time. If this ratio is high, this session has a long-running transaction.

It is also useful to run the QUERY SESSION request to determine how long a particular transaction has been running. Execute the MONITOR SESSION and QUERY SESSION request to pinpoint the source of the problem. By running these two requests, you may not need to abort as many transactions as originally planned. For more information on QUERY SESSION, see Utilities.

Relationship Between ABORT SESSION and MONITOR PHYSICAL RESOURCE

If you executed an ABORT SESSION request, data returned in a MONITOR VIRTUAL RESOURCE or MONITOR PHYSICAL RESOURCE request may be altered. Whether you notice the change in data depends on the scope of the ABORT SESSION request. For example, if you execute an ABORT SESSION and log off all of the sessions associated with a specific host (or client), the PEs associated with that client will report a large decrease in resource consumption. However, if the ABORT SESSION request only aborts one transaction from one session, you may not notice a change in AMP or PE resource use.

Page 66: Workload management api

Chapter 3: PMPC APIsABORT SESSION

66 Workload Management API: PM/API and Open API

Relationship Between ABORT SESSION and MONITOR VIRTUAL RESOURCE

For information on this PMPC CLIv2 interface relationship, see “Relationship Between ABORT SESSION and MONITOR PHYSICAL RESOURCE” on page 65.

Relationship Between ABORT SESSION and MONITOR PHYSICAL SUMMARY

The ABORT SESSION request affects the following usage statistics produced with the MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY request:

• When you complete an ABORT SESSION routine and log off the session, the SessionCount statistic returned by subsequent MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY requests reports a decreased number of sessions relative to the number of sessions aborted.

• Resource usage statistics returned by MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY are altered because the sessions that have been aborted and logged off affect the Teradata Database workload. Whether or not you notice a change in statistics depends on the extent of the impact of the ABORT SESSION. For example, you are more likely to notice if 40 out of 70 users are logged off than if 2 out of 70 users are logged off.

Relationship Between ABORT SESSION and MONITOR VIRTUAL SUMMARY

For information on this PMPC CLIv2 interface relationship, see “Relationship Between ABORT SESSION and MONITOR PHYSICAL SUMMARY” on page 66.

Page 67: Workload management api

Chapter 3: PMPC APIsIDENTIFY

Workload Management API: PM/API and Open API 67

IDENTIFY

PurposeReturns information on the locks blocking a session:

• Name of the user associated with a session

• User name of an object

• Database name of an object

• Name of a table

Input Data

Element Data TypeLength (Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

host_id SMALLINT, NULLABLE

2 The logical ID of a host (or client). host_id cannot exceed 1023. A host_id of zero identifies the system console ID of the host. A combination of host_id and session_no identifies a user causing a block.

session_no INTEGER, NULLABLE

4 The session number. A combination of host_id and session_no identifies a user causing a block.

To identify the user involved in a lock conflict, include the Blk_x_HostId and Blk_x_SessNo returned in a MONITOR SESSION response as input in the USING Data String for the IDENTIFY SESSION request.

database_id INTEGER, NULLABLE

4 The ID of the database for this session.

To identify the database name of the object involved in a block, include the Blk_x_ObjDBId returned in a MONITOR SESSION response as input in the USING Data String for the IDENTIFY DATABASE request.

Page 68: Workload management api

Chapter 3: PMPC APIsIDENTIFY

68 Workload Management API: PM/API and Open API

Note: Because the Blk_x_HostId, Blk_x_SessNo, and Blk_x_UserID fields returned by a MONITOR SESSION request may either be NULL or identify an internal session, the data returned by a MONITOR SESSION request that you use as input for the IDENTIFY request can result in error responses from IDENTIFY. If you use an internal session identifier as input to the IDENTIFY SESSION request, it will return a No such session currently logged on error message, and could potentially produce an Invalid HostId error message. The same error message No such session currently logged on is returned if you submit the IDENTIFY SESSION request for the DBQL/Teradata DWM artificial internal session.

If you use an NULL UserID as input to the IDENTIFY DATABASE or IDENTIFY USER request, they system will return an error message that says “Specified user/database identifier does not exist.” For more information on these types of errors, see “Warning and Error Messages” on page 63.

Usage Notes

The following table describes the different IDENTIFY options.

user_id INTEGER, NULLABLE

4 The ID of the user for this session.

To identify the user involved in a lock conflict, include the Blk_x_UserID field returned in a MONITOR SESSION response as input in the USING Data String for the IDENTIFY USER request.

table_id INTEGER, NULLABLE

4 The unique ID of a table.

To identify the table name of the object involved in a block, include the Blk_x_ObjTId returned in a MONITOR SESSION response as input in the USING Data String for the IDENTIFY TABLE request.

Note: The database name and user name are assigned an associated identifier when they are created. The IDENTIFY DATABASE or IDENTIFY USER request processes database and user names in the same manner because the database name and user name are almost equivalent.

Element Data TypeLength (Bytes) Description

Option Description

IDENTIFY DATABASE Identify a locked database.

IDENTIFY SESSION Identify a user (by session) who is causing a block. You can use IDENTIFY SESSION with a combination of host_id and session_no, or you can use IDENTIFY USER.

IDENTIFY TABLE Identify a locked table.

Page 69: Workload management api

Chapter 3: PMPC APIsIDENTIFY

Workload Management API: PM/API and Open API 69

A user must have MONSESSION privilege to execute the IDENTIFY request.

Parcels

Regardless of the form of the IDENTIFY request you execute, the response contains the following sequence of parcel types.

The Record parcel returns the Name field. Name is the name of the object (for example, database, user, or table) whose identifier was supplied by the IDENTIFY request. This field is a CHAR data type and has a length of 30 bytes.

IDENTIFY USER Identify a user who is causing a block. You can use IDENTIFY SESSION, or you can use IDENTIFY USER user_id.

System Table Name IDENTIFY Option

DBC.SessionTbl IDENTIFY SESSION

DBC.DBase IDENTIFY DATABASE

IDENTIFY USER

DBC.TVM IDENTIFY TABLE

Option Description

Parcel Sequence

Parcel Flavor Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 2

ActivityCount = 1

ActivityType = 85 (PCLIDENTIFY)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This record contains the user name with the specified user ID or database ID, user name logged on as the specified session, or table name with the specified table ID.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Page 70: Workload management api

Chapter 3: PMPC APIsIDENTIFY

70 Workload Management API: PM/API and Open API

Sample Input

The following example shows how the Request parcels for an IDENTIFY SESSION request, built by CLIv2, appear when sent to the Teradata Database server using a host_id of 348 and a session_no of 1000.

Note: In this example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

The following example shows how the Request parcels for an IDENTIFY USER request, built by CLIv2, look when they are sent to the Teradata Database server using a user_id of 725.

Note: In this example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

The next example shows how the Request parcels for an IDENTIFY TABLE request, built by CLIv2, look when they are sent to the Teradata Database server using a table_id of 183351.

Note: In this example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

Flavor Length Body

Num Name Bytes Field Value

0001 Req 20 Request IDENTIFY SESSION

0003 Data 12 MonVerID 2

HostId 348

SessionNo 1000

0004 Resp 6 BufferSize 32731

Flavor Length Body

Num Name Bytes Field Value

0001 Req 21 Request IDENTIFY DATABASE or IDENTIFY USER

0003 Data 10 MonVerID 2

UserID 725

0004 Resp 6 BufferSize 32731

Page 71: Workload management api

Chapter 3: PMPC APIsIDENTIFY

Workload Management API: PM/API and Open API 71

Sample Output

With a host_id of 52 and a session_no of 31467, the IDENTIFY SESSION request might return the following values. These example values are returned in text character format. Your application program may return the values in a different format or display.

Success parcel:StatementNo: 1 ActivityCount: 1ActivityType: 85 FieldCount: 1

DataInfo parcel:FieldCount: 1

Record parcel.Parcel flavor: 10 Parcel body length: 31Name = "DBC ".

EndStatement.EndRequest.

With a database_id of 1012, the IDENTIFY DATABASE request might return the following values. These example values are returned in text character format. Your application program may return the values in a different format or display.

Success parcel:StatementNo: 1 ActivityCount: 1ActivityType: 85 FieldCount: 1

DataInfo parcel:FieldCount: 1

Record parcel.Parcel flavor: 10 Parcel body length: 31Name = "weekly ".

EndStatement.EndRequest.

With a user_id of 1012, the IDENTIFY USER request might return the following values. These example values are returned in text character format. Your application program may return the values in a different format or display.

Success parcel:StatementNo: 1 ActivityCount: 1ActivityType: 85 FieldCount: 1

DataInfo parcel:FieldCount: 1

Record parcel.Parcel flavor: 10 Parcel body length: 31Name = "weekly ".

Flavor Length Body

Num Name Bytes Field Value

0001 Req 18 Request IDENTIFY TABLE

0003 Data 10 MonVerID 2

TableId 183351

0004 Resp 6 BufferSize 32731

Page 72: Workload management api

Chapter 3: PMPC APIsIDENTIFY

72 Workload Management API: PM/API and Open API

EndStatement.EndRequest.

With a table_id of 63, the IDENTIFY TABLE request might return the following values. These example values are returned in text character format. Your application program may return the values in a different format or display.

Success parcel:StatementNo: 1 ActivityCount: 1ActivityType: 85 FieldCount: 1

DataInfo parcel:FieldCount: 1

Record parcel.Parcel flavor: 10 Parcel body length: 31Name = "EventLog ".

EndStatement.EndRequest.

Warning and Error Messages

The following table describes the error messages that may be returned by the IDENTIFY request.

For a discussion of common warning and error messages that may be returned in response to IDENTIFY and other requests, see “Common Warning and Error Messages” on page 50.

For more information on warning and error messages, see Messages.

Relationship Between IDENTIFY and MONITOR SESSION

PM/API can report on locks placed by any user or object with the MONITOR SESSION and IDENTIFY requests. The MONITOR SESSION request helps you identify the types of locks blocking a session.

The MONITOR SESSION request:

• Monitors the currently executing processes and reports blocks preventing sessions from doing useful work, for both application or utility locks causing the block.

• Tells you not only which session is blocked and on what type of object but also who is holding the lock. You can trace a blocked session back to the object locked and display the

Message Number Description

3256 No such Session is currently logged on.

Remedy: Correct the error and resubmit the request.

3257 The specified Table Identifier does not exist.

Remedy: Correct the error and resubmit the request.

3258 The specified User/Database Identifier does not exist.

Remedy: Correct the error and resubmit the request.

Page 73: Workload management api

Chapter 3: PMPC APIsIDENTIFY

Workload Management API: PM/API and Open API 73

owner of the lock if your job is hung or is running very slowly and you suspect there is a lock conflict involved.

• On a query, reports up to three lock conflicts per session, with a flag (MoreBlockers) to indicate if there are more lock conflicts involved but not reported. The types of lock information returned for each session include:

• User ID or user of host utility job causing a block

• Type of object (for example, database, table, or row hash) causing a lock

• Mode or severity of lock

• Database identifier of object being locked

• Table identifier of object being locked

By looking at the logical host ID of a session causing the block in combination with the session number of the session causing a block, you can uniquely identify the session that is causing a block.

Although you have the above lock information, you must use the IDENTIFY request to further identify the locks as either a user name, database name, or table name. Use the Blk_ data values (or fields) returned in the MONITOR SESSION operation as input for an IDENTIFY request.

MONITOR SESSION, with IDENTIFY, is a more powerful diagnostic tool than the Show Locks utility accessed through Host Utility Console Subsystem (HUTCNS) and Database Window (DBW) on MP-RAS, Linux and Windows, which displays information about only client utility locks on an object and does not report who the lock is blocking.

Example

The following example output shows that SessionNo 1001 is blocked by SessionNo 1000 by a WRITE lock that has been granted on a table object type. Records are sorted in HostId and then SessionNo order.

First Record:

HostId = 719..

SessionNo = 1000...

Second Record:

HostId = 719..

SessionNo = 1001..

Blk-1-HostId = 719Blk-1-SessNo = 1000Blk-1-UserID = 10Blk-1-LMode = ‘W’

Page 74: Workload management api

Chapter 3: PMPC APIsIDENTIFY

74 Workload Management API: PM/API and Open API

Blk-1-OType = ‘T’Blk-1-ObjDBId = 12Blk-1-ObjTId = 1097Blk-1-Status = ‘G’Blk-2-HostId = NULL

.

.

.

Note: When the Blk_2_ HostId, Blk_2_SessNo, and Blk_2_UserID values are returned as NULLs, this usually means that the blocking job is a HUT job that has logged off without releasing its lock.

Because the data returned here does not tell you which user is causing the block or which table is locked, you must next use the IDENTIFY request with the output from your MONITOR SESSION to return that information.

To identify the user causing the lock, execute the IDENTIFY request with:

HostId = 719SessionNo = 1000

Or:

UserID = 10

To identify a locked database, execute the IDENTIFY request with:

ObjDBId = 12

To identify a locked table, execute the IDENTIFY request with:

ObjTId = 1097

Page 75: Workload management api

Chapter 3: PMPC APIsMONITOR AWT RESOURCE

Workload Management API: PM/API and Open API 75

MONITOR AWT RESOURCE

PurposeCollects statistics on AMPs based on the in-use Amp Worker Tasks (AWTs).

Input Data

Note: You can define up to four thresholds for categorizing AMPs.

Usage Notes

This interface provides a snapshot of AMP utilization based on the number of AWTs in use within the MSGWORKNEW and MSGWORKONE message work types. These two message work types are a barometer for AMP activity/health. The MONITOR AWT RESOURCE request allows the specification of four thresholds which are used to categorize AMPs. AMPs are counted into categories defined by these thresholds and based on the AWT usage of the AMP.

This request also indicates the number of AMPs currently in some form of Flow Control. Flow Control can be defined at a node level and therefore may not have a system-wide consistent definition. This indication is only applicable to those messages to which Flow Control is applicable.

Element Data TypeLength(Bytes) Description

mon_ver_id SMALLINT, NOT NULL

2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Threshold 1 SMALLINT,NOT NULL

2 The first threshold value. The minimum value for in-use AWTs to qualify an AMP for inclusion into this interval.

Threshold 2 SMALLINT,NULLABLE

2 The second threshold value. The start value for in-use AWTs to qualify an AMP for inclusion into this interval.

Threshold 3 SMALLINT,NULLABLE

2 The third threshold value. The start value for in-use AWTs to qualify an AMP for inclusion into this interval.

Threshold 4 SMALLINT,NULLABLE

2 The fourth threshold value. The start value for in-use AWTs to qualify an AMP for inclusion into this interval.

Page 76: Workload management api

Chapter 3: PMPC APIsMONITOR AWT RESOURCE

76 Workload Management API: PM/API and Open API

MONITOR AWT RESOURCE provides information on the AMPs having the highest and lowest in-use counts within the system. When duplicate in-use counts exist, the AMP information returned is for the AMPs with the largest VProc ID.

Thresholds must be defined in ascending order and cannot contain gaps. If a gap is detected, the following error message appears:

INVALID THRESHOLDDEFINED

For information on this error, see “Warning and Error Messages” on page 72.

Thresholds that are not used must be set to -1 (or NULLABLE). The minimum valid threshold value is zero.

Parcels

The MONITOR AWT RESOURCE request is treated internally as a one statement request that generates two responses. The statement response returned from Teradata Database contains the following sequence of parcel types.

Parcel Sequence

Parcel Flavor

Length(Bytes) Comments and Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = 1

ActivityType = 175 (PCLMONAWTRESSTMT)

DataInfo 71 6 to 32004 Optional: This parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on the request (Data or IndicData) data is returned in Record or Indicator mode. This record contains information in StatementNo-1. For an example of this record, see “Statement Type: 1” on page 77.

EndStatement 11 6 StatementNo = 2-byte integer=1

Success 8 18 to 273 StatementNo = 2

ActivityCount = 1

ActivityType = 175 (PCLMONAWTRESSTMT)

DataInfo 71 6 to 32004 Optional: This parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on the request (Data or IndicData) data is returned in Record or Indicator mode. This record contains information in StatementNo-2. For an example of this record, see “Statement Type: 2” on page 77.

Page 77: Workload management api

Chapter 3: PMPC APIsMONITOR AWT RESOURCE

Workload Management API: PM/API and Open API 77

Response

The MONITOR AWT RESOURCE request returns the following information: the number of AWTs in use within the MSGWORKNEW and MSGWORKONE message work types; the number of AMPs currently in some form of Flow Control; and the number of AMPs having the highest and lowest in-use counts within the system.

The output is divided into two statement types:

• The first statement type provides information about the Sample rate.

• The second statement type provides information about AMPs and the AMPs AWT distribution across the defined thresholds.

Statement Type: 1

The first statement type is a Record parcel format containing the SampleSec field. SampleSec is the duration of the sample period, in seconds. It contains the Monitor Virtual Collection Rate (VprocMonitor). It is an INTEGER, NOT NULL data type and has a length of 4 bytes.

For example:

Field name data type length descriptionSampleSec NTEGER 4SampleSec is equivalent to Monitor Virtual Collection Rate.

NOT NULL

To avoid excessive AWT data collection, Monitor AWT Resource checks if the data in the buffer is still valid in relation to the value set for SampleSec (VProcMonitor rate) and only collects new data if it has expired.

Statement Type: 2

The second statement type is a Record parcel format containing information about AMPs and the AMPs AWT distribution across the defined thresholds.

EndStatement 11 6 StatementNo = 2-byte integer=1

EndRequest 12 4 None

Parcel Sequence

Parcel Flavor

Length(Bytes) Comments and Key Parcel Body Fields

Field Name Data TypeLength (Bytes) Description

Interval 1 Count INTEGER, NOT NULL

4 The number of AMPs in the system whose in-use AWT counts fall at, or above, the Threshold 1 value and do not qualify for the higher thresholds.

Interval 2 Count INTEGER, NULLABLE

4 The number of AMPs in the system whose in-use AWT counts fall at, or above, the Threshold 2 value and do not qualify for the higher thresholds.

Page 78: Workload management api

Chapter 3: PMPC APIsMONITOR AWT RESOURCE

78 Workload Management API: PM/API and Open API

Interval 3 Count INTEGER, NULLABLE

4 The number of AMPs in the system whose in-use AWT counts fall at, or above, the Threshold 3 value and do not qualify for the higher thresholds.

Interval 4 Count INTEGER, NULLABLE

4 The number of AMPs in the system whose in-use AWT counts fall at, or above, the Threshold 4 value and do not qualify for the higher thresholds.

Flow Control INTEGER, NULLABLE

4 The number of AMPs currently in some form of Flow Control.

High AMP 1 VprocId

INTEGER, NULLABLE

4 The vproc ID of the AMP with the highest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

High AMP 1 In-Use Count

INTEGER, NULLABLE

4 The in-use count associated with the AMP 1 Vproc ID. This is only applicable if AMP 1 is defined.

High AMP 2 VprocId

INTEGER, NULLABLE

4 The vproc ID of the AMP with the next highest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

High AMP 2 In-Use Count

INTEGER, NULLABLE

4 The in-use count associated with the AMP 2 Vproc ID. This is only applicable if AMP 2 is defined.

High AMP 3 VprocId

INTEGER, NULLABLE

4 The vproc ID of the AMP with the next highest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

High AMP 3 In-Use Count

INTEGER, NULLABLE

4 The in-use count associated with the AMP 3 Vproc ID. This is only applicable if AMP 3 is defined.

High AMP 4 VprocId

INTEGER, NULLABLE

4 The vproc ID of the AMP with the next highest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

High AMP 4 In-Use Count

INTEGER 4 The in-use count associated with the AMP 4 Vproc ID. This is only applicable if AMP 4 is defined.

High AMP 5 VprocId

INTEGER, NULLABLE

4 The vproc ID of the AMP with the next highest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

High AMP 5 In-Use Count

INTEGER 4 The in-use count associated with the AMP 5 Vproc ID. This is only applicable if AMP 5 is defined.

Field Name Data TypeLength (Bytes) Description

Page 79: Workload management api

Chapter 3: PMPC APIsMONITOR AWT RESOURCE

Workload Management API: PM/API and Open API 79

Low AMP 1 VprocId INTEGER, NULLABLE

4 The vproc ID of the AMP with the lowest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

Low AMP 1 In-Use Count

INTEGER, NULLABLE

4 The in-use count associated with the AMP 1 Vproc ID. This is only applicable if AMP 1 is defined.

Low AMP 2 VprocId INTEGER, NULLABLE

4 The vproc ID of the AMP with the lowest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

Low AMP 2 In-Use Count

INTEGER, NULLABLE

4 The in-use count associated with the AMP 2 Vproc ID. This is only applicable if AMP 2 is defined.

Low AMP 3 VprocId INTEGER, NULLABLE

4 The vproc ID of the AMP with the lowest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

Low AMP 3 In-Use Count

INTEGER, NULLABLE

4 The in-use count associated with the AMP 3 Vproc ID. This is only applicable if AMP 3 is defined.

Low AMP 4 VprocId INTEGER, NULLABLE

4 The vproc ID of the AMP with the lowest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

Low AMP 4 In-Use Count

INTEGER, NULLABLE

4 The in-use count associated with the AMP 4 Vproc ID. This is only applicable if AMP 4 is defined.

Low AMP 5 VprocId INTEGER, NULLABLE

4 The vproc ID of the AMP with the lowest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

Low AMP 5 In-Use Count

INTEGER, NULLABLE

4 The in-use count associated with the AMP 5 Vproc ID. This is only applicable if AMP 5 is defined.

Flow Control 1 VprocId,

Flow Control 2 VprocId,

Flow Control 3 VprocId,

Flow Control 4 VprocId,

Flow Control 5 VprocId

INTEGER, NULLABLE

4 The vproc ID of the AMP in flow control. A value of -1 (or NULLABLE) indicates this field is not defined.

Field Name Data TypeLength (Bytes) Description

Page 80: Workload management api

Chapter 3: PMPC APIsMONITOR AWT RESOURCE

80 Workload Management API: PM/API and Open API

Sample Input

The following example shows how the parcels for a MONITOR AWT RESOURCE request, built by CLIv2, appear when sent to the Teradata Database server.

Note: In this example, the size of the response buffer in the example is set at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

The MONITOR AWT RESOURCE request returns values approximately as shown below when Category 3 is active and the following input data is specified:

Threshold 1 = 10Threshold 2 = 12Threshold 3 = 14Threshold 4 = 15

The MONITOR AWT RESOURCE request commonly returns values in text character format. Your application program may return the values in a different format or display.

SampleRate: 600

Intervals: 1 2 3 4 0 0 0 0

Flow Control = 0

*** HIGH AMP *** 1 2 3 4 5 VprocId: 0 7 6 5 4 InUseCount: 2 1 1 1 1

*** LOW AMP *** 1 2 3 4 5VprocId: 7 6 5 4 3InUseCount: 1 1 1 1 1

*** FLOW CONTROL INFO ***

Flavor Length Body

Num Name Bytes Field Value

0001 Req 16 Request MONITOR AWT RESOURCE

0003 Data 57 mon_ver_id

Threshold 1

Threshold 2

Threshold 3

Threshold 4

6

10

12

14

15

0004 Resp 6 BufferSize 32731

Page 81: Workload management api

Chapter 3: PMPC APIsMONITOR AWT RESOURCE

Workload Management API: PM/API and Open API 81

1 2 3 4 5VprocId -1 -1 -1 -1 -1

Warning and Error Messages

The following table describes the error message that may be returned by the MONITOR AWT RESOURCE request.

For more detailed information on warning and error messages, see Messages.

Message Number Description

3324 More data exists than was returned.

This is a warning that there were more records to be returned than would fit into the response buffer.

Remedy: Increase the size of the response buffer if all records are desired.

3325 Invalid threshold has been specified as an input argument of the MONITOR AWT RESOURCE request.

Thresholds must be defined in ascending order and cannot contain gaps. Thresholds that are not used must be set to -1. The minimum valid threshold is 0.

Remedy: Correct threshold value and resubmit the request.

Page 82: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL CONFIG

82 Workload Management API: PM/API and Open API

MONITOR PHYSICAL CONFIG

PurposeCollects overall information on node availability. Node status information is returned for all nodes in the system.

Input Data

Monitor Privileges

Unless monitor privileges have been established as part of the default role for the user, users must set a session role before exercising any of the monitor privileges for that role. If the current role is a specified non-NULL role, the user may be able to utilize monitor privileges via the current role or its nested roles. If the current role is ALL, the user may be able to use monitor privileges via any roles directly and indirectly granted. For more information, see Database Administration and Security Administration.

Usage Notes

A user must have any one of the following MONITOR privileges to execute the MONITOR PHYSICAL CONFIG request:

• ABORTSESSION

• MONRESOURCE

• MONSESSION

• SETRESRATE

• SETSESSRATE

ElementDataType

Length (Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if using indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Page 83: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL CONFIG

Workload Management API: PM/API and Open API 83

MONITOR PHYSICAL CONFIG is most useful when used with the MONITOR PHYSICAL SUMMARY request for doing a quick overall system health check. For more information, see “Relationship Between MONITOR PHYSICAL CONFIG and MONITOR PHYSICAL SUMMARY” on page 86.

You can use the MONITOR PHYSICAL CONFIG request instead of dumping the DBC.SW_Event_Log table (accessible from the DBC.Software_Event_LogV view) to check for a physical problem with the system.

Parcels

The MONITOR PHYSICAL CONFIG request is treated internally as a two statement request, with each statement generating a response. Teradata Database returns the two statement response containing the following sequence of parcels.

Parcel Sequence

Parcel Flavor

Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = 1

ActivityType = 92 (PCLMONPCONFIG)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This record contains the BYNET status data.

EndStatement 11 6 StatementNo = 2-byte integer

Success 8 18 to 273 StatementNo = 2

ActivityCount = Number of nodes

ActivityType = 92 (PCLMONPCONFIG)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This record contains the node-specific information; one record per node.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Page 84: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL CONFIG

84 Workload Management API: PM/API and Open API

For descriptions of the flavor field and length field, see Teradata Call-Level Interface Version 2 Reference for Channel-Attached Systems or Teradata Call-Level Interface Version 2 Reference for Network-Attached Systems. Within the parcel body fields, the order of items and their data types and lengths are determined by the USING Phrase.

Statement Type: 1

The Record parcel in the first statement of the MONITOR PHYSICAL CONFIG response returns two-column BYNET status values that are generated once for the whole system. The following table shows these response values.

Statement Type: 2

The response to the second statement results in multiple Record parcels that consist of a record for each node in the system, with six fields in each record. For example, if you have two nodes, two records are returned with specific information for each processor, in addition to the one record of BYNET data for the whole system.

Records are sorted based on NodeID. The following table shows the order in which the Record parcel returns the data.

Column Field Name Data TypeLength(Bytes) Description

1 NetAUp CHAR, NULLABLE

1 The status of the BYNETs (if there are more than two, the first two) on a system-wide basis. The following values apply:

• D = Down/Offline

• U = Up/Online

• S = Standby

2 NetBUp CHAR NULLABLE

1 The status of the BYNETs (if there are more than two, the first two) on a system-wide basis.

The following values apply:

• D = Down/Offline

• U = Up/Online

• S = Standby

Note: The value is always zero.

3 SystemType CHAR 7 The type of system running the Teradata Database software, such as 3400, 3500, 5100, or “Unknown.”

Page 85: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL CONFIG

Workload Management API: PM/API and Open API 85

Sample Input

The following example shows how the parcels for a MONITOR PHYSICAL CONFIG request, built by CLIv2, look when sent to the Teradata Database server.

Note: In the following example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

Field Name Data TypeLength (Bytes) Description

ProcId SMALLINT 2 The ID associated with a node. This value is computed as the module number within a cabinet plus 100 times the cabinet number. Usually formatted for display as zz9-99. However, this display format can be changed by the user.

Status CHAR 1 The status of the node, AMP, or PE associated with this record. The following values apply:

• U = Up/online

• D = Down

• S = Standby

A vproc or node is up (U) when it is:

• Configured into the system

• Online

• Capable of actively performing tasks associated with normal Teradata Database activity

Down (D) represents all other potential states.

Standby (S) indicates the vproc or node is ready to join the configuration in place if another vproc or node goes down.

CPUType VARCHAR 7 The type of central processing unit (CPU) installed in this node, for example: 'Pentium', 'PentPro', or 'Unknown'.

CPUCount INTEGER 4 The number of CPUs in this node.

Flavor Length Body

Num Name Bytes Field Value

0001 Req 27 Request MONITOR PHYSICAL CONFIG

0003 Data 6 MonVerID 2

0004 Resp 6 BufferSize 32731

Page 86: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL CONFIG

86 Workload Management API: PM/API and Open API

Sample Output

This request might return the following values in character text format. Your application program may display returned values in a different format.

Success parcel:StatementNo: 1 ActivityCount: 1ActivityType: 92 FieldCount: 3

DataInfo parcel:FieldCount: 3

Record parcel.Parcel flavor: 10 Parcel body length: 10NetAUp = 'U', NetBUp = 'U', SystemType = "5100 ".

EndStatement.Success parcel:StatementNo: 2 ActivityCount: 2ActivityType: 92 FieldCount: 4

DataInfo parcel:FieldCount: 4

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 736, ProcStatus = 'U', CPUType = "Pentium", CPUCount = 8.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 746, ProcStatus = 'U', CPUType = "Pentium", CPUCount = 8.

EndStatement.EndRequest.

Warning and Error Messages

The MONITOR PHYSICAL CONFIG request does not return any unique warning or error messages. For a list of general warning and error messages that may appear in response to MONITOR PHYSICAL CONFIG and other requests, see “Common Warning and Error Messages” on page 50.

For more detailed information on warning and error messages, see Messages.

Relationship Between MONITOR PHYSICAL CONFIG and MONITOR PHYSICAL SUMMARY

Use the MONITOR PHYSICAL SUMMARY request with the MONITOR PHYSICAL CONFIG request for an overall system status. These are low overhead requests.

• Execute the MONITOR PHYSICAL SUMMARY request every 5 or 10 minutes for a low-cost, continuous monitoring of your system.

• Execute the MONITOR PHYSICAL CONFIG request to get a picture of your system configuration at defined times, such as at the beginning of a day, various times during the day, or when the system is down.

Use these requests to spot problems, such as abnormal Central Processing Unit (CPU) load balancing, and possible sources of system performance bottlenecks. For example, if the High/LowCPUUse figures are consistently widely separated and do not approximate the AvgCPU figure, you may need to evaluate whether the system is using available resources efficiently.

Page 87: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL CONFIG

Workload Management API: PM/API and Open API 87

How often you check your system depends on the size of your system and the type of applications your system runs.

Knowledge of the overall system status can help you to determine these three concerns.

If the data returned from a MONITOR PHYSICAL SUMMARY query does not give you enough information (for example, you need BYNET or CPU% busy information), use the MONITOR PHYSICAL RESOURCE request to obtain more detailed resource usage data.

The data returned by the MONITOR PHYSICAL CONFIG request is an abbreviated form of the data returned by the MONITOR PHYSICAL RESOURCE request.

Note: The MONITOR PHYSICAL CONFIG and MONITOR PHYSICAL SUMMARY requests do not return the status of non-Teradata Database nodes. However, the MONITOR PHYSICAL RESOURCE and MONITOR PHYSICAL SUMMARY requests accumulate and return data on some resources consumed by non-Teradata applications running on Teradata Database nodes. To determine the resources consumed by non-Teradata applications, compare:

• Data returned by the MONITOR PHYSICAL RESOURCE request with that of the MONITOR VIRTUAL RESOURCE request (that is, the subtotal of the various resource statistics by node).

• Data returned by the MONITOR PHYSICAL SUMMARY request with that of the MONITOR VIRTUAL SUMMARY request (that is, the subtotal/average by node of the various resource statistics in the MONITOR VIRTUAL SUMMARY).

Concern Comments

When to run production applications, especially large ones

For example, if you have a down node, some Access Module Processors (AMPs) and Parsing Engines (PEs) may migrate to other nodes. It may be less costly to recover the node first and run the job than to run the job without full system availability.

Why an application runs more slowly than usual

This situation may be caused by a down node, which causes the online nodes to run more than the optimal number of AMPs and PEs. This, in turn, could cause your application to run more slowly.

Whether all nodes have come back up after a system restart

Examine the Status value returned in a MONITOR PHYSICAL CONFIG request to determine whether each node is up or down.

Page 88: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

88 Workload Management API: PM/API and Open API

MONITOR PHYSICAL RESOURCE

PurposeCollects node resource usage data.

Input Data

Monitor Privileges

Unless monitor privileges have been established as part of the default role for the user, users must set a session role before exercising any of the monitor privileges for that role. If the current role is a specified non-NULL role, the user may be able to utilize monitor privileges via the current role or its nested roles. If the current role is ALL, the user may be able to use monitor privileges via any roles directly and indirectly granted. For more information, see Database Administration and Security Administration.

Usage Notes

Because information is given on the detailed resource usage of each node, performance concerns can be isolated by node. A MONITOR PHYSICAL RESOURCE request returns the following data:

• System-wide (identical for all nodes) data

• Node-specific data

A user must have the MONRESOURCE privilege to execute the MONITOR PHYSICAL RESOURCE request.

Use the MONITOR PHYSICAL RESOURCE request to:

Element Data TypeLength(Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Page 89: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

Workload Management API: PM/API and Open API 89

• Expand on the data reported by the MONITOR PHYSICAL SUMMARY request.

In your initial problem analysis, a MONITOR PHYSICAL SUMMARY request may indicate a performance or system problem. MONITOR PHYSICAL RESOURCE allows you to gather resource usage information on a node by node basis.

• Continually monitor your system.

Monitor your system on a periodic basis, for example, every 10 minutes. Use this request to build a normal baseline profile for your system. When you notice something abnormal or a user complains that a job is slow (such as the last reading is significantly different from the normal baseline reading), this request can tell you:

• If there is a parallel efficiency problem

• A constraint to throughput

• And which node is causing it.

For example:

• If one PE shows a much higher usage than the other PEs, then the PE might be overloaded.

• If one AMP is loaded more heavily than the other AMPs, then you may have problems with a skewed index.

• Determine whether a new application can be added to the current system load without disruption.

The node usage information collected by this request can help you evaluate the impact of adding new applications to an already heavily utilized system and help you plan potential system upgrades.

• Help resolve problems that session-level usage information cannot resolve.

When the MONITOR SESSION request does not show any cause for the problem, the MONITOR PHYSICAL RESOURCE request provides information on congestion, memory allocations, BYNET outages, and system status.

The MONITOR PHYSICAL RESOURCE request provides the following information:

• How the system is being used (for example, the percentage of CPU usage by node)

• How system resource usage is spread across the nodes

• How much physical disk Input/Output (I/O), BYNET traffic, or host reads and writes are occurring

• Whether congestion or excessive swapping is a problem on any node or group of nodes

The MONITOR PHYSICAL RESOURCE request returns some of the same fields found in the resource usage (ResUsage) tables. You can use both MONITOR PHYSICAL RESOURCE and resource usage data for problem detection. Unlike resource usage data, MONITOR PHYSICAL RESOURCE data is instantaneous, requires less overhead to produce, but is less comprehensive. MONITOR PHYSICAL RESOURCE data helps detect:

• Poor Node CPU parallel efficiency

• Poor disk parallel efficiency

• A higher than expected disk read/write ratio

Page 90: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

90 Workload Management API: PM/API and Open API

• A high swap I/O rate

If the MONITOR PHYSICAL RESOURCE request does not provide enough detailed data for problem detection, run one or more of the resource usage macros, such as the Node resource usage macros. For more information, see Resource Usage Macros and Tables.

Note: You must set the ResMonitor rate (rate at which node resource usage data is updated within memory) to a nonzero value to allow the MONITOR PHYSICAL RESOURCE request to return meaningful data. If you set the ResMonitor rate to zero, NULL values are returned for all node usage data.

After a system outage or a change in the ResMonitor rate, do not request data again until after completion of the first sample period requested after the crash or change in rate. Otherwise, the data returned will contain NULL values except NetAUp, NetBUp, SampleSec, ProcId, AMPCount, PECount, and Status, and may not be fully representative. The in-memory counters reset after a crash. Typically the contents of the counters are not well defined until a full sample period has elapsed. If you were logged on prior to the system outage, and you issue the first MONITOR PHYSICAL RESOURCE request after the outage, then you will receive a warning that the Teradata Database system has been restarted.

Parcels

The MONITOR PHYSICAL RESOURCE request is treated internally as a two statement request with each statement generating a response. The Teradata Database returns a two statement response containing the following sequence of parcel types.

Parcel Sequence

Parcel Flavor

Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = 1

ActivityType = 96 (PCLMONPRES)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. One record is returned. It contains the duration of the sample period (in seconds) and BYNET status.

EndStatement 11 6 StatementNo = 2-byte integer

Success 8 18 to 273 StatementNo = 2

ActivityCount = Number of nodes

ActivityType = 96 (PCLMONITOPRES)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicReq parcel.

Page 91: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

Workload Management API: PM/API and Open API 91

Statement Type: 1

The response to the first statement results in a Record parcel containing global data about sample duration and BYNET status that is generated once for the whole system. The following table shows the order in which the data is returned.

Statement Type: 2

The response to the second statement results in multiple Record parcels that consist of a one record of 32 fields for each node in the system. For example, if you have 50 nodes, 50 records are returned with specific information for each node. One record describes the sample period, and BYNET status for the entire system.

The following table shows the order in which the Record parcel returns the data.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. One record per node is returned. Each record contains a description for each node in the system.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Field Name Data TypeLength (Bytes) Description

NetAUp,

NetBUp

CHAR, NULLABLE

1 The status of the BYNETs (if there are more than two, the first two) on a system-wide basis. The following values apply:

• D = Down/Offline

• U = Up/Online

• S = Standby

SampleSec SMALLINT 2 The duration of the sample period, in seconds. This field is equivalent to the ResMonitor rate. See ResMonitor rate for more information.

Parcel Sequence

Parcel Flavor

Length (Bytes) Comments/Key Parcel Body Fields

Page 92: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

92 Workload Management API: PM/API and Open API

Field Name Data TypeLength (Bytes) Description

ProcId SMALLINT 2 The ID associated with a node. This value is computed as the module number within a cabinet plus 100 times the cabinet number. Usually formatted for display as zz9-99. However, this display format can be changed by the user.

AmpCount SMALLINT 2 The current number of AMPs currently executing on the associated node.

PECount SMALLINT 2 The current number of active PEs on the associated node.

CPUUse FLOAT, NULLABLE, range 0 - 100%

8 The % of CPU usage not spent being idle. The node-level display is computed from ResUsageSpma table data as:

PercntUser + PercntService

The vproc-level displays is computed from ResUsageSvpr table data as:

100.00 * (CPUUExecPart00 + CPUUExecPart01 + ... + CPUUExecPart15 + CPUUServPart00 + CPUUServPart01 + ... + CPUUServPart15) / (x * SampleSec)

This value is NULL if:

• Nodes, AMPs, or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

PercntKernel FLOAT, NULLABLE

8 The % of CPU resources spent in UNIX/PDE kernel processing. This value is computed from ResUsageSpma data as follows, where x is the number of CPUs:

CPUIOWAIT* /(x * SampleSec)

This value is NULL if:

• Nodes are down or offline.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Page 93: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

Workload Management API: PM/API and Open API 93

PercntService FLOAT, NULLABLE

8 The % of CPU resources spent in UNIX/PDE user service processing. For node-level displays, the value is computed from the ResUsageSpma table data, where x represents the number of CPUs:

CPUUServ *(x * SampleSec)

For vproc-level displays, the value is computed from the ResUsageSvpr table data, where x represents the number of CPUs:

(CPUUServPart00 + CPUUServPart01 + ... + CPUUServPart15)* / (x * SampleSec)

This value is NULL if:

• Nodes, AMPs, or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

PercntUser FLOAT, NULLABLE

8 The % of CPU resources spent in non-service user code processing. This value is computed from the ResUsageSpma table data, where x represents the number of CPUs:

CPUUExec */ (x * SampleSec)

This value is NULL if:

• Nodes are down or offline.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Field Name Data TypeLength (Bytes) Description

Page 94: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

94 Workload Management API: PM/API and Open API

Status CHAR 1 The status of the node, AMP, or PE associated with this record. The following values apply:

• U = Up/online

• D = Down

• S = Standby

A vproc or node is up (U) when it is:

• Configured into the system

• Online

• Capable of actively performing tasks associated with normal Teradata Database activity

Down (D) represents all other potential states.

Standby (S) indicates the vproc or node is ready to join the configuration in place if another vproc or node goes down.

NetAUse FLOAT, NULLABLE

8 The % of BYNET A usage. This is the actual BYNET receiver usage. (The BYNET transmitter usage is maintained in ResUsage separately and is typically lower than the receiver usage. This is caused by multicasts, where one transmitter sends a message to many receivers.) This value is computed from the ResUsageSpma table data as:

(netsamples ? nettxidle) / netsamples * 100.0

This value is NULL if:

• ResMonitor is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

NetBUse FLOAT, NULLABLE

8 This field is obsolete. It returns the same value as NetAUse.

Field Name Data TypeLength (Bytes) Description

Page 95: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

Workload Management API: PM/API and Open API 95

DiskUse FLOAT, NULLABLE

8 The % of disk usage per node or AMP.

For node-level displays, this value is computed from ResUsageSldv table data as follows, assuming n is the number of ldv controllers used by this node:

(LdvOutReqTime 1 + ... + LdvOutReqTime n) / (n*SampleSec)

For vproc-level displays, this value is computed from the ResUsageSvdsk table data, assuming it is the number of logical devices used by this AMP:

(OutReqTime 1 + ... + OutReqTime n) / SampleSec

Note: DiskUse does not take into account overlapping of operations among multiple storage controllers, but it allows for the possibility of multiple requests for the same controller.

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

CICUse FLOAT, NULLABLE

8 This field is obsolete.

Field Name Data TypeLength (Bytes) Description

Page 96: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

96 Workload Management API: PM/API and Open API

DiskReads FLOAT, NULLABLE

8 The total number of physical disk reads per node or AMP during the sample period. For node-level displays, this value is computed from ResUsageSpma table data as:

MemTextPageReads + MemCtxtPageReads + MemSwapReads + FileAcqReads

Note: You can determine node-level DiskReads by summing the vproc level values across all vprocs on a given node with the MemTextPageReads value for that node.

For vproc-level displays, this value is computed from the ResUsageSvpr table data as:

MemCtxtPageReads + MemSwapReads + FilePCiAcqReads + FilePDbAcqReads + FileSCiAcqReads + FileSDbAcqReads + FileTJtAcqReads + FileAPtAcqReads

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Field Name Data TypeLength (Bytes) Description

Page 97: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

Workload Management API: PM/API and Open API 97

DiskWrites FLOAT, NULLABLE

3 The total number of physical disk writes per node or AMP during the sample period. For node-level displays, this value is computed from ResUsageSpma table data as:

MemCtxtPageWrites + FileWrites

Note: For the total number of node-level DiskWrites, add all the vproc values across all AMPs on a given node.

For vproc-level displays, this value is computed from ResUsageSvpr table data as:

MemCtxtPageWrites + FilePCiFWrites + FilePDbFWrites + FileSCiFWrites + FileSDbFWrites + FileTJtFWrites + FileAPtFWrites + FilePCiDyAWrites + FilePDbDyAWrites + FileSCiDyAWrites + FileSDbDyAWrites + FileTJtDyAFWrites + FileAPtDyAWrites

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made during the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

DiskOutReqAvg FLOAT, NULLABLE

8 The average number of outstanding disk requests.

For node-level displays, this value is computed from ResUsageSldv table data as follows, assuming n is the number of ldv controllers used by this node:

(LdvOutReqSum 1 + ... + LdvOutReqSum n) / collectintervals

For vproc-level displays, this value is computed from ResUsageSvdsk table data, assuming n is the number of storage devices used by this vproc:

(ReadRespTot 1 + WriteRespTot 1 + ... + ReadRespTot n + WriteRespTot n) / SampleSec

Field Name Data TypeLength (Bytes) Description

Page 98: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

98 Workload Management API: PM/API and Open API

This value is NULL if:

• Nodes, AMPs, or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For Nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

HostBlockReads FLOAT, NULLABLE

8 The number of message blocks (one or more messages sent in one physical group) received from all clients. For node-level displays, this value is computed from ResUsageShst data, assuming n is the number of vprocs on this node:

HostBlockReads1 + ... + HostBlockReadsn

For vproc-level displays, this value corresponds to the column totals in the DBC.ResUsage.Shst table supplying HostBlockReads for this vproc.

This value is NULL for:

• Down or offline nodes or PEs.

• AMPs.

• A request for data that is made before completion of the first sample period following a system outage.

• Nodes, a request for data that is made before the completion of the first sample period following a change in the ResMonitor rate.

• PEs. A request for data that is made before the completion of the first sample period following a change in the VProcMonitor rate.

Field Name Data TypeLength (Bytes) Description

Page 99: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

Workload Management API: PM/API and Open API 99

HostBlockWrites FLOAT, NULLABLE

8 The number of message blocks (that is, one or more messages sent in one physical group) sent to all hosts. For node displays, this value is computed from ResUsageShst data, assuming n is the number of PEs on this node:

HostBlockWrites1 + ... + HostBlockWritesn

For PE display, this value corresponds to the column totals in the DBC.ResUsageShst table with the same names.

This value is NULL if:

• Nodes or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For PEs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

SwapReads FLOAT, NULLABLE

8 The number of pages/segments read into node memory from the disk during the sample period after a prior write/drop. This value is computed from the ResUsageSpma table data as:

MemSwapReads + MemCtxtPageReads + MemTextPageReads

This value is NULL if:

• Nodes are down or offline.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

SwapWrites FLOAT, NULLABLE

8 The number of pages/segments written to swap area from node memory during the sample period. This value is computed from the ResUsageSpma table data as:

MemCtxtPageWrites

This value is NULL if:

• Nodes are down or offline.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Field Name Data TypeLength (Bytes) Description

Page 100: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

100 Workload Management API: PM/API and Open API

SwapDrops FLOAT, NULLABLE

8 The number of pages/segments dropped from node memory during the sample period due to swapping. This value is computed from the ResUsageSpma table data as:

MemSwapDrops + MemTextPageDrops

This value is NULL if:

• Nodes are down or offline.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

MemAllocates FLOAT, NULLABLE

8 The number of segments allocated to memory resources. This value corresponds to the ResUsageSpma and ResUsageSvpr table columns with the same name.

This value is NULL if:

• Nodes, AMPs, or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

MemAllocateKB, MemAllocates, MemFailures, and MemAgings together indicate if memory resources are taxed, and may assist in determining if more memory is needed.

Field Name Data TypeLength (Bytes) Description

Page 101: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

Workload Management API: PM/API and Open API 101

MemAllocateKB FLOAT, NULLABLE

8 The number of KB allocated to memory resources. For node-level displays, the value is computed from the ResUsageSpma table data as:

(fixed_pg_size * MemTextAllocs) + MemVprAllocKB

Note: You can determine the node-level value, MemVprAllocKB, by summing vproc-level values across all vprocs on a given node.

For vproc-level displays the value is computed from the ResUsageSvpr table data as:

fixed_pg_size * (MemCtxtAllocs + MemPDbAllocKB + MemPCiAllocKB + ... + MemAPtAllocKB)

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs and PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

For vproc-level displays, this value is computed from the ResUsageSvpr table data as:

MemCtxtAllocs + MemPDbAllocs + MemPCiAllocs + MemSDbAllocs + MemSCiAllocs + MemTJtAllocs + MemAPtAllocs

Field Name Data TypeLength (Bytes) Description

Page 102: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

102 Workload Management API: PM/API and Open API

MemFailures FLOAT, NULLABLE

8 The number of failed segment allocation attempts.

A request retries until memory is allocated. Thus, a single request can fail several times. As a result, if this value is large for a single sampling interval, it is no cause for concern. On the other hand, if the value is large over several sampling intervals, there may be a memory resource problem. MemAllocateKB, MemAllocates, MemFailures, and MemAgings together indicate whether memory resources are taxed, and may help to determine if more memory is needed.

This value is NULL if:

• Nodes are down or offline.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

MemAgings FLOAT, NULLABLE

8 The number of memory agings and collections done on old segments (per second per PE or AMP). This value corresponds to the ResUsageSpma table column with the same name.

MemAllocateKB, MemAllocates, MemFailures, and MemAgings together indicate if memory resources are taxed, and may assist in determining if more memory is needed.

Teradata Database manages the use of memory segments on a Least Recently Used (LRU) basis, where counters are assigned to each segment allocated. The counters are decremented for each aging cycle until the value reaches zero, whereupon the segment is collected (written to disk). If a segment is reused before the counter reaches zero, the counter is reset to its initial value.

This value is NULL if:

• Nodes are down or offline.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Field Name Data TypeLength (Bytes) Description

Page 103: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

Workload Management API: PM/API and Open API 103

NetReads FLOAT, NULLABLE

8 The number of Reads from the BYNET to the node or vproc during the sample period. For node-level displays, this value is computed from the ResUsageSpma table data as:

Netrxcircbrd + Netrxcircptp

For vproc-level displays, the value is computed from the ResUsageSvpr table data as:

NetBrdReads + NetPtPReads

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

NetWrites FLOAT, NULLABLE

8 The number of messages written from the node, AMP, or PE to the BYNET during the sample period. For node-level displays, the value is computed from the ResUsageSpma table data as:

Nettxcircbrd + Nettxcircptp

For vproc-level displays, the value is computed from the ResUsageSvpr table data as:

NetBrdWrites + NetPtPWrites

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

NVMemAgings FLOAT, NULLABLE

8 This field is obsolete.

NVMemAllocate FLOAT, NULLABLE

8 This field is obsolete.

Field Name Data TypeLength (Bytes) Description

Page 104: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

104 Workload Management API: PM/API and Open API

Sample Input

The following example shows how the parcels built by CLIv2 for a MONITOR PHYSICAL RESOURCE request look when sent to Teradata Database.

Note: In this example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

This request might return the following values in character text format (a record for each node). Your application program may display returned values in a different format.

Note: Pay attention to SampleSec when interpreting the results of this request.

Success parcel:StatementNo: 1 ActivityCount: 1ActivityType: 96 FieldCount: 3

DataInfo parcel:FieldCount: 3Parcel flavor: 10 Parcel body length: 5

Record parcel.NetAUp = 'U', NetBUp = 'U', SampleSec = 10.

EndStatement.Success parcel:StatementNo: 2 ActivityCount: 2ActivityType: 96 FieldCount: 29

DataInfo parcel:FieldCount: 29

Record parcel.Parcel flavor: 10 Parcel body length: 211NodeId = 736, AMPCount = 8, PECount = 2, CPUUse = 0.9%, PctKernel = 0.0%,PctService = 0.9%, PctUser = 0.0%, Status = 'U', NetAUse = 0.0%,NetBUse = 0.0%, DiskUse = 0.0%, CICUse = 0.0%, DiskReads = 0.0,DiskWrites = 0.0, DiskOutReqAvg = 0.0, HostBlockReads = 0.0,HostBlockWrites = 0.0, SwapReads = 0.0, SwapWrites = 0.0, SwapDrops = 0.0,MemAllocates = 0.0, MemAllocateKB = 0.0, MemFailures = 0.0,MemAgings = 0.0, NetReads = 0.0, NetWrites = 0.0, NVMemAgings = <null>,

NVMemAllocSegs FLOAT, NULLABLE

8 This field is obsolete.

Field Name Data TypeLength (Bytes) Description

Flavor Length Body

Num Name Bytes Field Value

0001 Req 20 Request MONITOR PHYSICAL RESOURCE

0003 Data 6 MonVerID 2

0004 Resp 6 BufferSize 32731

Page 105: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

Workload Management API: PM/API and Open API 105

NVMemAllocate = <null>, NVMemAllocSegs = <null>,Record parcel.Parcel flavor: 10 Parcel body length: 211NodeId = 746, AMPCount = 8, PECount = 2, CPUUse = 0.7%, PctKernel = 0.0%,PctService = 0.7%, PctUser = 0.0%, Status = 'U', NetAUse = 0.0%,NetBUse = 0.0%, DiskUse = 0.0%, CICUse = 0.0%, DiskReads = 0.0,DiskWrites = 0.0, DiskOutReqAvg = 0.0, HostBlockReads = 0.0,HostBlockWrites = 0.0, SwapReads = 0.0, SwapWrites = 0.0, SwapDrops = 0.0,MemAllocates = 0.0, MemAllocateKB = 0.0, MemFailures = 0.0,MemAgings = 0.0, NetReads = 0.0, NetWrites = 0.0, NVMemAgings = <null>,NVMemAllocate = <null>, NVMemAllocSegs = <null>,

EndStatement.EndRequest.

Warning and Error Messages

The following table describes the error messages that may be returned by the MONITOR PHYSICAL RESOURCE request.

For a discussion of common warning messages that may appear in response to MONITOR PHYSICAL RESOURCE and other requests, see “Common Warning and Error Messages” on page 50.

Message Number Description

3271 Data Unavailable: Resource Usage Sampling is not currently enabled.

Remedy: Set the ResMonitor Rate to a valid non-zero value, wait for at least one collection period to expire, and resubmit this request.

3272 Warning: Resource Data is incomplete for one of the following reasons:

• The system has gone through recovery and a full collection period has not expired since.

• The Resource Monitor Rate has been changed and a full collection period has not expired since.

• For the MONITOR SUMMARY request only, Resource Monitoring is not enabled.

Remedy: Wait for a full collection period to expire and resubmit the request, or in the case of a MONITOR SUMMARY request when the Resource Monitoring is not enabled, set the Resource Monitor Rate to a valid non-zero value, wait for a full collection period to expire, and resubmit the request.

3273 Warning: Resource Monitoring rate has been altered.

Remedy: This warning is informational only.

3289 Invalid Rate: The Logging Sample Rate must be an integral multiple of the Monitoring Sample Rate.

Remedy: Select an acceptable rate that fits the criterion and resubmit the request.

3290 The VIRTUAL CHANGE option must have a value of Y, y, N, n, BLANK, or NULL.

Remedy: Correct the error and resubmit the request.

Page 106: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

106 Workload Management API: PM/API and Open API

For more detailed information on warning and error messages, see Messages.

Relationship Between MONITOR PHYSICAL RESOURCE andABORT SESSION

For information on this PMPC CLIv2 interface relationship, see “Relationship Between ABORT SESSION and MONITOR PHYSICAL RESOURCE” on page 65.

Relationship Between MONITOR PHYSICAL RESOURCE andSET RESOURCE RATE

You must execute the SET RESOURCE RATE request to activate vproc resource data collection before you execute a MONITOR VIRTUAL RESOURCE or MONITOR PHYSICAL RESOURCE request. This means that you must set the resource monitoring rate (VProcMonitor) to nonzero. If the VProcMonitor rate is zero, you will receive the error message:

Data unavailable: No vproc resource usage sampling currently active.

A change in the resource collection rate by User A, for example, may affect the data reported by MONITOR VIRTUAL RESOURCE or MONITOR PHYSICAL RESOURCE request made by User B. If the resource monitoring rate has been altered, User B receives the following warning message upon executing a subsequent MONITOR VIRTUAL RESOURCE or MONITOR PHYSICAL RESOURCE request:

Warning: Resource monitoring rate has been altered.

Relationship Between MONITOR PHYSICAL SUMMARY andSET RESOURCE RATE

The SET RESOURCE RATE request sets the VProcMonitor and VProcLogging rates, which are among the responses returned by the MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY request. Any change to either the VProcMonitor or VProcLogging rate results in changes in the corresponding response returned by the MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY request.

You must set VProcMonitor to a nonzero rate for MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY to return meaningful vproc utilization data. A zero VProcMonitor rate returns NULL values for vproc utilization information.

Relationship Between MONITOR PHYSICAL SUMMARY andSET SESSION RATE

Changes to the session-level rates (system and local) specified by SET SESSION RATE are reported in the data returned by MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY.

Note: The local rate reported is your own local rate. If the local rate is not set, the local rate is reported as zero.

Page 107: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL RESOURCE

Workload Management API: PM/API and Open API 107

As more session-level monitoring is done (by setting a faster SET SESSION RATE), the resulting overhead may increase the level of CPU usage (reported in MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY data) by your system. However, this may depend on the size of the rate change and the type of work done by other sessions.

Page 108: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL SUMMARY

108 Workload Management API: PM/API and Open API

MONITOR PHYSICAL SUMMARY

PurposeCollects global summary information that includes the following types of information:

• CPU usage: average by processor type (online only)

• Disk usage: average, high, and low, by processor ID

• BYNET usage: total, up/down

• Rate information: resource logging rate and resource usage monitoring rate

• Current software release and version numbers

Input Data

Monitor Privileges

Unless monitor privileges have been established as part of the default role for the user, users must set a session role before exercising any of the monitor privileges for that role. If the current role is a specified non-NULL role, the user may be able to utilize monitor privileges via the current role or its nested roles. If the current role is ALL, the user may be able to use monitor privileges via any roles directly and indirectly granted. For more information, see Database Administration and Security Administration.

Usage Notes

A user must have any one of the following MONITOR privileges to execute the MONITOR PHYSICAL SUMMARY request:

Element Data TypeLength (Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Page 109: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL SUMMARY

Workload Management API: PM/API and Open API 109

• ABORTSESSION

• MONRESOURCE

• MONSESSION

• SETRESRATE

• SETSESSRATE

You must set the ResMonitor rate (rate at which node resource usage data is updated within memory) to a nonzero value to allow the MONITOR PHYSICAL SUMMARY request to return meaningful data. If you set the ResMonitor rate to zero, then NULL values are returned for all processor usage data.

Caution: After a system outage or a change in the ResMonitor rate, do not request data again until after the completion of the first sample period requested after the crash or change in rate. Otherwise, the data returned contains NULL values and may not be fully representative. After a crash, the in-memory counters are reset, and typically the contents of the counters are not well defined until a full sample period has elapsed. For example, if you were logged on prior to the system outage and you issue your first MONITOR PHYSICAL SUMMARY request after the outage, you receive a warning that the Teradata Database system has been restarted.

Parcels

The response returned from the Teradata Database resembles a summary of the type of response returned by a MONITOR PHYSICAL RESOURCE request. The response is one row of 22 fields. The response returned from Teradata Database contains the following sequence of parcel types.

For more information on parcel body fields, see the appropriate chapter in Teradata Call-Level Interface Version 2 Reference for Channel-Attached Systems or Teradata Call-Level Interface Version 2 Reference for Network-Attached Systems.

Parcel Sequence

Parcel Flavor

Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = 1

ActivityType = 94 (PCLMONPSUMMARY)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This contains the Data or IndicData physical summary information.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Page 110: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL SUMMARY

110 Workload Management API: PM/API and Open API

The following table describes the resource usage information returned from the Record parcel for the MONITOR PHYSICAL SUMMARY response.

Field Name Data TypeLength(Bytes) Description

AvgCPU FLOAT, NULLABLE

8 The average % CPU usage (CPUUse) time of all online nodes currently in the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate (the rate at which resource data is updated within memory) is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

AvgDisk FLOAT, NULLABLE

8 The average % disk usage (from DiskUse) of all online nodes currently in the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

AvgDiskIO FLOAT, NULLABLE

8 The average number DiskReads and DiskWrites for all online nodes currently in the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period that following either a system outage or a change in the ResMonitor rate.

HighCPUUse INTEGER, NULLABLE

4 The vproc ID of the AMP with the next highest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

HighCPUProcId INTEGER, NULLABLE

4 The in-use count associated with the AMP 3 Vproc ID. This is only applicable if AMP 3 is defined.

Page 111: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL SUMMARY

Workload Management API: PM/API and Open API 111

LowCPUUse FLOAT, NULLABLE

8 The lowest CPUUse number associated with any online node that is currently part of the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

LowCPUProcId SMALLINT, NULLABLE

2 The ID of a node with CPPUse equal to the value reported as LowCPUUse.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

HighDisk FLOAT, NULLABLE

8 The highest % disk usage (from DiskUse) associated with any online node that is currently part of the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

HighDiskProcId SMALLINT, NULLABLE

2 The ID of a node with DiskUse equal to the value reported as HighDisk.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Field Name Data TypeLength(Bytes) Description

Page 112: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL SUMMARY

112 Workload Management API: PM/API and Open API

LowDisk FLOAT, NULLABLE

8 The lowest % disk usage (from DiskUse) associated with any online node that is currently part of the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

LowDiskProcId SMALLINT, NULLABLE

2 The ID of a node with DiskUse equal to the value reported as LowDisk.

This value is NULL when LowDisk is NULL.

HighDiskIO FLOAT, NULLABLE

8 The highest DiskReads and DiskWrites number associated with any online node that is currently active in the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

HighDiskIOProcId SMALLINT, NULLABLE

2 The ID of a node with DiskReads and DiskWrites equal to the value reported as HighDiskIO.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

LowDiskIO FLOAT, NULLABLE

8 The lowest DiskReads and DiskWrite number associated with any online node that is currently part of the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Field Name Data TypeLength(Bytes) Description

Page 113: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL SUMMARY

Workload Management API: PM/API and Open API 113

LowDiskIOProcId SMALLINT, NULLABLE

2 The ID of a node with DiskReads and DiskWrites equal to the value reported as LowDiskIO.

This value is NULL when LowDiskIO is NULL.

NetUse FLOAT, NULLABLE

8 The % of total BYNET use; that is, average of the online BYNETs.

If both BYNETs are up, the value is computed from ResUsageSpma table data as:

(NetAUse + NetBUse) / 2

This value is NULL if:

• ResMonitor is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Note: ResUsage data for this field is not currently available. The NetAUse value returned is zero.

NetAUp,NetBUp

CHAR, NULLABLE

1 The status of the BYNETs (if there are more than two, the first two) on a system-wide basis.

The following values apply:

• D = Down/Offline

• U = Up/Online

• S = Standby

Note: The NetBUp value is always zero.

ResLogging SMALLINT, range 0-3600 seconds

2 The frequency at which node resource usage data is written to one or more active ResUsage database tables. The node ResUsage tables are named DBC.ResUsageXyyy, where Xyyy is Spma and Scpu (see Resource Usage Macros and Tables). A rate of zero turns off logging capability.

This rate can be changed with the SET RESOURCE RATE request. When changed, the rate is saved on disk (in the version record).

ResMonitor SMALLINT, range 0-3600 seconds

2 The rate at which node resource usage data is collected within memory for reporting via the PM/API.

This rate can be changed with the SET RESOURCE RATE request. The rate is saved on disk when it is changed.

Field Name Data TypeLength(Bytes) Description

Page 114: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL SUMMARY

114 Workload Management API: PM/API and Open API

Sample Input

The following example shows how the parcels for a MONITOR PHYSICAL SUMMARY request, built by CLIv2, look when sent to Teradata Database.

Note: In this example, the size of the response buffer in the example is set at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

The following example shows the values returned in character text format for the MONITOR PHYSICAL SUMMARY request. Your application program may display returned values in a different format.

Success parcel:StatementNo: 1 ActivityCount: 1ActivityType: 94 FieldCount: 22

DataInfo parcel:FieldCount: 22

Record parcel.Parcel flavor: 10 Parcel body length: 163AvgCPU = 1.4%, AvgDisk = 0.0%, AvgDiskIO = 2.0, HighCPUUse = 2.4%,HighCPUNodeId = 746, LowCPUUse = 0.5%, LowCPUNodeId = 736,HighDisk = 0.0%, HighDiskNodeId = 746, LowDisk = 0.0%,LowDiskNodeId = 736, HighDiskIO = 4.0, HighDiskIONodeId = 746,LowDiskIO = 0.0, LowDiskIONodeId = 736, NetUse = 0.0%, NetAUp = 'U',NetBUp = 'U', ResLogging = 60, ResMonitor = 10,Release = "13.00.00.00",Version = "13.00.00.00".

EndStatement.

Release CHAR 29 The release number of the currently running Teradata Database software (for example, 13.00.00.00).

This value is supplied by Teradata Database.

Version CHAR 32 The version number of the currently running Teradata Database software (for example, 13.00.00.00).

This value is supplied by Teradata Database.

Field Name Data TypeLength(Bytes) Description

Flavor Length Body

Num Name Bytes Field Value

0001 Req 28 Request MONITOR PHYSICAL SUMMARY

0003 Data 6 MonVerID 2

0004 Resp 6 BufferSize 32731

Page 115: Workload management api

Chapter 3: PMPC APIsMONITOR PHYSICAL SUMMARY

Workload Management API: PM/API and Open API 115

EndRequest.

Warning and Error Messages

All users who are logged on and issue a MONITOR PHYSICAL SUMMARY request after a system restart or after the last rate change can expect to receive a warning. Users will also receive a warning if the resource usage sampling rate (ResMonitor) is rate is set to zero.

Either MONITOR PHYSICAL SUMMARY or MONITOR PHYSICAL RESOURCE requests issues a warning for any sessions logged on prior to the database recovery, or prior to the change in the ResMonitor sampling rate.

For a discussion of common warning and error messages that may appear in response to an MONITOR PHYSICAL SUMMARY and other requests, see “Common Warning and Error Messages” on page 50.

For more detailed information on warning and error messages, see Messages.

Relationship Between MONITOR PHYSICAL SUMMARY and MONITOR PHYSICAL CONFIG

For information on this PMPC CLIv2 interface relationship, see “Relationship Between MONITOR PHYSICAL CONFIG and MONITOR PHYSICAL SUMMARY” on page 86.

Page 116: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

116 Workload Management API: PM/API and Open API

MONITOR SESSION

PurposeCollects current status and activity information for one or more logged-on sessions.

Input Data

Note:• If you do not specify host_id, user_name, or session_no, all hosts, all users, or all sessions

are monitored. For example, if you specify 127 for host_id, PEDERSON for user_name, and do not specify session_no, the MONITOR SESSION request reports on all sessions currently logged on from host 127 as user PEDERSON.

• A NULL value in any field, with the exception of mon_ver_id, indicates a match for all potential values of that field. A NULL for mon_ver_id will produce an error response.

Element Data TypeLength (Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

Note: Version 6 or 7 can be used to determine if a utility session is on the Teradata DWM delay queue. For information on returning the utility delay queue, see “TDWMGetDelayedUtilities” on page 370.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

host_id SMALLINT, NULLABLE

2 The logical ID of a host (or client) with sessions logged on. host_id cannot exceed 1023. A host_id of zero identifies the system console ID of the host on which sessions are running.

session_no INTEGER, NULLABLE

4 The session number. The session number combined with the host_id represents a unique session ID.

user_name CHAR, NULLABLE

30 The name of the user or database that is running this session.

Page 117: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 117

Remember that IndicData parcels are used to specify the output fields that are null. For additional information on IndicData, see “Creating a Request” on page 33.

• A value of 3 in the mon_ver_id field provides access to additional, more detailed information on CPU, AMP, and I/O usage for the subject session.

• A value of 4 in the mon_ver_id field provides access to additional request level usage information on the current request.

• A value of 5 (or 6) in the mon_ver_id field provides access to data from Response Parcel Groups I through IV.

Note: A value of 6 or higher is required for Teradata Dynamic Workload Management PM/APIs.

• A value of 7 in the mon_ver_id field provides access to proxy user permission information for the current session.

For more information, see “Response Parcel Groups” on page 123 and “MONITOR

VERSION” on page 156.

Monitor Privileges

Unless monitor privileges have been established as part of the default role for the user, users must set a session role before exercising any of the monitor privileges for that role. If the current role is a specified non-NULL role, the user may be able to utilize monitor privileges via the current role or its nested roles. If the current role is ALL, the user may be able to use monitor privileges via any roles directly and indirectly granted. For more information, see Database Administration and Security Administration.

Usage Notes

Use this information, when a job hangs because of unavailable resources, to find out about the following:

• The user causing a block

• The locked database or table

• System usage data on a session-by-session basis

A user must have MONSESSION privilege to execute the MONITOR SESSION request. In the MONITOR partition, each job is a session. You can execute the MONITOR SESSION request to query:

• All hosts (or clients) with all sessions

• Single host (or client) with all sessions

• Single host (or client) with all sessions for a given user name

• Single host (or client) with a single session and a given user name

MONITOR SESSION requests return data:

• Identical for all sessions

• Specific to a particular session

Page 118: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

118 Workload Management API: PM/API and Open API

MONITOR SESSION requests return accumulated session statistics commencing with the last time that one of the following events impacted a session:

• The time that a session logged on.

• The time that a session-switch changed the vproc with Session Control responsibility for a session.

• The time that a system crash or TPA restart occurred.

• The time that system or local rate was set to a nonzero value.

A MONITOR SESSION request can also be used to track session-level AMP usage and provide data on the three highest and lowest CPU/IO utilized AMPs. This can help identify:

• Skewed data

• Possible hardware problems

• Possible Teradata Database bugs

You can use the data returned by the MONITOR SESSION request as input for the IDENTIFY request to determine lock activity. For more information, see “IDENTIFY” on page 67.

Be aware of the following rules:

• To collect statistics, set the system or local rate to a nonzero value.

• Data on a particular session is only reported for the last complete sample period. For example, assume the sample rate is 600 seconds (or 10 minutes) and that you issue a MONITOR SESSION request at 9:00 a.m. If the user for whom you are seeking data logged onto the system at 9:01 a.m., no session data would be available until the next MONITOR SESSION request is issued at 9:10 a.m. (upon completion of the current sample period). A MONITOR SESSION request made at 9:05 a.m. (after the user logged on at 9:01 a.m.) only reports on sessions that stayed logged on at 9:00 a.m.

• When a session-switch changes the processor with session control responsibility for a session, previous data in memory is lost and the data collection for the affected session starts over again.

• When a system crash occurs, the system crash clears out the previous data and data collection starts over again.

The resource usage data loss affects only specific sessions when a session logs off or a PE goes down, forcing all sessions on that PE to switch to another PE. In other cases, such as a system outage, the data loss affects all sessions.

If a system failure occurs, then the response to subsequent MONITOR SESSION requests contains a warning message. For more information, see Messages.

The MONITOR SESSION request always returns an ActivityCount (one of the fields in the Success parcel indicating total number of records selected, updated, and so forth) equal to 0 or -1.

Page 119: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 119

The following CPU fields in the MONITOR SESSION response are affected by the MonSesCPUNormalization field:

The MonSesCPUNormalization field, a DBS Control General Record field, controls whether normalized or non-normalized statistical CPU data is reported by the MONITOR SESSION request, and by the functions: MonitorMySessions and MonitorSession. For more information about the MonSesCPUNormalization field and CPU normalization, see the DBS Control utility in Utilities.

For a complete description of these fields, see “Response Parcel Groups” on page 123.

You can also refer to “MonitorMySessions” on page 231 or “MonitorSession” on page 262 for a list of these CPU fields.

How Session Data is Collected

After a sampling interval is set to a nonzero rate, session usage data is accumulated in AMP and PE storage areas (regardless of the rate set). When a user makes a MONITOR request, the central coordinator task determines if more current data is necessary. If more current data is required, the central coordinator task directs the processors to transmit data from processor storage areas on the AMPs to the main memory repository on each PE where each PE is simultaneously collecting its own session data. Otherwise, data in the main PE repositories is considered current and is sent to the user.

All current data is associated with an internal timestamp not visible to the user. Every MONITOR SESSION request issued by a user is associated with a session-level data collection rate. This rate is the local rate if a local rate has been set. Otherwise, it is the global rate.

IF ActivityCount is... THEN...

0 no session matched the requested combination of logical HostId, UserName, and SessionNo.

-1 this request generates an unknown number of Response Rows. The application must continue to gather data until it encounters the EndStatement parcel.

A value of -1 is used because ActivityCount cannot be determined when the request is executed. Because the response is collected from data shared by all running Monitor sessions, that data can be updated while a request is in progress. If that update adds or removes information on sessions, the activity count calculated at the beginning of a particular session query response generation does not become valid by the end of the response processing for that session. Rather than return possibly incorrect data, the ActivityCount is set to indicate that the count is unknown.

• AMPCPUSec

• AvgAmpCPUSec

• HotAmp1CPU

• HotAmp2CPU

• HotAmp3CPU

• LowAmp1CPU

• LowAmp2CPU

• LowAmp3CPU

• PECPUSec

• RequestAmpCPU

Page 120: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

120 Workload Management API: PM/API and Open API

When a user executes a MONITOR SESSION request, the central coordinator task checks the age of the current session-level data (current time minus the data timestamp). Depending on the age determination, action is then taken on the data as shown in the table below.

Unreported Session Partitions

Resource usage in some session partitions may not be reported or fully reported. MONITOR SESSION requests do not report statistics on session resources used by the DBCUTIL utility. Although resource usage is reported, not all resource usage data is accounted for. These restrictions may affect the following data returned from a MONITOR SESSION request:

• AMPCPUSec

• AMPIO

• Request_AMPSpool

• AMPState

• PECPUSec

• PEState

• ReqCount

As an example of how the returned data is affected, both AMPState and PEState data values may be UNKNOWN if I/O is done on behalf of the unreported partitions. As another example, in a Teradata SQL session, PECPUSec spent in a PE do not include time spent in Gateway communications processing.

A Down Processor

When a previously active PE is down because of a system outage, the data returned for those sessions logged on to the down processor may not be meaningful. If you encounter a system outage, pay attention to the following information, because the PE data does not change:

IF data in the PE memory repository is... THEN...

considered current (the age of the data is less than or equal to the session collection rate)

this data is returned to the user.

not considered current (the age of the data is greater than the session collection rate)

the coordinator task forces a data update (causing its internal timestamp to be reset to the current time) and returns the updated data to the user.

• HostId

• LogonPENo

• SessionNo

• UserName

• UserAccount

• UserID

• LSN

• LogonTime

• LogonDate

• PartName

• PEState

• LogonSource

Page 121: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 121

Internal Sessions

Internal sessions are a part of the database software and cannot be started or aborted from the client. For example, the operation sending a message from a parser to an AMP is an internal session.

Internal sessions can cause problems because:

• They may be blocking an important session.

• They are hard to recognize.

• They may be blocked by other requests.

Internal sessions that are blocked are reported by MONITOR SESSION. These include:

• Internal sessions associated with the user that show the blocking activity on the user session itself.

• DBQL/Teradata DWM artificial internal sessions that appear in the Monitor Session output and exist only to show blocked DBQL/Teradata DWM internal express requests.

Note: For information on handling blocked DBQL/Teradata DWM internal express requests, see Database Administration.

You must determine what to do about a session that is blocking some important activity.

The following fields (returned by a MONITOR SESSION request) may provide information about internal sessions blocking other sessions:

• Blk_x_HostId

• Blk_x_SessNo

• Blk_x_UserID

Some internal sessions are not easy to recognize simply from the data returned in these Blk_x fields. With an internal session, any or all of the Blk_x fields may be NULL. In this case, you might mistake an internal session with a NULL Blk_x_SessNo for a client utility session. All three fields could be filled in with legitimate looking values. In this case, you can frequently recognize an internal session by a zero value in the Blk_x_HostId field. Still, this is not guaranteed, because a Teradata SQL session started from the system console running DBW has a zero value in the Blk_x_HostId field.

The following matrix provides some guidelines for recognizing internal sessions the HostId, SessNo, and UserID Blk_x fields internal sessions.

For fields: If Values Are: Session Type is:

HostId, SessNo, UserID NULL Internal session

• HostId & SessNo

• UserID

• NULL

• Non-NULL

Idle Client utility

Page 122: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

122 Workload Management API: PM/API and Open API

Parcels

The MONITOR SESSION request is treated internally as a two statement request with each statement generating a response. The two statement response returned from Teradata Database contains the following sequence of parcel types:

HostId, SessNo, UserID Non-NULL Special rule: A MONITOR SESSION request does not return a record for an internal session. If you specify internal session in an IDENTIFY request to specify the name of the session causing the lock, the session returns the error message No such session currently logged on.

If... Then...

an internal session is blocking an important session

you cannot abort the internal session.

the internal session lock request is waiting you can abort the work of the sessions that are blocking the internal sessions.

the internal session lock request is granted you must wait for it to complete.

For fields: If Values Are: Session Type is:

Parcel Sequence

Parcel Flavor

Length(Bytes) Comments and Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = 1

ActivityType = 84 (PCLMONSESS)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 5 to 32004 (record mode)

6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This is the first record returned. It contains the sessions sample time in seconds.

EndStatement 11 6 StatementNo = 2-byte integer

Success 8 18 to 273 StatementNo = 2

ActivityCount = -1 or 0

ActivityType = 84 (PCLMONSESS)

Page 123: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 123

The response to the first statement results in a Record parcel containing the

SampleSec field SampleSec is the duration of the sample period, in seconds. This value represents the session-level collection rate, if set. If the session rate is not set, the system-level collection rate is returned. The first rate is equivalent to SesMonitorLoc while the second rate is equivalent to SesMonitorSys. It is a SMALLINT data type and has a length of 2 bytes.

The response to the second statement results in multiple Record parcels that consist of a record for each session in the system. Records are sorted in order of LogonPENo, HostId, and SessionNo.

Response Parcel Groups

There are five groups of response parcel fields returned by the MONITOR SESSION request. The following table shows the different values returned from the mon_ver_id.

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 5 to 32004 (record mode)

6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This is the second record returned. It contains data describing the session. See the following description for details.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Parcel Sequence

Parcel Flavor

Length(Bytes) Comments and Key Parcel Body Fields

mon_ver_ID EntryResponse Parcel Group Returned Description

2 Group I Returns data fields concerned primarily with session-level user status.

3 Groups I and II In addition, returns data fields on session-specific AMP resource usage.

4 Groups I-III In addition, returns request level usage information.

5 Groups I-IV Returns data fields concerned with Group I through IV

6 Groups I-IV Returns data fields concerned with Group I through IV.

Note: This value is required for Teradata Dynamic Workload Management PM/APIs.

7 Groups I-V In addition, returns the name of the proxy user if this session has a proxy connection.

Page 124: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

124 Workload Management API: PM/API and Open API

Group I Data Fields

The Record parcel returns the following Group I data values.

Field Name Data TypeLength (Bytes) Description

HostId SMALLINT, NULLABLE

2 The logical host ID associated with a PE or session. For a PE, the Host ID identifies one of the hosts or LANs associated with the described PE. For a session, the combination of a Host ID and a session number uniquely identifies a user session on the system.

Note: This value is NULL for AMPs. A value of zero represents the Supervisor window.

LogonPENo SMALLINT 2 The vproc number of the PE the session is currently logged on to; it identifies the PE that has control responsibility for the session. Normally, this is the PE that processed the logon request; but if that PE goes offline, it will be the PE to which the session was switched.

RunVprocNo SMALLINT, NULLABLE

2 Vproc number of the AMP or PE currently assigned to process the session requests.

For sessions in Teradata SQL partitions, this value is identical to the LogonPENo. For sessions in FastLoad or MultiLoad partitions, this is the AMP that initially processes the data being loaded. For HUTPARSE or HUTCTL (Archive/Restore) sessions, this value is NULL.

If a RunVprocNo value of -1 in record mode or NULL in indicator mode is returned by MONITOR SESSION for FastLoad, MultiLoad or FastExport sessions, this indicates that the session is in the process of starting up.

SessionNo INTEGER 4 The number of the current session. Together with a given host ID, a session number uniquely identifies a session on the Teradata Database system. This value is assigned by the host (or client) at logon time.

UserName VARCHAR 30 The user name of the session. This is the name specified when the user is created; it is used to log on to a session. Within Teradata Database, user name is almost equivalent to database name.

Page 125: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 125

UserAccount CHAR 30 The account currently with which the user is logged on. When a user is created or altered, that user is allowed to run in association with one or more accounts. During the logon process, a particular user session establishes its priority and charges resource usage to one of the allowed accounts.

UserID INTEGER 4 The user or internal ID of a user for this session. Within the Teradata Database, UserID is equivalent to Database ID. Typically, UserID is used when the associated record is known to be a user name, and Database ID is used when the associated record is known to be a database. However, UserID can identify either a given user or database name.

LSN INTEGER 4 The Logon Sequence Number (LSN) that is associated with a session when the session logs on. It identifies a collection of sessions performing a related activity. For example, in a FastLoad job, a user is logged on as a Teradata SQL session, as well as n FastLoad sessions with the same user name. Therefore, n+1 sessions (1 Teradata SQL and n FastLoad) with the same LSN are all associated with the given FastLoad job. To see how the FastLoad job is doing, the user can pick out all sessions reported with the same LSN number.

Note: This information supplies the parent-child relationship for sessions involved with FastLoad, MultiLoad, and Archive and Recovery jobs.

LogonTime FLOAT 8 Time portion of the information recorded by Session Control when a session successfully logs on. Together with LogonDate, it indicates when the session logged on to the system. It is usually formatted for display as 99:99:99, which represents hours: minutes: seconds.

LogonDate DATE 4 The date portion of the information recorded by Session Control when a session successfully logs on. Together with LogonTime, it indicates when the session logged on to the system.

Field Name Data TypeLength (Bytes) Description

Page 126: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

126 Workload Management API: PM/API and Open API

PartName CHAR 16 The name of the session partition associated with this session. Following a successful logon request by a session or as part of a connect request, the session identifies the partition with which the user wants the session to be associated. FASTLOAD, Teradata SQL, MONITOR, INTERNAL are examples of valid partition names.

Reserved2 CHAR 2 This field is not currently used.

PEState CHAR 18 The current state of the session within the PE. This session describes PARSING, DISPATCHING, and Monitor activity. The session states are reported in decreasing priority:

• DELAYED: The request is either waiting on a queue table for rows to be inserted in to that table or, because of a Teradata Dynamic Workload Management throttle rule, the request is on the Teradata Dynamic Workload Management delay queue.

• HOST-RESTART: A restart is in progress for the associated host (or client).

• ABORTING: The transaction is being rolled back; the session is aborting.

• PARSING-WAIT: Waiting for information from the Data Dictionary.

• PARSING: The Parser portion of the PE is processing a request.

• ELICIT CLIENT DATA: The Dispatcher is eliciting data from the client and sending it to the AMP.

• DISPATCHING: The Dispatcher or Monitor is having a request executed.

• BLOCKED: Some background activity is in progress and the last request is on hold until this background activity is completed.

• ACTIVE: Normal, on-going activity is being done by this session.

• RESPONSE: The Dispatcher is returning query responses to the session.

Field Name Data TypeLength (Bytes) Description

Page 127: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 127

• IDLE: IN-DOUBT: A session using Two-Phase Commit (2PC) is currently IN-DOUBT.

• IDLE : No work in progress for this session.

• QTDELAYED: A session is delayed due to a Queue Table restriction.

• SESDELAYED: A utility session is on the Teradata DWM delay queue.

• UNKNOWN: The Parser, Dispatcher, and Monitor on the PE are unaware of this session.

This value is NULL when a request for data is made before completion of the first sample period that follows either a system outage or a change in the ResMonitor rate.

PECPUsec FLOAT, NULLABLE

8 The CPU time, in seconds, used in a PE by the associated session for parsing and dispatching requests. It is accurate to the second.

This value is valid only when associated with Teradata SQL and MONITOR partition sessions. The value is NULL when it is returned for all other sessions.

XActCount FLOAT, NULLABLE

8 The number of explicit and implicit transactions executed by the session. This value is valid only when returned for Teradata SQL sessions, and is NULL for all other partition sessions. For this value, you must make a request for data before completion of the first sample period that follows either a system outage or a change in the VProcMonitor rate.

ReqCount FLOAT, NULLABLE

8 The number of requests (Tequel Start Request [TSR] messages) initiated by the session.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or change in the VProcMonitor rate.

Field Name Data TypeLength (Bytes) Description

Page 128: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

128 Workload Management API: PM/API and Open API

ReqCacheHits FLOAT, NULLABLE

8 The number of times that this session processed a request using information from the Teradata SQL Parser request cache, specifically, how many times there was a request cache hit.

This value is valid only for Teradata SQL sessions, and is NULL for all other partition sessions. This value is also NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

AMPState CHAR, NULLABLE

18 The current state of the associated session in AMP vprocs in decreasing priority:

• ABORTING: The transaction is being rolled back; session is aborting.

• BLOCKED: Some background activity is in progress and the last request is on hold until this background activity is completed.

• ACTIVE: Normal, on-going activity is being done by this session.

• IDLE: No work in progress for this session on any AMP.

• UNKNOWN: No recorded activity by this session since monitoring began.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

AMPCPUSec FLOAT, NULLABLE

8 The current elapsed CPU time, in seconds, used on all AMPs by the associated session for executing requests. For example, for Teradata SQL requests, this is the time spent by the Teradata Database actively working or rolling back an aborted transaction. This does not include any UNIX/PDE CPU time spent handling Teradata Database requests. This value is accurate to the second.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Field Name Data TypeLength (Bytes) Description

Page 129: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 129

AMPIO FLOAT,NULLABLE

8 The current number of logical Reads and Writes issued across all AMPs by the associated session.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Request_AmpSpool FLOAT, NULLABLE

8 The current spool used by current request across all AMPs, expressed as a number of bytes.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Blk_1_HostId,

Blk_2_HostId,

Blk_3_HostId

SMALLINT, NULLABLE

2 The logical host ID of a session causing a block. This value is derived from equating the transactions causing a Teradata Database lock conflict to the sessions that issued those transactions. The Blk_x_HostId in combination with Blk_x_SessNo uniquely identifies the session that is causing a block.

A valid value is not returned if an inactive Archive/Recovery job is causing the lock conflict, because no session is logged in.

This value is NULL if:

• The host ID is not available.

• The session does not have an AMPState of BLOCKED.

If the Blk_x_HostId, Blk_x_SessNo, and Blk_x_UserID values all return as NULLs and AMPState is BLOCKED, a Host Utility (HUT) lock left over after the session holding the lock was aborted or logged off. The lock was never released, and no blocking information is available because the session no longer exists.

Use the Show Locks utility to obtain the user name that placed the HUT lock. For more information, see Utilities.

Field Name Data TypeLength (Bytes) Description

Page 130: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

130 Workload Management API: PM/API and Open API

Blk_1_SessNo,

Blk_2_SessNo,

Blk_3_SessNo

INTEGER, NULLABLE

4 The number of the session causing a block. This value is derived from associating the transactions causing a lock conflict to the sessions that issued those transactions. The Blk_x_SessNo in combination with Blk_x_HostId uniquely identifies the session causing a block.

This information is unavailable if an inactive Archive/Recovery job is causing the lock conflict.

This value is NULL if:

• SessNo is not available.

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

If the Blk_x_HostId, Blk_x_SessNo, and Blk_x_UserID values all return as NULLs and AMPState is BLOCKED, a host utility lock left over after the session holding the lock was aborted or logged off. The lock was never released, and no blocking information is available because the session no longer exists.

Use the Show Locks utility to obtain the user name that placed the HUT lock. For more information, see Utilities.

Blk_1_UserID,

Blk_2_UserID,

Blk_3_UserID

INTEGER, NULLABLE

4 The ID of the user or host utility job preventing the session from being granted a lock. This information is especially important when an Archive/Recovery job is holding the lock, because the user ID is the only information available about who placed the lock.

This value is NULL if:

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Field Name Data TypeLength (Bytes) Description

Page 131: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 131

If the Blk_x_HostId, Blk_x_SessNo, and Blk_x_UserID values all return as NULLs and AMPState is BLOCKED, a host utility lock left over after the session holding the lock was aborted or logged off. The lock was never released, and no blocking information is available because the session no longer exists.

Use the Show Locks utility to obtain the user name that placed the HUT lock. For more information, see Utilities.

Blk_1_LMode,

Blk_2_LMode,

Blk_3_LMode

CHAR, NULLABLE

1 The mode (severity) of the lock involved in causing a block.

The following values apply:

• E = Exclusive

• W = Write

• R = Read

• A = Access

Locks are reported in decreasing order of severity because removing the most severe lock conflict may eliminate the source of the lock conflict.

This value is NULL if:

• The session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

A session may be blocked by either a granted lock or an ungranted lock that precedes the blocked lock in the queue and is in conflict with the lock requested by this blocked session. For information on whether the lock is granted, see the MONITOR SESSSION fields: Blk_1_Status, Blk_2_Status, and Blk_3_Status.

Field Name Data TypeLength (Bytes) Description

Page 132: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

132 Workload Management API: PM/API and Open API

Blk_1_OType,

Blk_2_OType,

Blk_3_OType

INTEGER,NULLABLE

1 The type of object whose lock is causing the session described by the associated row to be blocked:

• D = Database

• T= Table

• R = Row hash

However, this object is not necessarily the type of object the blocked session is trying to access. For example, if the session is requesting a row hash lock, the blocking object could be a database, table, or row hash.

This value is NULL if:

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

For a Table T, it is possible for User A to block User B with a table level lock on Table T on AMP_1 and with a Row Hash Level lock on that same Table T on AMP_2. When that occurs, the only lock conflict reported is that User B is blocked by User A on a table.

Blk_1_ObjDBId,

Blk_2_ObjDBId,

Blk_3_ObjDBId

INTEGER, NULLABLE

4 The unique ID of the database object over which a lock conflict is preventing the session from being granted a lock.

Within the Teradata Database system, Database ID is equivalent to User ID. Typically, User ID is used when the associated record is known to be a user name, and Database ID is used when the associated record is known to be a database. However, Database ID can identify either a user or database name.

This value is NULL if:

• The session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Field Name Data TypeLength (Bytes) Description

Page 133: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 133

Blk_1_ObjTId,

Blk_2_ObjTId,

Blk_3_ObjTId

INTEGER, NULLABLE

4 The unique ID of the table object over which a lock conflict is preventing the session from being granted a lock.

This value is NULL if:

• The session does not have an AMPState of BLOCKED.

• The Blk_x_OType is D.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Blk_1_Status,

Blk_2_Status,

Blk_3_Status

CHAR, NULLABLE

1 The status of lock causing a block:

• W= Waiting

• G = Granted

This value is NULL if:

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Note: A lock request may be blocked by either a granted lock or an ungranted lock that precedes the blocked lock request in the queue and is in conflict with it.

A status of Waiting has a higher priority than that of Granted when there is more than one lock involved. For example, for a given object and a given session, a session that is blocked by a Waiting lock on one AMP and a Granted lock on another AMP has Waiting reported as its status.

MoreBlockers CHAR, NULLABLE

1 An indicator of more lock conflicts:

• Blank = Blk_x information is a complete list of sessions blocking the session described.

• Asterisk (*) = additional sessions are blocking the session described. The Blk_x information shows only three blocking sessions.

Field Name Data TypeLength (Bytes) Description

Page 134: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

134 Workload Management API: PM/API and Open API

Group II Data Fields

The Record parcel returns the following Group II data values.

This value is NULL if:

• The state of the session is not BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

LogonSource VARCHAR, NULLABLE

2,128 The logon source information. At logon time, this information is optionally supplied by the Teradata Director Program or the LAN Gateway to further identify the physical or logical location of the session, the logon user name, and the interface under which the session was initiated. (For example, the data string may include DBC as the user ID and BTEQ as the interface.)

Data strings for TCP/IP sessions are inserted by CLIv2, which truncates strings that exceed 128 bytes.

Note: A two-byte value precedes the LogonSource data to indicate the length of the string. The length value is zero if LogonSource is NULL.

For a list of the commonly seen LogonSource string application names, see SQL Data Definition Language.

TempSpace FLOAT, NULLABLE

8 The total amount, in bytes, of temporary space used by the session.

This value is NULL if the session did not materialize any temporary tables.

Field Name Data TypeLength(Bytes) Description

HotAmp1CPU FLOAT, NULLABLE

8 The CPU time of the highest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

Field Name Data TypeLength (Bytes) Description

Page 135: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 135

HotAmp2CPU FLOAT, NULLABLE

8 The CPU time of the second highest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp3CPU FLOAT, NULLABLE

8 The CPU time of the third highest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

HotAmp1IO FLOAT, NULLABLE

8 The IO count of the highest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp2IO FLOAT, NULLABLE

8 The IO count of the second highest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp3IO FLOAT, NULLABLE

8 The IO count of the third highest IO utilized AMP for the last collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs in the system.

HotAmp1CPUId SMALLINT, NULLABLE

2 The vproc ID of the highest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp2CPUId SMALLINT, NULLABLE

2 The vproc ID of the second highest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp3CPUId SMALLINT, NULLABLE

2 The vproc ID of the third highest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs in the system.

HotAmp1IOId SMALLINT, NULLABLE

2 The vproc ID of the highest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

Field Name Data TypeLength(Bytes) Description

Page 136: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

136 Workload Management API: PM/API and Open API

HotAmp2IOId SMALLINT, NULLABLE

2 The vproc ID of the second highest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp3IOId SMALLINT, NULLABLE

2 The vproc ID of the third highest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs in the system.

LowAmp1CPU FLOAT, NULLABLE

8 The CPU time of the lowest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp2CPU FLOAT, NULLABLE

8 The CPU time of the second lowest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp3CPU FLOAT, NULLABLE

8 The CPU time of the third lowest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

LowAmp1IO FLOAT, NULLABLE

8 The IO count of the lowest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp2IO FLOAT, NULLABLE

8 The IO count of the second lowest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp3IO FLOAT, NULLABLE

8 The IO count of the third lowest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

LowAmp1CPUId SMALLINT, NULLABLE

2 The vproc ID of the lowest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

Field Name Data TypeLength(Bytes) Description

Page 137: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 137

LowAmp2CPUId SMALLINT, NULLABLE

2 The vproc ID of the second lowest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp3CPUId SMALLINT, NULLABLE

2 The vproc ID of the third lowest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

LowAmp1IOId SMALLINT, NULLABLE

2 The vproc ID of the lowest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp2IOId SMALLINT, NULLABLE

2 The vproc ID of the second lowest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp3IOId SMALLINT, NULLABLE

2 The vproc ID of the third lowest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

UpAMPCount SMALLINT, NULLABLE

2 The total number of AMPs participating for this session during the last session collection interval.

This value is NULL if the request is made before the sample period expires.

AvgAmpCPUSec FLOAT, NULLABLE

8 The average AMP CPU utilization for the last session collection interval. The average is calculated as the sum of CPU utilization for all amps participating divided by the number of online AMPs.

This value is NULL if the request is made before the sample period expires.

AvgAmpIOCnt FLOAT, NULLABLE

8 The average AMP IO utilization for the last session collection interval. The average is calculated as the sum of IO utilization for all AMPs participating divided by the number of online AMPs.

This value is NULL if the request is made before the sample period expires.

Field Name Data TypeLength(Bytes) Description

Page 138: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

138 Workload Management API: PM/API and Open API

Group III Data Fields

The Record parcel returns the following Group III data values.

Group IV Data Fields

The Record parcel returns the following Group IV data values.

Field Name Data TypeLength(Bytes) Description

RequestStartTime FLOAT, NULLABLE

8 The time of the current request on the session started.

RequestStartDate DATE, NULLABLE

4 The date of the current request on the session started.

RequestAmpCPU FLOAT,NULLABLE

8 The total CPU usage by the current SQL request on the session on all AMPs. This value contains proper request-level statistics for DBC/SQL sessions running SQL requests only. Ignore the value returned in this field for other types of sessions, such as DBC/SQL sessions linked to a utility job.

This field is equivalent to the MonitorSession ReqCPU field.

RequestAmpI/O FLOAT, NULLABLE

8 Total number of accesses by the current SQL request on the session on all AMPs.

This value contains proper request-level statistics for DBC/SQL sessions running SQL requests only. Ignore the value returned in this field for other types of sessions, such as DBC/SQL sessions linked to a utility job.

This field is equivalent to the MonitorSession ReqIO field.

Field Name Data TypeLength(Bytes) Description

Request Number INTEGER, NULLABLE

4 The Active Request Number.

If no request is running, then a value of zero or NULL is displayed in indicator mode.

WDId INTEGER, NULLABLE

4 The workload class ID associated with the specified request.

Page 139: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 139

Group V Data Field

The Record parcel returns the Group V data value, ProxyUser. The ProxyUser field is the name of the proxy user if the session has a proxy connection. ProxyUser is a VARCHAR data type and has a length of 256 bytes.

Sample Input

This example shows how the parcels for a MONITOR SESSION request, built by CLIv2, appear when sent to the Teradata Database server using a host_id of 387, a session_no of 1098, and a user_name of WEEKLY. In this example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

The following examples show the values returned in character text format for the MONITOR SESSION request.

Classification Mode SMALLINT, NULLABLE

2 An indicator if a running query or session is (or any future queries will be) forced into a workload definition (WD) or not.

The classification mode is valid only for DBC/SQL sessions and if Teradata DWM is enabled. If Teradata DWM is enabled, it classifies all incoming queries into a WD.

If Teradata DWM is enabled, the value is:

• 0 = Automatic by Teradata DWM

• 1 = Manual at Request Level

• 2 = Manual at Session Level

If Teradata DWM is not a DBC/SQL session or is disabled, then the value is 255 or NULL.

Field Name Data TypeLength(Bytes) Description

Flavor Length Body

Num Name Bytes Field Value

0001 Req 19 Request MONITOR SESSION

0003 Data 42 MonVerID 2

HostId 387

SessionNO 1098

UserName WEEKLY

0004 Resp 6 BufferSize 32731

Page 140: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

140 Workload Management API: PM/API and Open API

• Example 1 shows the values returned for a mon_ver_ID setting of 2 (only Group I data fields).

• Example 2 uses a different utility to show the values returned for a mon_ver_ID setting of 3.

• Example 3 shows the values returned for a mon_ver_ID setting of 4.

• Example 4 shows the values returned for a mon_ver_ID setting of 5. The same data fields returned in monitor version 5 are returned in monitor version 6.

• Example 5 shows the values returned for a mon_ver_ID setting of 7.

Note: Version 6 or 7 is required for Teradata Dynamic Workload Management PM/APIs.

The values returned vary in format and content depending on the value of mon_ver_ID used, the number of AMPs up on your system, and the structure of your application.

Pay attention to SampleSec when interpreting the results of this request.

Example 1: mon_ver_ID = 2 (Returns only Group I data fields)

Success parcel:StatementNo: 1 ActivityCount: 1ActivityType: 84 FieldCount: 1Warning code: 3276, Warning: Session Monitoring Rate has been altered.

DataInfo parcel:FieldCount: 1

Record parcel.Parcel flavor: 10 Parcel body length: 3SampleSec = 6.

EndStatement.Success parcel:StatementNo: 2 ActivityCount: -1ActivityType: 84 FieldCount: 47

DataInfo parcel:FieldCount: 47

Record parcel.Parcel flavor: 10 Parcel body length: 298HostId = 52, LogonNodeId = 1020, RunNodeId = 1020, SessionNo = 2520,UserName = "DBC ",UserAccount = "DBC ", UserID = 1, LSN = 0,

LogonTime = 12:16:31.00, LogonDate = 960802, PartName = "DBC/SQL ",PEState = "IDLE ", PECPUSec = 1738.31,XactCount = 1, ReqCount = 1, ReqCacheHits = 0,AMPState = "IDLE ", AMPCPUSec = 0.69, AMPIO = 101,Request_AMPSpool= 365568, Blk_1_HostId = <null>, Blk_1_SessNo = <null>,Blk_1_UserID = <null>, Blk_1_LMode = <null>, Blk_1_OType = <null>,Blk_1_ObjDBId = <null>, Blk_1_ObjTId = <null>, Blk_1_Status = <null>,Blk_2_HostId = <null>, Blk_2_SessNo = <null>, Blk_2_UserID = <null>,Blk_2_LMode = <null>, Blk_2_OType = <null>, Blk_2_ObjDBId = <null>,Blk_2_ObjTId = <null>, Blk_2_Status = <null>, Blk_3_HostId = <null>,Blk_3_SessNo = <null>, Blk_3_UserID = <null>, Blk_3_LMode = <null>,Blk_3_OType = <null>, Blk_3_ObjDBId = <null>, Blk_3_ObjTId = <null>,Blk_3_Status = <null>, MoreBlockers = <null>,

LogonSource = "(TCP/IP) 0974 141.206.3.29".Record parcel.Parcel flavor: 10 Parcel body length: 298

Page 141: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 141

HostId = 52, LogonNodeId = 1021, RunNodeId = 1021, SessionNo = 2519,UserName = "DBC ",UserAccount = "DBC ", UserID = 1, LSN = 0,

LogonTime = 12:14:57.00, LogonDate = 960802, PartName = "MONITOR ",PEState = "ACTIVE ", PECPUSec = 0.05,XactCount = 0, ReqCount = 2, ReqCacheHits = 0,AMPState = "IDLE ", AMPCPUSec = 0.86, AMPIO = 0,Request_AMPSpool = 0, Blk_1_HostId = <null>, Blk_1_SessNo = <null>,Blk_1_UserID = <null>, Blk_1_LMode = <null>, Blk_1_OType = <null>,Blk_1_ObjDBId = <null>, Blk_1_ObjTId = <null>, Blk_1_Status = <null>,Blk_2_HostId = <null>, Blk_2_SessNo = <null>, Blk_2_UserID = <null>,Blk_2_LMode = <null>, Blk_2_OType = <null>, Blk_2_ObjDBId = <null>,Blk_2_ObjTId = <null>, Blk_2_Status = <null>, Blk_3_HostId = <null>,Blk_3_SessNo = <null>, Blk_3_UserID = <null>, Blk_3_LMode = <null>,Blk_3_OType = <null>, Blk_3_ObjDBId = <null>, Blk_3_ObjTId = <null>,Blk_3_Status = <null>, MoreBlockers = <null>,

LogonSource = "(TCP/IP) 0972 141.206.3.29".Record parcel.Parcel flavor: 10 Parcel body length: 298HostId = 52, LogonNodeId = 1023, RunNodeId = 1023, SessionNo = 2521,UserName = "DBC ",UserAccount = "DBC ", UserID = 1, LSN = 0,

LogonTime = 12:18:45.00, LogonDate = 960802, PartName = "DBC/SQL ",PEState = "IDLE ", PECPUSec = 1874.45,XactCount = 1, ReqCount = 1, ReqCacheHits = 0,AMPState = "IDLE ", AMPCPUSec = 0.69, AMPIO = 101,Request_AMPSpool= 354304, Blk_1_HostId = <null>, Blk_1_SessNo = <null>,Blk_1_UserID = <null>, Blk_1_LMode = <null>, Blk_1_OType = <null>,Blk_1_ObjDBId = <null>, Blk_1_ObjTId = <null>, Blk_1_Status = <null>,Blk_2_HostId = <null>, Blk_2_SessNo = <null>, Blk_2_UserID = <null>,Blk_2_LMode = <null>, Blk_2_OType = <null>, Blk_2_ObjDBId = <null>,Blk_2_ObjTId = <null>, Blk_2_Status = <null>, Blk_3_HostId = <null>,Blk_3_SessNo = <null>, Blk_3_UserID = <null>, Blk_3_LMode = <null>,Blk_3_OType = <null>, Blk_3_ObjDBId = <null>, Blk_3_ObjTId = <null>,Blk_3_Status = <null>, MoreBlockers = <null>,

LogonSource = "(TCP/IP) 0975 141.206.3.29".TempSpaceUsg: 0.00EndStatement.EndRequest.

Example 2: mon_ver_ID = 3 (Returns both Group I and II data fields)

HostId: 1 SessionNo: 1007LogonPENo: 16383 RunVprocNo: 16383PartName: DBC/SQL PEState: DISPATCHINGLogonDate: 2001/02/07 LogonTime: 16:08:35.00UserID: 1 LSN: 0UserName: DBCUserAccount: DBCPECPUSec: 111 XactCount: 4.00ReqCount: 5.0 ReqCacheHits: 0.00AmpState: IDLEAmpCPUSec: 16.63 AMPIO: 7216.00Request_AMPSpool: 0.0Blk_1_HostId: 0 Blk_2_HostId: 0 Blk_3_HostId: 0Blk_1_SessNo: 0 Blk_2_SessNo: 0 Blk_3_SessNo: 0Blk_1_UserID: 0 Blk_2_UserID: 0 Blk_3_UserID: 0Blk_1_LMode: Blk_2_LMode: Blk_3_LMode:

Page 142: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

142 Workload Management API: PM/API and Open API

Blk_1_OType: Blk_2_OType: Blk_3_OType:Blk_1_ObjTId: 0 Blk_1_ObjTId: 0 Blk_3_ObjTId: 0Blk_1_Status: Blk_2_Status: Blk_3_Status:MoreBlockers:Logon Source: (TCP-IP)04E3 153.64.139.5 2664 01 LSSTempSpaceUsg: 0.00HotAmp1CPU: 8.85 HotAmp2CPU: 7.78 HotAmp3CPU: 0.00HotAmp1CPUId: 0 HotAmp2CPUId: 1 HotAmp3CPUId: 0HotAmp1IO: 3622.00 HotAmp2IO: 3594.00 HotAmp3CPUIO: 0.00HotAmp1IOId: 1 HotAmp2IOId: 0 HotAmp3IOId: 0LowAmp1CPU: 7.78 LowAmp2CPU: 8.85 LowAmp3CPU: 0.00LowAmp1CPUId: 1 LowAmp2CPUId: 0 LowAmp3CPUId: 0LowAmp1IO: 3594.00 LowAmp2IO: 3622.00 LowAmp3IO: 0.00LowAmp1IOId: 0 LowAmp2IOId: 1 LowAmp3IOId: 0UpAmpCount: 2AvgAmpCPUSec: 8.32 AvgAmpIOCnt: 3608.00

Example 3: mon_ver_ID = 4 (Returns Group I, II, and III data fields)

HostId: 1 SessionNo: 3873LogonPENo: 16383 RunVprocNo: 16383PartName: DBC/SQL PEState: DISPATCHINGLogonDate: 2002/12/05 LogonTime: 10:27:21.00UserID: 1 LSN: 0UserName: DBCUserAccount: DBCPECPUSec: 0.35 XactCount: 2.00ReqCount: 5.0 ReqCacheHits: 0.0AMPState: ACTIVEAMPCPUSec: 2.46 AMPIO: 3753.00Request_AmpSpool: 67584.0Blk_1_HostId: 0 Blk_2_HostId: 0 Blk_3_HostId: 0Blk_1_SessNo: 0 Blk_2_SessNo: 0 Blk_3_SessNo: 0Blk_1_UserID: 0 Blk_2_UserID: 0 Blk_3_UserID: 0Blk_1_LMode: Blk_2_LMode: Blk_3_LMode:Blk_1_OType: Blk_2_OType: Blk_3_OType:Blk_1_ObjDBId: 0 Blk_2_ObjDBId: 0 Blk_3_ObjDBId: 0Blk_1_ObjTId: 0 Blk_2_ObjTId: 0 Blk_3_ObjTId: 0Blk_1_Status: Blk_2_Status: Blk_3_Status:MoreBlockers:LogonSource: (TCP/IP) 04DB 141.206.38.100 SPALDING 472 JCK BTEQ 01 LSSTempSpaceUsg: 0.00HotAmp1CPU: 0.41 HotAmp2CPU: 0.36 HotAmp3CPU: 0.34HotAmp1CPUId: 7 HotAmp2CPUId: 5 HotAmp3CPUId: 6HotAmp1IO: 650.00 HotAmp2IO: 638.00 HotAmp3IO: 428.00HotAmp1IOId: 7 HotAmp2IOId: 6 HotAmp3IOId: 3LowAmp1CPU: 0.23 LowAmp2CPU: 0.24 LowAmp3CPU: 0.25LowAmp1CPUId: 4 LowAmp2CPUId: 0 LowAmp3CPUId: 3LowAmp1IO: 386.00 LowAmp2IO: 392.00 LowAmp3IO: 417.00LowAmp1IOId: 4 LowAmp2IOId: 5 LowAmp3IOId: 1AvgAmpCPUSec: 0.31 AvgAmpIOCnt: 469.13AmpCount: 8ReqStartTime: 2002/12/05 10:27:43.00 ReqCPU: 2.35 ReqIO: 3717.00

Example 4: mon_ver_id = 5 or 6 (Returns Group I through IV data fields)

HostId: 1 SessionNo: 1659LogonPENo: 16383 RunVprocNo: 16383

Page 143: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 143

PartName: MONITOR PEState: IDLE

LogonDate: 2006/08/01 LogonTime: 12:44:50.00UserID: 1 LSN: 0UserName: DBCUserAccount: DBC

PECPUSec: 0.00 XactCount: 0.00ReqCount: 1.0 ReqCacheHits: 0.0

AMPState: IDLEAMPCPUSec: 0.00 AMPIO: 0.00Delta_AMPSpool: 0.0

Blk_1_HostId: 0 Blk_2_HostId: 0 Blk_3_HostId: 0Blk_1_SessNo: 0 Blk_2_SessNo: 0 Blk_3_SessNo: 0Blk_1_UserID: 0 Blk_2_UserID: 0 Blk_3_UserID: 0Blk_1_LMode: Blk_2_LMode: Blk_3_LMode:Blk_1_OType: Blk_2_OType: Blk_3_OType:Blk_1_ObjDBId: 0 Blk_2_ObjDBId: 0 Blk_3_ObjDBId: 0Blk_1_ObjTId: 0 Blk_2_ObjTId: 0 Blk_3_ObjTId: 0Blk_1_Status: Blk_2_Status: Blk_3_Status:MoreBlockers:

LogonSource: (TCP/IP) 0BB4 153.64.136.171 KENTEST 3720 ADMINISTRATOR TSTPMPC 01 LSS

HotAmp1CPU: 0.00 HotAmp2CPU: 0.00 HotAmp3CPU: 0.00HotAmp1CPUId: 0 HotAmp2CPUId: 0 HotAmp3CPUId: 0

HotAmp1IO: 0.00 HotAmp2IO: 0.00 HotAmp3IO: 0.00HotAmp1IOId: 0 HotAmp2IOId: 0 HotAmp3IOId: 0

LowAmp1CPU: 0.00 LowAmp2CPU: 0.00 LowAmp3CPU: 0.00LowAmp1CPUId: 0 LowAmp2CPUId: 0 LowAmp3CPUId: 0

LowAmp1IO: 0.00 LowAmp2IO: 0.00 LowAmp3IO: 0.00LowAmp1IOId: 0 LowAmp2IOId: 0 LowAmp3IOId: 0

AvgAmpCPUSec: 0.00 AvgAmpIOCnt: 0.00AmpCount: 0

TempSpaceUsg: 0.00

ReqStartTime: 0000/00/00 00:00:00.00 ReqCPU: 0.00 ReqIO: 0.00ReqNo:0 0 WlcId: 0 DontReclassifyFlag: 255

Example 5: mon_ver_id = 7 (Returns Group I through V data fields)

HostId: 1 SessionNo: 1659LogonPENo: 16383 RunVprocNo: 16383PartName: MONITOR PEState: IDLE

LogonDate: 2006/08/01 LogonTime: 12:44:50.00UserID: 1 LSN: 0UserName: DBCUserAccount: DBC

Page 144: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

144 Workload Management API: PM/API and Open API

PECPUSec: 0.00 XactCount: 0.00ReqCount: 1.0 ReqCacheHits: 0.0

AMPState: IDLEAMPCPUSec: 0.00 AMPIO: 0.00Delta_AMPSpool: 0.0

Blk_1_HostId: 0 Blk_2_HostId: 0 Blk_3_HostId: 0Blk_1_SessNo: 0 Blk_2_SessNo: 0 Blk_3_SessNo: 0Blk_1_UserID: 0 Blk_2_UserID: 0 Blk_3_UserID: 0Blk_1_LMode: Blk_2_LMode: Blk_3_LMode:Blk_1_OType: Blk_2_OType: Blk_3_OType:Blk_1_ObjDBId: 0 Blk_2_ObjDBId: 0 Blk_3_ObjDBId: 0Blk_1_ObjTId: 0 Blk_2_ObjTId: 0 Blk_3_ObjTId: 0Blk_1_Status: Blk_2_Status: Blk_3_Status:MoreBlockers:

LogonSource: (TCP/IP) 0BB4 153.64.136.171 KENTEST 3720 ADMINISTRATOR TSTPMPC 01 LSS

HotAmp1CPU: 0.00 HotAmp2CPU: 0.00 HotAmp3CPU: 0.00HotAmp1CPUId: 0 HotAmp2CPUId: 0 HotAmp3CPUId: 0

HotAmp1IO: 0.00 HotAmp2IO: 0.00 HotAmp3IO: 0.00HotAmp1IOId: 0 HotAmp2IOId: 0 HotAmp3IOId: 0

LowAmp1CPU: 0.00 LowAmp2CPU: 0.00 LowAmp3CPU: 0.00LowAmp1CPUId: 0 LowAmp2CPUId: 0 LowAmp3CPUId: 0

LowAmp1IO: 0.00 LowAmp2IO: 0.00 LowAmp3IO: 0.00LowAmp1IOId: 0 LowAmp2IOId: 0 LowAmp3IOId: 0

AvgAmpCPUSec: 0.00 AvgAmpIOCnt: 0.00AmpCount: 0

TempSpaceUsg: 0.00

ReqStartTime: 0000/00/00 00:00:00.00 ReqCPU: 0.00 ReqIO: 0.00ReqNo:0 0 WlcId: 0 DontReclassifyFlag: 255ProxyUser: PXYUSER3

Warning and Error Messages

The following table describes the error messages that may be returned by the MONITOR SESSION request.

Message Number Description

3252 Invalid Session ID/User Name Pair: Name does not match SessionId.

Remedy: Correct the error and resubmit the request. The IDENTIFY SESSION request can be used to determine the correct user name if the session ID and host ID are known.

Page 145: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

Workload Management API: PM/API and Open API 145

For a discussion of common warning and error messages that may appear in response to an MONITOR PHYSICAL SUMMARY and other requests, see “Common Warning and Error Messages” on page 50.

For more detailed information on warning and error messages, see Messages.

Relationship Between MONITOR SESSION and ABORT SESSION

For information on this PMPC CLIv2 interface relationship, see “Relationship Between ABORT SESSION and MONITOR SESSION” on page 64.

Relationship Between MONITOR SESSION and IDENTIFY

For information on this PMPC CLIv2 interface relationship, see “Relationship Between IDENTIFY and MONITOR SESSION” on page 72.

Relationship Between MONITOR SESSION and SET SESSION RATE

You must execute the SET SESSION RATE request to activate session-level data collection before you execute a MONITOR SESSION request. This means that either the system rate or local rate must be set to nonzero. If both rates are zero, the following error message is returned:

Data Unavailable: Session Usage sampling is not currently enabled.

A change in the system-wide session collection rate may affect the data reported by a MONITOR SESSION request. Specifically, if User A makes a change in the system rate, this change could affect the viewing for User B of displayed data from a MONITOR SESSION request. Unless User B is aware of the rate change, User B may draw incorrect conclusions

3256 No such Session is currently logged on.

Remedy: Correct the error and resubmit the request.

3274 Data Unavailable: Session Usage Sampling is not currently enabled.

Remedy: Set the Session Monitoring Rate to a valid non-zero value, wait for a full collection period to expire, and resubmit this request.

3275 Warning: Session Data is incomplete for one of the following reasons:

• The system has gone through a recovery and a full collection period has not expired since

• The Resource Monitor Rate has been changed and a full collection period has not expired since.

Remedy: Wait for a full collection period to expire and resubmit the request.

3276 Warning: Session Monitoring Rate has been altered.

Remedy: This warning is informational.

Message Number Description

Page 146: Workload management api

Chapter 3: PMPC APIsMONITOR SESSION

146 Workload Management API: PM/API and Open API

from the observed data. In this case, User B receives the following warning message upon executing a MONITOR SESSION request:

Warning: Session Monitoring Rate has been altered.

Example

The following example is a single user on a system that uses the SET SESSION RATE and MONITOR SESSION requests.

1 User Morris uses the SET SESSION RATE request to set a session-level global rate of 600 seconds (or 10 minutes) at 9:00 a.m. The data time-stamp was set at 9:00 a.m. because that was the last time data was requested.

2 Morris then uses the SET SESSION RATE request to set a session-level local rate of 300 seconds (5 minutes) at 9:05 a.m. Morris does not make a request for data at this time. Therefore, the time-stamp is still set at 9:00 a.m.

3 Morris executes a MONITOR SESSION request at 9:08 a.m. for host_id of 510 and a session_no of 1000:

MONITOR SESSION 2 510 1000

4 A collection occurs because the “current” data was not considered current (that is, the age of the data is greater than the session collection rate). The system calculates that 9:08 a.m. (current time) - 9:00 a.m. (time-stamp) = 8 minutes, which is the age of the data. The 8 minutes is greater than 5 minutes, which is the local collection rate. Because of the forced update, Morris receives 8 minutes of data (from 9:00 a.m. to 9:08 a.m.), and the time-stamp is reset to 9:08 a.m.

5 At 9:10 a.m., Morris decides to make another MONITOR SESSION request. This time, no collection occurs, because the “current” available data was considered current. The system calculates that 9:10 a.m. (current time) - 9:08 a.m. (time-stamp) = 2 minutes (age of the data), which is less than 5 minutes (local collection rate). This means that the current data available is considered current, because no data update to the session-level memory repository occurs. Morris gets the same data that was returned at 9:08 a.m.

Two other events can cause data to be collected:

Event Comments

A default system timer of 10 minutes has elapsed without a request from a user.

Whenever 10 minutes has expired without a collection, the system timer causes a default collection to occur. This causes data in the main memory repository to be updated, even if no request is made.

When the AMP Session Cache is full A full AMP Session Cache forces an update of data in the main memory repository. This is a rare occurrence.

Page 147: Workload management api

Chapter 3: PMPC APIsMONITOR SQL

Workload Management API: PM/API and Open API 147

MONITOR SQL

PurposeIdentifies problem requests at the step level, including the SQL text of the request currently being executed, the step being executed, and the steps text (a scaled-down version of the output of the EXPLAIN request modifier) of the currently running request.

Input Data

Element Data TypeLength (Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

host_id SMALLINT 2 The logical ID of a host (or client) with sessions logged on. host_id cannot exceed 1023 bytes. A host _id of zero identifies the system console ID of the host on which the sessions are running.

session_no INTEGER 4 The session number. The session number combined with the host_id represents a unique session ID.

RunPEVprocNo SMALLINT, NULLABLE

2 The PE vproc number where the session runs. This is typically obtained from the MONITOR SESSION response of the RunVprocNo field. See the MONITOR SESSION RunVprocNo field for more information.

If this field is specified with a NULL or zero value, then all PEs will be searched for the session, causing significant overhead compared to sending Monitor SQL with known PE vproc number.

Note: This is a not a valid field for Monitor Version 2, 3, or 4.

Page 148: Workload management api

Chapter 3: PMPC APIsMONITOR SQL

148 Workload Management API: PM/API and Open API

Monitor Privileges

Unless monitor privileges have been established as part of the default role for the user, users must set a session role before exercising any of the monitor privileges for that role. If the current role is a specified non-NULL role, the user may be able to utilize monitor privileges via the current role or its nested roles. If the current role is ALL, the user may be able to use monitor privileges via any roles directly and indirectly granted. For more information, see Database Administration and Security Administration.

Usage Notes

You must have MONSESSION privileges to execute the MONITOR SQL request.

When issuing a MONITOR SQL request, you must specify a minimum buffer size of 32,007 bytes or more. For some custom applications, the following error message may appear:

Response buffer size is insufficient to hold one record.

If you receive this error message, increase the response buffer size and resubmit the Monitor SQL request. For details, see message number 3116 in “Warning and Error Messages” on page 154.

The MONITOR SQL request can be used in the following ways:

• A problematic query is utilizing a large amount of system resources. Use of this feature provides the associated SQL text to the system administrator to help identify possible bottlenecks, hardware problems and bugs. The query text and DDL statements can also be forwarded to Teradata Support Center for help in diagnosing the problem.

• The information provided by this request can help to identify specific SQL problems, such as poorly structured tables and indexes.

• Problems can even be traced down to the individual step within a query.

The MONITOR SQL request may not be used on internal sessions or sessions that are logged onto the monitor. Request text and steps text are not stored for these types of sessions, and if an attempt is made to query one of them, an error is returned indicating that it is not an SQL session.

Abort processing is handled in the same way as when using the MONITOR SESSION request. For further information about abort handling, see “MONITOR SESSION” on page 116.

MONITOR SQL is most useful when used with the MONITOR VIRTUAL SUMMARY request for doing a quick overall system health check. For more information, see “Relationship Between MONITOR VIRTUAL CONFIG and MONITOR VIRTUAL SUMMARY” on page 165.

Parcels

The MONITOR SQL request is treated internally as a three statement request with each statement generating a response. The three-statement response returned from Teradata Database contains the following sequence of parcel types:

Page 149: Workload management api

Chapter 3: PMPC APIsMONITOR SQL

Workload Management API: PM/API and Open API 149

Parcel Sequence

Parcel Flavor

Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = 1

ActivityType = 110 (PCLMONSQL)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This record contains the text of the SQL request.

EndStatement 11 6 StatementNo = 2-byte integer

Success 8 18 to 273 StatementNo = 2

ActivityCount = 1

ActivityType = 107 (PCLMONSQL)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This record contains Step count information.

EndStatement 11 6 StatementNo = 2-byte integer

Success 8 18 to 273 StatementNo = 3

ActivityCount = Number of EXPLAIN steps

ActivityType = 110 (PCLMONSQL)

Datainfo 71 6 TO 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 5 to 32004 (record mode) or 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. Each record contains step resource information.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Page 150: Workload management api

Chapter 3: PMPC APIsMONITOR SQL

150 Workload Management API: PM/API and Open API

Statement Type: 1

The response to the first statement results in a Record parcel that contains the SQL request text.

The RequestText field returned in the response is the actual SQL request for a specified session. RequestText is a VARCHAR, NULLABLE data type.

Statement Type: 2

The response to the second statement returns information regarding the total number of steps and which steps are currently executing.

Note: If only one step is executing, then CurLevlStepNum and CurLEv2StepNum will be identical.

Statement Type: 3

The response to the third statement returns a Record parcel that contains the step text for a given request. Each step returns a separate row. This parcel description has changed from the Version 3 parcel. The response parcel received is contingent upon whether you set mon_ver_id 3 or mon_ver_id 4. The values returned vary in format and content depending on the value of mon_ver_id used.

If mon_ver_id 3 is set, then the response to the third statement returns a Record parcel that contains the following steps text for a given request.

If mon_ver_id 4 is set, then the response to the third statement returns a Record parcel that contains the following steps text for a given request.

Field Name Data TypeLength(Bytes) Description

NumOfSteps SMALLINT 2 The number of steps contained in the description text.

CurLev1StepNum SMALLINT 2 This is the number of the currently executing level 1 step.

CurLev2StepNum SMALLINT 2 This is the number of the currently executing level 2 or parallel step.

Field Name Data TypeLength (Bytes) Description

StepNum SMALLINT 2 The unique number identifying the EXPLAIN step.

StepText VARCHAR (1024)

128 The generated text of the step.

Page 151: Workload management api

Chapter 3: PMPC APIsMONITOR SQL

Workload Management API: PM/API and Open API 151

The estimated fields populate immediately. The low value supplied by the optimizer will be used. The actual fields will be populated at the same time with a “-1”. After the step executes, the actual values (or a zero for those kinds of steps with no row count) will be placed in the actual fields to identify those steps that have been executed at the time of the API information capture.

Sample Input

This example shows how the parcels for a MONITOR SQL request built by CLIv2 appear when sent to the Teradata Database server. In this example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

Field Data TypeLength (Bytes) Description

StepNum SMALLINT 2 The unique number identifying the EXPLAIN step.

Confidence SMALLINT, NOT NULL

2 The confidence level as determined by the optimizer. The following values apply:

• 0 = None

• 1= Foreign Key

• 2 = Low

• 3 = High

EstRowCount FLOAT,NOT NULL

8 This is the row count generated from the Optimizer plan.

ActRowCount FLOAT,NOT NULL

8 This is the row count returned from the AMP for this step.

EstElapTime FLOAT, NOT NULL

8 This is the estimated time for the query as generated from the Optimizer plan.

ActElapTime FLOAT, NOT NULL

8 This is the actual elapsed time calculated by the dispatcher.

StepText VARCHAR 128 The generated text of the step.

Flavor Length Body

Num Name Bytes Field Value

0001 Req 16 Request MONITOR SQL

0003 Data 12 MonVerID

HostId

SessionNO

3

1

1002

0004 Resp 6 BufferSize 32731

Page 152: Workload management api

Chapter 3: PMPC APIsMONITOR SQL

152 Workload Management API: PM/API and Open API

Sample Output

This example shows the values returned in character text format for the MONITOR SQL request. Your application program may display returned values in a different format.

Note: The EXPLAIN steps shown are not as inclusive as those provided by the EXPLAIN request modifier.

The following is an Explain of a CREATE DATABASE SQL statement. This statement generates 21 steps. Step 7 has 7 parallel steps. Steps 9 and 11 have 2 parallel steps and step 11 has 3 parallel steps.

Explain CD baseDT1b AS PERM=1E6;

Explanation-----------------------------------------------------------------------1) First, we lock data base baseDT1b for exclusive use. 2) Next, we lock a distinct DBC."pseudo table" for write on a RowHash to prevent global deadlock for DBC.DataBaseSpace. 3) We lock a distinct DBC."pseudo table" for write on a RowHash to prevent global deadlock for DBC.AccessRights. 4) We lock a distinct DBC."pseudo table" for write on a RowHash to prevent global deadlock for DBC.Parents. 5) We lock a distinct DBC."pseudo table" for write on a RowHash to prevent global deadlock for DBC.Owners. 6) We lock DBC.DataBaseSpace for write, we lock DBC.AccessRights for write, we lock DBC.Parents for write, we lock DBC.Owners for write, we lock DBC.Accounts for write on a RowHash, we lock DBC.DBase for write on a RowHash, and we lock DBC.DBase for write on a RowHash. 7) We execute the following steps in parallel. 1) We do a single-AMP ABORT test from DBC.DBase by way of the unique primary index with no residual conditions. 2) We do a single-AMP ABORT test from DBC.Roles by way of the unique primary index with no residual conditions. 3) We do a single-AMP ABORT test from DBC.DBase by way of the unique primary index. 4) We do a single-AMP ABORT test from DBC.DBase by way of the unique primary index. 5) We do an INSERT into DBC.DBase. 6) We do a single-AMP UPDATE from DBC.DBase by way of the unique primary index with no residual conditions. 7) We do a single-AMP RETRIEVE step from DBC.Parents by way of the primary index with no residual conditions into Spool 1 (all_amps), which is redistributed by hash code to all AMPs. Then we do a SORT to order Spool 1 by row hash. 8) We do an all-AMPs MERGE into DBC.Owners from Spool 1 (Last Use). 9) We execute the following steps in parallel. 1) We do an INSERT into DBC.Owners. 2) We do a single-AMP RETRIEVE step from DBC.Parents by way of the primary index with no residual conditions into Spool 2 (all_amps), which is redistributed by hash code to all AMPs. Then we do a SORT to order Spool 2 by row hash. 10) We do an all-AMPs MERGE into DBC.Parents from Spool 2 (Last Use). 11) We execute the following steps. 1) We do an INSERT into DBC.Parents. 2) We do an INSERT into DBC.Accounts. 3) We do a single-AMP RETRIEVE step from DBC.AccessRights by way of the primary index into Spool 3 (all_amps), which is

Page 153: Workload management api

Chapter 3: PMPC APIsMONITOR SQL

Workload Management API: PM/API and Open API 153

redistributed by hash code to all AMPs. 12) We execute the following steps in parallel. 1) We do a single-AMP RETRIEVE step from DBC.AccessRights by way of the primary index into Spool 3 (all_amps), which is redistributed by hash code to all AMPs. 2) We do an all-AMPs RETRIEVE step from DBC.AccessRights by way of an all-rows scan into Spool 4 (all_amps), which is redistributed by hash code to all AMPs. Then we do a SORT to order Spool 4 by row hash. 13) We do an all-AMPs JOIN step from DBC.Owners by way of a RowHash match scan, which is joined to Spool 4 (Last Use). DBC.Owners and Spool 4 are joined using a merge join. The result goes into Spool 3 (all_amps), which is redistributed by hash code to all AMPs. Then we do a SORT to order Spool 3 by row hash. 14) We do an all-AMPs MERGE into DBC.AccessRights from Spool 3 (Last Use). 15) We flush the DISKSPACE and AMPUSAGE caches. 16) We do an all-AMPs ABORT test from DBC.DataBaseSpace by way of the unique primary index. 17) We do an INSERT into DBC.DataBaseSpace. 18) We do an all-AMPs UPDATE from DBC.DataBaseSpace by way of the unique primary index with no residual conditions. 19) We flush the DISKSPACE and AMPUSAGE caches. 20) We spoil the parser's dictionary cache for the database. 21) 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 following is the output from Teradata Performance Monitor capturing the step data of the SQL statement above.

The first column of numbers is a sequential count of the rows returned from the DBS.

When a step number is repeated in the step number column, it indicates that it is a parallel step. For instance, in the following example, the step number 7 is repeated 7 times. This coincides with the 7 parallel steps found for step 7 in the above Explain. Step 9 and 12 have two entries (they both have 2 parallel steps) and that step 11 is repeated 3 times for its 3 parallel steps. You will also note that the step text itself indicates when a block of parallel steps begins, that a step is part of a parallel block and when a parallel block of steps ends.

The statement “Currently executing step 24 of 31” refers to the sequential row count and not the actual step number. Teradata Performance Monitor highlights the currently active step. You will note that the data for the currently active step and those following it is blank. The data is only available after the step completes. Remember that Step text is derived information and not the true EXPLAIN text.

Teradata Performance Monitor output appears as follows:

CD baseDT1b AS PERM=1E6;Currently executing step 24 of 31 steps

Step Est. Actual Est. Actual Step TextTime Time IOs IOs

1 1 0:00.00 0:00.00 0 1 First, lock [DBId=0x0406].for exclusive.2 2 0:00.00 0:00.01 0 1 Next, we lock DBC."pseudo table" for write on a row hash.3 3 0:00.00 0:00.00 0 1 We lock DBC."pseudo table" for write on a row hash.4 4 0:00.00 0:00.01 0 1 We lock DBC."pseudo table" for write on a row hash.

Page 154: Workload management api

Chapter 3: PMPC APIsMONITOR SQL

154 Workload Management API: PM/API and Open API

5 5 0:00.00 0:00.11 0 1 We lock DBC.DBSpace for write, we lock DBC.AccessRights for write, we lock DBC.Parents for write, we lock DBC.Owners for write, we lock DBC.Accounts for write on a row hash, we lock DBC.DBase for write on a row hash and we lock DBC.DBase for write on a row hash.

7 7 0:00.00 0:00.00 0 0 We do a Single-AMP ABORT test from DBC.DBase by way of unique primary index. This step begins a parallel block of steps.

8 7 0:00.00 0:00.00 0 0 We do a Single-AMP ABORT test from DBC.[TBId=0x0071] by way of the unique primary index. This step is performed in parallel.

9 7 0:00.00 0:00.00 0 0 We do a Single-AMP ABORT test from DBC.DBase by way of the unique primary index. This step is performed in parallel.

10 7 0:00.00 0:00.00 0 0 We do a Single-AMP ABORT test from DBC.DBase by way of the unique primary index. This step is performed in parallel.

11 7 0:00.00 0:00.00 0 1 We do an INSERT step into table DBC.DBase. This step is performed in parallel.

12 7 0:00.00 0:00.07 0 1 We do a Single-AMP UPDATE from DBC.DBase by way of the unique primary index. This step is performed in parallel.

13 7 0:00.00 0:00.07 0 0 We do a Single-AMP RETRIEVE step from DBC.Parents by way of the primary index into Spool 6345, which is redistributed by hash code to all AMPs. This step ends aparallel block of steps.

14 8 0:00.00 0:00.00 0 0 We do a MERGE into table DBC.Owners from Spool 6345.15 9 0:00.00 0:00.02 0 1 We do an INSERT step into table DBC.Owners. This step

begins a parallel block of steps.16 9 0:00.00 0:00.01 0 1 We do a Single-AMP RETRIEVE step from DBC.Parents by way

of the primary index into Spool 6346, which is redistributed by hash code to all AMPs. This step ends a parallel block of steps.

17 10 0:00.00 0:00.00 0 0 We do a MERGE into table DBC.Parents from Spool 6346.18 11 0:00.00 0:00.07 0 1 We do an INSERT step into table DBC.Parents. This step

begins a parallel block of steps.19 11 0:00.00 0:00.07 0 1 We do an INSERT step into table DBC.Accounts. This step is

performed in parallel.20 11 0:00.00 0:00.01 0 21 We do a Single-AMP RETRIEVE step from DBC.AccessRights by

way of the primary index into Spool 6347, which is redistributed by hash code to all AMPs. This step ends a parallel block of steps.

21 12 0:00.00 0:00.01 0 17 We do a Single-AMP RETRIEVE step from DBC.AccessRights by way of the primary index into Spool 6347, which is redistributed by hash code to all AMPs. This step begins a parallel block of steps.

22 12 0:00.00 0:00.01 0 0 We do an All-AMPs RETRIEVE step from DBC.AccessRights by way of an all-rows scan into Spool 6348, which is redistributed by hash code to all AMPs. This step ends a parallel block of steps.

23 13 0:00.00 0:00.01 0 17 We do an All-AMPs JOIN step from DBC.Owners by way of an all-rows scan, which is joined to Spool 6348. table Owners and Spool 6348 are joined using a merge join. The result goes into Spool 6347, which is redistributed by hash code to all AMPs.

24 14 0:00.00 0 We do a MERGE into table DBC.AccessRights from Spool 6347.

25 15 0:00.00 0 We flush the DISKSPACE and AMPUSAGE caches.26 16 0:00.00 0 We do an All-AMPs ABORT test from DBC.DBSpace by way of

0 the unique primary index.27 17 0:00.00 0 We do an INSERT step into table DBC.DBSpace.28 18 0:00.00 0 We do an All-AMPs UPDATE from DBC.DBSpace by way of the

unique primary index.29 19 0:00.00 0 We flush the DISKSPACE and AMPUSAGE caches.30 20 0:00.00 0 We Spoil the parser's dictionary cache for the database.31 21 0:00.00 0 We send out an END TRANSACTION step to all AMPs involved

in processing the request.

Warning and Error Messages

Specific error messages that may be returned by the MONITOR SQL request are as follows:

Page 155: Workload management api

Chapter 3: PMPC APIsMONITOR SQL

Workload Management API: PM/API and Open API 155

For a discussion of common warning and error messages that may appear in response to an MONITOR SQL and other requests, see “Common Warning and Error Messages” on page 50.

For more detailed information on warning and error messages, see Messages.

Message Number Description

3116 Response buffer size is insufficient to hold one record.

Remedy: Increase the response buffer size to the size returned in the Info field of the error parcel and resubmit the Monitor SQL request.

See the Teradata Call-Level Interface Version 2 Reference for Channel-Attached Systems or Teradata Call-Level Interface Version 2 Reference for Network-Attached Systems for instructions on how to change the response buffer size.

3256 No such Session is currently logged on.

Remedy: Correct the error and resubmit the request.

3297 The session is not currently executing SQL.

Remedy: Retry or check the session itself.

3298 PM/API SET SESSION ACCOUNT not allowed with the Teradata Dynamic Workload Management workload class.

Remedy: Use the TDWM WD ASSIGNMENT request. For more information about this request, see “TDWM WD ASSIGNMENT” on page 345.

3523 User does not have the necessary privileges for this request.

Remedy: Obtain the necessary privileges.

3671 Invalid host_id specified.

Remedy: Correct the statement and resubmit the request.

Page 156: Workload management api

Chapter 3: PMPC APIsMONITOR VERSION

156 Workload Management API: PM/API and Open API

MONITOR VERSION

PurposeIdentifies the highest version number (MonVerId) the Teradata Database monitor function supports, which determines the requests and data fields available for use.

Input Data

Monitor Privileges

Unless monitor privileges have been established as part of the default role for the user, users must set a session role before exercising any of the monitor privileges for that role. If the current role is a specified non-NULL role, the user may be able to utilize monitor privileges via the current role or its nested roles. If the current role is ALL, the user may be able to use monitor privileges via any roles directly and indirectly granted. For more information, see Database Administration and Security Administration.

Usage Notes

Several versions or request sets are accessible using PM/API:

• Version 2 does not include MONITOR SQL or MONITOR VERSION. For MONITOR SESSION, version 2 returns only Group I parcel data.

• For MONITOR SESSION, version 3 includes all data fields on session-specific AMP resource usage from Groups I and II.

• For MONITOR SESSION, version 4 includes all request level usage information from Groups I through III.

• For MONITOR SESSION, version 5 and 6 includes all requests and data fields from Groups I through IV.

Element Data TypeLength(Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 3, 4, 5, 6, or 7.

Page 157: Workload management api

Chapter 3: PMPC APIsMONITOR VERSION

Workload Management API: PM/API and Open API 157

• For MONITOR SESSION, version 7 includes all requests and data fields from Groups I through V.

Note: Version 6 or 7 is required for Teradata Dynamic Workload Management PM/APIs.

For information on the parcel data fields returned for Groups I through V of MONITOR SESSION, see “Response Parcel Groups” on page 123.

The MONITOR VERSION request does not check for access privileges.

Parcels

The MONITOR VERSION request is treated internally as a one-statement request that generates one response. The statement response returned from Teradata Database contains the following sequence of parcel types:

For more information on parcel body fields, see Teradata Call-Level Interface Version 2 Reference for Channel-Attached Systems, or Teradata Call-Level Interface Version 2 Reference for Network-Attached Systems.

The response to the statement results in a Record parcel containing the FunctionBitmap field, a 2-byte bitmap indicating the supported functions. The following values apply:

• Bit0 = ModifyAccount

• Bit1 = Monitor SQL

• Bit2 = 15 - Set to zero (This bit is not currently used)

The bits are 1 if supported and zero if not.

FunctionBitmap is a SMALLINT data type and has a length of 2 bytes.

Parcel Sequence

Parcel Flavor

Length(Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = Highest supported version

ActivityType = 108 (PCLMONVER)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. A 2-byte bitmap field indicates supported functions.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Page 158: Workload management api

Chapter 3: PMPC APIsMONITOR VERSION

158 Workload Management API: PM/API and Open API

Sample Input

This example shows how the parcels for a MONITOR VERSION request built by CLIv2 appear when sent to the Teradata Database server. In this example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

This example shows the values returned in character text format for the MONITOR VERSION request. Your application program may display returned values in a different format.

Enter PMPC command: monitor version;Submitting request MONITOR VERSION;Highest support monitor version: 3Function bitmap: 2

Warning and Error Messages

There are no specific warning or error messages codes associated with the MONITOR VERSION request.

Flavor Length Body

Num Name Bytes Field Value

0001 Req 19 Request MONITOR VERSION

0003 Data 8 MonVerID 3

0004 Resp 6 BufferSize 32731

Page 159: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL CONFIG

Workload Management API: PM/API and Open API 159

MONITOR VIRTUAL CONFIG

PurposeCollects information on virtual processor (vproc) availability.

Input Data

Monitor Privileges

Unless monitor privileges have been established as part of the default role for the user, users must set a session role before exercising any of the monitor privileges for that role. If the current role is a specified non-NULL role, the user may be able to utilize monitor privileges via the current role or its nested roles. If the current role is ALL, the user may be able to use monitor privileges via any roles directly and indirectly granted. For more information, see Database Administration and Security Administration.

Usage Notes

Information regarding vproc status is returned for all AMP, PE, and VSS vprocs in the system.

A user must have any one of the following MONITOR privileges to execute the MONITOR VIRTUAL CONFIG request:

• ABORTSESSION

• MONRESOURCE

• MONSESSION

• SETRESRATE

Element Data TypeLength(Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using the Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Page 160: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL CONFIG

160 Workload Management API: PM/API and Open API

• SETSESSRATE

MONITOR VIRTUAL CONFIG is most useful when used with the MONITOR VIRTUAL SUMMARY request for doing a quick overall system health check. For more information, see “Relationship Between MONITOR VIRTUAL CONFIG and MONITOR VIRTUAL SUMMARY” on page 165.

If you use MONITOR VIRTUAL CONFIG, you do not need to dump out the DBC.SW_Event_Log table (accessible from the DBC.Software_Event_LogV view) to see if there is a physical problem with the system.

Parcels

The MONITOR VIRTUAL CONFIG request is treated internally as a two statement request with each statement generating a response. The two statement response returned from Teradata Database contains the following sequence of parcel types:

Parcel Sequence

Parcel Flavor

Length(Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo =1

ActivityCount = 1

ActivityType = 91 (PCLMONVCONFIG)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This record contains the BYNET status data.

EndStatement 11 6 StatementNo = 2-byte integer

Success 8 18 to 273 StatementNo = 2

ActivityCount = Number of vprocs

ActivityType = 91 (PCLMONVCONFIG)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This record contains the vproc-specific information; one record per vproc.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Page 161: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL CONFIG

Workload Management API: PM/API and Open API 161

Statement Type: 1

The following table describes the order in which the Record parcel in the first statement of the MONITOR VIRTUAL CONFIG returns the BYNET status values and the system type.

Statement Type: 3

The Record parcels in the second statement of the MONITOR VIRTUAL CONFIG response return one record for each processor, with six fields in each record. Records are sorted based on VProcNo. For example, if you have 32 vprocs, 32 records are returned with specific information for each vproc, in addition to the one record of BYNET data for the whole system.

Column Field Data TypeLength(Bytes) Description

1 NetAUp CHAR, NULLABLE

1 The status of the BYNETs (if there are more than two, the first two) on a system-wide basis.

The following values apply:

• D = Down/Offline

• U = Up/Online

• S = Standby

2 NetBUp CHAR, NULLABLE

1 The status of the BYNETs (if there are more than two, the first two) on a system-wide basis.

The following values apply:

• D = Down/Offline

• U = Up/Online

• S = Standby

Note: The value is always zero.

3 SystemType CHAR 7 The type of system running Teradata Database software, for example: 3400, 3500, 5100, or “Unknown”.

Page 162: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL CONFIG

162 Workload Management API: PM/API and Open API

Sample Input

This example shows how the parcels for a MONITOR VIRTUAL CONFIG request built by CLIv2 appear when sent to the Teradata Database server. In this example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

Field Name Data TypeLength(Bytes) Description

ProcId SMALLINT 2 The ID associated with a node. This value is computed as the module number within a cabinet plus 100 times the cabinet number. Usually formatted for display as zz9-99. However, this display format can be changed by the user.

VProcNo SMALLINT 2 The ID of an AMP (that is, a set of disk) and the associated tasks or processes that, in combination, make up the AMP), PE or VSS vproc.

VProcType CHAR 3 The type of vproc: AMP, PE, and VSS.

HostId SMALLINT, NULLABLE

2 The logical host ID for the PEs. This field shows NULL for the AMP or VSS vprocs associated with this record. Each channel- or LAN-connected host is assigned an ID at the time the system is configured. Each PE is assigned to a (single) channel-connected host (or client) or a LAN-connected host. The host ID of zero is reserved for the PEs processing internal sessions.

Status CHAR 1 The status of the vproc associated with this record. A vproc is considered up or down from the standpoint of whether the vproc is helping a query process SQL statements. For example, an AMP doing offline recovery is considered to be down because the AMP is not helping to process SQL statements. On the other hand, an up vproc is one that is online and fully up or is in online recovery.

The status of the node. The following values apply:

• U = Up or Online

• D = Down or Offline

• S = Standby (This value indicates the node is ready to join the configuration in place if another node goes down.)

DiskSlice SMALLINT 2 Virtual disk ID defining the portion of a physical disk assigned to an AMP.

This value is NULL for VSS vprocs.

Flavor Length Body

Num Name Bytes Field Value

Page 163: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL CONFIG

Workload Management API: PM/API and Open API 163

Sample Output

This example shows the values returned in character text format for the MONITOR VIRTUAL CONFIG request. Your application program may display returned values in a different format.

Success parcel:StatementNo: 1 ActivityCount: 1ActivityType: 91 FieldCount: 3

DataInfo parcel:FieldCount: 3

Record parcel.Parcel flavor: 10 Parcel body length: 10NetAUp = 'U', NetBUp = 'U', SystemType = "5100 ".

EndStatement.Success parcel:StatementNo: 2 ActivityCount: 20ActivityType: 91 FieldCount: 6

DataInfo parcel:FieldCount: 6

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 746, VProcNo = 0, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 0.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 736, VProcNo = 1, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 1.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 746, VProcNo = 2, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 2.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 736, VProcNo = 3, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 3.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 746, VProcNo = 4, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 4.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 736, VProcNo = 5, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 5.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 746, VProcNo = 6, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 6.

Record parcel.Parcel flavor: 10 Parcel body length: 13

0001 Req 26 Request MONITOR VIRTUAL CONFIG

0003 Data 6 MonVerID 2

0004 Resp 6 BufferSize 32731

Flavor Length Body

Page 164: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL CONFIG

164 Workload Management API: PM/API and Open API

NodeId = 736, VProcNo = 7, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 7.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 746, VProcNo = 8, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 8.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 736, VProcNo = 9, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 9.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 746, VProcNo = 10, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 10.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 736, VProcNo = 11, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 11.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 746, VProcNo = 12, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 12.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 736, VProcNo = 13, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 13.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 746, VProcNo = 14, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 14.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 736, VProcNo = 15, VProcType = "AMP", HostId = <null>,VProcStatus = 'U', DiskSlice = 15.

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 746, VProcNo = 1020, VProcType = "PE ", HostId = 52,VProcStatus = 'U', DiskSlice = <null>,

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 746, VProcNo = 1021, VProcType = "PE ", HostId = 52,VProcStatus = 'U', DiskSlice = <null>,

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 736, VProcNo = 1022, VProcType = "PE ", HostId = 52,VProcStatus = 'U', DiskSlice = <null>,

Record parcel.Parcel flavor: 10 Parcel body length: 13NodeId = 736, VProcNo = 1023, VProcType = "PE ", HostId = 52,VProcStatus = 'U', DiskSlice = <null>,

EndStatement.EndRequest.

Warning and Error Messages

There are no warning or error messages specifically associated with the MONITOR VIRTUAL CONFIG request. For a discussion of common warning and error messages that may be

Page 165: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL CONFIG

Workload Management API: PM/API and Open API 165

returned in response to MONITOR VIRTUAL CONFIG and other requests, see “Common Warning and Error Messages” on page 50.

Relationship Between MONITOR VIRTUAL CONFIG and MONITOR VIRTUAL SUMMARY

Use MONITOR VIRTUAL SUMMARY with the MONITOR VIRTUAL CONFIG request for an overall system status. These are low overhead requests.

• Execute the MONITOR VIRTUAL SUMMARY request every 5 or 10 minutes for a low-cost, continuous monitoring of your system.

• Execute the MONITOR VIRTUAL CONFIG request to get a picture of your system configuration at defined times, such as at the beginning of a day, various times during the day, or when the system is down.

Using these requests to spot problems, such as abnormal AMP CPU load balancing, and possible sources of system performance bottlenecks. For example, if the HiCPUAMPUse, HiCPUPEUse, LoCPUAMPUse, and LoCPUPEUse figures are consistently widely separated and do not approximate the AMPAvgCPU figure, you may need to evaluate whether the system is using available resources efficiently. Alternatively, if the PEAvgCPU is consistently much higher than the AMPAvgCPU, the system may not be configured to efficiently use AMP resources. How often you perform a health check of your system depends on the size of your system and the type of applications run.

Knowledge of the overall system status can help you to determine:

The response data returned by MONITOR VIRTUAL CONFIG is similar in content to the response data returned by a MONITOR VIRTUAL RESOURCE request, but it is in an abbreviated form. In your initial problem analysis, if the information returned from a MONITOR VIRTUAL SUMMARY query does not give you enough data. For example, you need BYNET or CPU% busy information and you may want to use MONITOR VIRTUAL RESOURCE to obtain more detailed resource usage data.

Concern Comments

When to run production applications, especially large ones

For example, if you have a down AMP, you may decide that it is less costly to recover the AMP first and run the job than to run the job without full system availability.

Why an application runs more slowly than usual

This situation may be caused by a down AMP, which results in the backup AMP doing more work, specifically, doing backup and primary processing. This, in turn, could cause your application to run more slowly.

Whether all vprocs have come back up after a system restart

Examine the Status value returned in a MONITOR VIRTUAL CONFIG request to determine whether each vproc is up or down (see the MONITOR VIRTUAL CONFIG Status field).

Page 166: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

166 Workload Management API: PM/API and Open API

MONITOR VIRTUAL RESOURCE

PurposeCollects performance information for each AMP, PE, or VSS vproc and returns:

• System-wide (identical for all vprocs) data

• vproc-specific data

Input Data

Monitor Privileges

Unless monitor privileges have been established as part of the default role for the user, users must set a session role before exercising any of the monitor privileges for that role. If the current role is a specified non-NULL role, the user may be able to utilize monitor privileges via the current role or its nested roles. If the current role is ALL, the user may be able to use monitor privileges via any roles directly and indirectly granted. For more information, see Database Administration and Security Administration.

Usage Notes

A user must have MONRESOURCE privilege to execute the MONITOR VIRTUAL RESOURCE request.

You can use the MONITOR VIRTUAL RESOURCE request to:

• Expand on the data reported by the MONITOR VIRTUAL SUMMARY request.

Element Data TypeLength (Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using the Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Page 167: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

Workload Management API: PM/API and Open API 167

In your initial problem analysis, a MONITOR VIRTUAL SUMMARY request may indicate a performance or system problem. MONITOR VIRTUAL RESOURCE allows you to gather resource usage information on a vproc by vproc basis.

• Continually monitor your system.

Monitor your system continually on a periodic basis, for example, every 10 minutes. Use this request to build a normal baseline profile for your system. When you notice something abnormal, such as the last reading is significantly different from the normal baseline reading, or when a user complains that a job is slow, this request can tell you if there is a parallel efficiency problem or a constraint to throughput, and which vproc is causing it. For example, if one PE shows a much higher usage than the other PEs, that PE might be overloaded. Also, if one AMP is loaded more heavily than the other AMPs, you may have problems with a skewed index.

• Determine whether a new application can be added to the current system load without disruption.

The vproc usage information collected by this request can help you evaluate the impact of adding new applications to an already heavily utilized system and help you plan potential system upgrades.

• Help resolve problems that session-level usage information cannot resolve.

When the MONITOR SESSION request does not show any cause for the problem, this request can supply information regarding congestion, memory allocations, BYNET outages, and system status.

The MONITOR VIRTUAL RESOURCE request can provide information about:

• How the is system being used (for example, the number of sessions associated with each vproc and the percentage of CPU usage by vproc).

• How system resource usage is spread across the vprocs (for example, whether the vprocs are used evenly).

• How much physical disk I/O, BYNET traffic, or host reads and writes are occurring.

• Whether congestion or excessive swapping is a problem on any vproc or group of vprocs.

The MONITOR VIRTUAL RESOURCE request returns some of the same fields found in the ResUsage tables. You can use both MONITOR VIRTUAL RESOURCE and resource usage data for problem detection. Unlike resource usage data, MONITOR VIRTUAL RESOURCE data is instantaneous, and requires less overhead to produce, but is less comprehensive. MONITOR VIRTUAL RESOURCE data can help detect:

• Poor AMP CPU parallel efficiency

• Poor disk parallel efficiency

• A higher than expected disk read/write ratio

• A high swap I/O rate

If MONITOR VIRTUAL RESOURCE does not give you all the detailed data you need for problem detection, run one or more of the resource usage macros for the AMP, PE, or VSS vprocs. See Resource Usage Macros and Tables for more information on problem detection and the resource usage macros.

Page 168: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

168 Workload Management API: PM/API and Open API

Note: You must set the rate by which vproc resource usage data is updated within memory (VProcMonitor rate) to nonzero for the MONITOR VIRTUAL RESOURCE request to return meaningful data. If you set the VProcMonitor rate to zero, NULL values are returned for all vproc usage data.

Also note that if the VSS vproc is configured on a node without any AMPs, all fields will return a zero value.

After a system outage or a change in the VProcMonitor rate, do not request data again until after completion of the first sample period requested after the crash or change in rate. Otherwise, the data returned will contain NULL values for all columns except NetAUp, NetBUp, SampleSec, VProcType, ProcId, VProcNo, HostId/ClusterNo, and Status, and may not be fully representative. This is because after a system failure, the in-memory counters are reset, and typically the contents of the counters are not well defined until a full sample period has elapsed. In fact, if you were logged on prior to the system outage and you issue your first MONITOR VIRTUAL RESOURCE request after the outage, you will receive a warning that the Teradata Database system has been restarted.

Parcels

The MONITOR VIRTUAL RESOURCE request is treated internally as a two statement request, with each statement generating a response. The two statement response returned from Teradata Database contains the following sequence of parcel types:

Parcel Sequence

Parcel Flavor

Length(Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = 1

ActivityType = 95 (PCLMONVRES)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. One record is returned that contains the duration of the sample period (in seconds) and BYNET status.

EndStatement 11 6 StatementNo = 2-byte integer

Success 8 18 to 273 StatementNo = 2

ActivityCount = Number of vprocs

ActivityType = 95 (PCLMONVRES)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Page 169: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

Workload Management API: PM/API and Open API 169

Statement Type: 1

The Record parcel in the first statement of the MONITOR VIRTUAL RESOURCE response returns global data about sample duration and BYNET status in the order listed below.

Statement Type: 2

The response to the second statement results in multiple Record parcels that consist of a record for each vproc in the system. The Record parcels in the second statement of the MONITOR VIRTUAL RESOURCE response can return multiple records, specifically, one record of 32 fields for each vproc in the system. For example, if you have 50 vprocs, 50 records are returned with specific information for each vproc, one record describing the sample period, and BYNET status for the entire system. Records are sorted by VProcType and VProcNo.

The following table shows the order in which the data is returned from the Record parcel.

Record 10 5 to 32004 (record mode) or 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. One record per vproc is returned that contains a description for each vproc in the system.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Field Name Data TypeLength(Bytes) Description

NetAUp,NetBUp

CHAR, NULLABLE

1 The status of the BYNETs (if there are more than two, the first two) on a system-wide basis.

The following values apply:

• D = Down/Offline

• U = Up/Online

• S = Standby

SampleSec SMALLINT 2 The duration of the sample period, in seconds. This is the session local rate if one has been set, or the session global rate if not. This field is equivalent to the VProcMonitor rate. See SET RESOURCE RATE, for more information on VProcMonitor.

Column Name Data TypeLength (Bytes) Description

VprocType CHAR 3 The type of vproc: PE, AMP, or VSS.

Parcel Sequence

Parcel Flavor

Length(Bytes) Comments/Key Parcel Body Fields

Page 170: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

170 Workload Management API: PM/API and Open API

ProcId SMALLINT 2 The ID associated with a node. This value is computed as the module number within a cabinet plus 100 times the cabinet number. Usually formatted for display as zz9-99. However, this display format can be changed by the user.

VprocNo SMALLINT 2 The ID of an AMP (that is, a set of disks and the associated tasks or processes that, in combination, make up the AMP), PE or VSS vproc.

HostId/ClusterNo SMALLINT,NULLABLE

2 For a PE vproc, this field, HostId, identifies one of the hosts or LANs associated with the described PE.

For an AMP vproc, this field, ClusterNo, identifies the cluster to which this AMP has been assigned.

This field is not applicable to VSS vproc and a NULL value is returned.

CPUUse FLOAT,NULLABLE,range 0 - 100%

8 The % of CPU usage not spent being idle. The node-level display is computed from ResUsageSpma table data as:

PercntUser + PercntService

The vproc-level displays is computed from ResUsageSvpr table data as:

100.00 * (CPUUExecPart00 + CPUUExecPart01 + ... + CPUUExecPart15 + CPUUServPart00 + CPUUServPart01 + ... + CPUUServPart15) / (x * SampleSec)

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Column Name Data TypeLength (Bytes) Description

Page 171: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

Workload Management API: PM/API and Open API 171

Status CHAR 1 The status of the node, AMP, PE, or VSS vproc associated with this record. The following values apply:

• U = Up/online

• D = Down

• S = Standby

A vproc or node is up (U) when it is:

• Configured into the system

• Online

• Capable of actively performing tasks associated with normal Teradata Database activity

Down (D) represents all other potential states.

Standby (S) indicates the vproc or node is ready to join the configuration in place if another vproc or node goes down.

SessLogCount SMALLINT,NULLABLE

2 SessLogCount is the number of current sessions logged to this PE. A logged on session is either a session whose logon request was delivered to this PE, or a session that was switched to this PE following its logon.

SubpoolId identifies the subpool associated with the allocator vproc. A subpool defines a set of storage and allocator vprocs assigned to that storage.

This value is NULL for:

• AMPs.

• Down or offline PEs.

• A request for data that is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Note: The SessLogCount field contains the SubPoolId if the vproc type is VSS.

Column Name Data TypeLength (Bytes) Description

Page 172: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

172 Workload Management API: PM/API and Open API

SessRunCount SMALLINT,NULLABLE

2 The number of current sessions whose Initiate Requests (TSR messages) are addressed to this vproc. For example:

• PEs have a SessRunCount that includes all the Teradata SQL and MONITOR sessions logged on to that PE.

• AMPs may have a nonzero SessRunCount, since AMPs receive TSR messages from FastLoad or MultiLoad logons.

Note: Sessions involving Archive and Recovery jobs are not included in this SessRunCount because HUT sessions do not deliver TSR messages to a fixed AMP or PE.

This value is NULL for:

• Down or offline AMPs or PEs.

• A request for data that is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

DiskUse FLOAT,NULLABLE

8 The % of disk usage per node or AMP. For node-level displays, this value is computed from ResUsageSldv table data as follows, assuming n is the number of ldv controllers used by this node:

(LdvOutReqTime 1 + ... + LdvOutReqTime n) / (n*SampleSec)

For vproc-level displays, this value is computed from the ResUsageSvdsk table data, assuming it is the number of logical devices used by this AMP:

(OutReqTime 1 + ... + OutReqTime n) / SampleSec

Note: DiskUse does not take into account overlapping of operations among multiple storage controllers, but it allows for the possibility of multiple requests for the same controller.

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

Column Name Data TypeLength (Bytes) Description

Page 173: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

Workload Management API: PM/API and Open API 173

CICUse FLOAT,NULLABLE

8 This field is obsolete.

DiskReads FLOAT,NULLABLE

8 The total number of physical disk reads per node or AMP during the sample period.

The total number of physical disk reads per node or AMP during the sample period. For node-level displays, this value is computed from ResUsageSpma table data as:

MemTextPageReads + MemCtxtPageReads + MemSwapReads + FileAcqReads

Note: You can determine node-level DiskReads by summing the vproc level values across all vprocs on a given node with the MemTextPageReads value for that node.

For vproc-level displays, this value is computed from the ResUsageSvpr table data as:

MemCtxtPageReads + MemSwapReads + FilePCiAcqReads + FilePDbAcqReads + FileSCiAcqReads + FileSDbAcqReads + FileTJtAcqReads + FileAPtAcqReads

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

Column Name Data TypeLength (Bytes) Description

Page 174: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

174 Workload Management API: PM/API and Open API

DiskWrites FLOAT,NULLABLE

8 The total number of physical disk writes per node or AMP during the sample period. For node-level displays, this value is computed from ResUsageSpma table data as:

MemCtxtPageWrites + FileWrites

Note: For the total number of node-level DiskWrites, add all the vproc values across all AMPs on a given node.

For PE and AMP-level displays, this value is computed from ResUsageSvpr table data as:

MemCtxtPageWrites + FilePCiFWrites + FilePDbFWrites + FileSCiFWrites + FileSDbFWrites + FileTJtFWrites + FileAPtFWrites + FilePCiDyAWrites + FilePDbDyAWrites + FileSCiDyAWrites + FileSDbDyAWrites + FileTJtDyAFWrites + FileAPtDyAWrites

For VSS vproc displays, this value is computed from ResUsageSvpr table data as:

AllocatorMapIOsDone

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made during the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Column Name Data TypeLength (Bytes) Description

Page 175: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

Workload Management API: PM/API and Open API 175

DiskOutReqAvg FLOAT,NULLABLE

8 The average number of outstanding disk requests.

For node-level displays, this value is computed from ResUsageSldv table data as follows, assuming n is the number of ldv controllers used by this node:

(LdvOutReqSum 1 + ... + LdvOutReqSum n) / collectintervals

For PE and AMP-level displays, this value is computed from ResUsageSvdsk table data, assuming n is the number of storage devices used by this vproc:

(ReadRespTot 1 + WriteRespTot 1 + ... + ReadRespTot n + WriteRespTot n) / SampleSec

For VSS vproc displays, this value is computed from ResUsageSvpr table data as:

AllocatorMapIOsStarted - AllocatorMapIOsDone

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Column Name Data TypeLength (Bytes) Description

Page 176: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

176 Workload Management API: PM/API and Open API

HostBlockReads FLOAT,NULLABLE

8 The number of message blocks (one or more messages sent in one physical group) received from all clients. For node-level displays, this value is computed from ResUsageShst data, assuming n is the number of vprocs on this node:

HostBlockReads1 + ... + HostBlockReadsn

For vproc-level displays, this value corresponds to the column totals in the DBC.ResUsage.Shst table supplying HostBlockReads for this vproc.

This value is NULL for:

• Down or offline nodes or PEs.

• AMPs.

• A request for data that is made before completion of the first sample period following a system outage.

• Nodes. A request for data that is made before the completion of the first sample period following a change in the ResMonitor rate.

• PEs. A request for data that is made before the completion of the first sample period following a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

HostBlockWrites FLOAT,NULLABLE

8 The number of message blocks (that is, one or more messages sent in one physical group) sent to all hosts. For node displays, this value is computed from ResUsageShst data, assuming n is the number of PEs on this node:

HostBlockWrites1 + ... + HostBlockWritesn

For PE display, this value corresponds to the column totals in the DBC.ResUsageShst table with the same names.

This value is NULL if:

• Nodes or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For PEs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

Column Name Data TypeLength (Bytes) Description

Page 177: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

Workload Management API: PM/API and Open API 177

MemAllocates FLOAT,NULLABLE

8 The number of segments allocated to memory resources. This value corresponds to the ResUsageSpma and ResUsageSvpr table columns with the same name.

This value is NULL if:

• Nodes or Vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For vprocs a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

MemAllocateKB, MemAllocates, MemFailures, and MemAgings together indicate if memory resources are taxed, and may assist in determining if more memory is needed.

MemAllocateKB FLOAT,NULLABLE

8 The number of KB allocated to memory resources. For node-level displays, the value is computed from the ResUsageSpma table data as:

fixed_pg_size * (MemCtxtAllocs + MemPDbAllocKB + MemPCiAllocKB + ... + MemAPtAllocKB)

Note: You can determine the node-level value, MemVprAllocKB, by summing vproc-level values across all vprocs on a given node.

For vproc-level displays the value is computed from the ResUsageSvpr table data as:

fixed_pg_size * (MemCtxtAllocs + MemPDbAllocKB + MemPCiAllocKB + ... + MemAPtAllocKB)

Column Name Data TypeLength (Bytes) Description

Page 178: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

178 Workload Management API: PM/API and Open API

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For vprocs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

For vproc-level displays, this value is computed from the ResUsageSvpr table data as:

MemCtxtAllocs + MemPDbAllocs + MemPCiAllocs + MemSDbAllocs + MemSCiAllocs + MemTJtAllocs + MemAPtAllocs

PercentService FLOAT,NULLABLE

8 The % of CPU resources spent in UNIX/PDE user service processing. For node-level displays, the value is computed from the ResUsageSpma table data, where x represents the number of CPUs:

CPUUServ * (x * SampleSec)

For vproc-level displays, the value is computed from the ResUsageSvpr table data, where x represents the number of CPUs:

(CPUUServPart00 + CPUUServPart01 + ... + CPUUServPart15)* / (x * SampleSec)

This value is NULL if:

• Nodes, AMPs, or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

Column Name Data TypeLength (Bytes) Description

Page 179: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

Workload Management API: PM/API and Open API 179

PercntAMPWT FLOAT,NULLABLE,range 0 - 100%

8 The % of CPU resources used by either the AMP Worker Task (Partition 11) or by the VSS Task (Partition 31) depending on the type of vproc this record represents. For information on partition assignments, see Resource Usage Macros and Tables.

This value depends on the number of CPUs on the node but does not exceed 100%. It is computed from the ResUsageSvpr table data, where x represents the number of CPUs on a node:

For AMP vprocs:

CPUUExecPart11 * 100.00 / (x * SampleSec)

For VSS vprocs:

CPUUExecPart31 * 100.00 / (x * SampleSec)

The value is NULL for:

• PEs.

• Down or offline vproc.

• A request for data that is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

PercntParser FLOAT,NULLABLE,range 0 - 100%

8 The % of CPU resources spent in PE Parser processing. This value depends on the number of CPUs on the node but does not exceed 100%. The value is computed from the ResUsageSvpr table data, where x represents the number of CPUs on a node:

CPUUExecPart14 * 100.00/(x * SampleSec)

This value is NULL for:

• AMPs.

• Down or offline PEs.

• A request for data that is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

Column Name Data TypeLength (Bytes) Description

Page 180: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

180 Workload Management API: PM/API and Open API

PercntDispatcher FLOAT,NULLABLE,range 0 - 100%

8 The % of CPU resources spent in PE Dispatcher processing. This value depends on the number of CPUs on the node but does not exceed 100%. This value is computed from the ResUsageSvpr table data, where x represents the number of CPUs on a node:

CPUUExecPart13 * 100.00 /(x * SampleSec)

This value is NULL for:

• AMPs.

• Down or offline PEs.

• A request for data that is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

NetReads FLOAT,NULLABLE

8 The number of Reads from the BYNET to the node or vproc during the sample period. For node-level displays, this value is computed from the ResUsageSpma table data as:

Netrxcircbrd + Netrxcircptp

For vproc-level displays, the value is computed from the ResUsageSvpr table data as:

NetBrdReads + NetPtPReads

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

Column Name Data TypeLength (Bytes) Description

Page 181: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

Workload Management API: PM/API and Open API 181

NetWrites FLOAT,NULLABLE

8 The number of messages written from the node, AMP, or PE to the BYNET during the sample period. For node-level displays, the value is computed from the ResUsageSpma table data as:

Nettxcircbrd + Nettxcircptp

For vproc-level displays, the value is computed from the ResUsageSvpr table data as:

NetBrdWrites + NetPtPWrites

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

Column Name Data TypeLength (Bytes) Description

Page 182: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

182 Workload Management API: PM/API and Open API

NVMemAllocSegs FLOAT,NULLABLE

8 The number of complete and partial nonvolatile memory allocations of disk segments read (written) for backup storage during the sample period.

For node-level displays, the value is computed from ResUsageSpma table data as:

MemPDbBackCReads + MemPCiBackCReads + MemSDbBackCReads + MemSCiBackCReads + MemTJtBackCReads + MemAPtBackCReads + MemPDbBackPReads + MemPCiBackPReads + MemSDbBackPReads + MemSCiBackPReads + MemTJtBackPReads + MemAPtBackPReads

For vproc-level displays, the value is computed from ResUsageSvpr table data using:

• On MP-RAS, the following calculation:

MemPDbBackCWrites + MemPCiBackCWrites + MemSDbBackCWrites + MemSCiBackCWrites + MemTJtBackCWrites + MemAPtBackCWrites + MemPDbBackPWritets + MemPCiBackPWrites + MemSDbBackPWrites + MemSCiBackPWrites + MemTJtBackPWrites + MemAPtBackPWrites

• On Windows and Linux:

Svpr_IoRespMax MaxIOTime (the maximum I/O response time in milliseconds number of milliseconds caused by long I/O (Reads, Writes) operations for each AMP vproc on that node). For details, see Resource Usage Macros and Tables.

This value is NULL if:

• Nodes, AMPs, or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

Note: This field is called “Max I/O Time” in PMON and “Maximum I/O Time” in Teradata Manager.

This field is not applicable to VSS vprocs.

Column Name Data TypeLength (Bytes) Description

Page 183: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

Workload Management API: PM/API and Open API 183

Sample Input

This example shows how the parcels for a MONITOR VIRTUAL RESOURCE request built by CLIv2 look when sent to the Teradata Database server. The size of the response buffer is set in the example at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

This example shows the values returned in character text format (a record for each vproc) for the MONITOR VIRTUAL RESOURCE request. Your application program may display returned values in a different format.

Pay attention to SampleSec when interpreting the results of this request.

VprocNo: 0 Vproctype: AMP Status: UProcId: 134 HostId/ClusterNo: 0

SessLogCount: 0 SessRunCount: 0

CPUUse: 22.1 PctService: 0.8PctAMPWT: 21.3 DiskUse: 98.3DiskReads: 5.00 DiskWrites: 3971.00 DiskOutReqAvg: 8.31

NetReads: 248.00 NetWrites: 248.00NVMemAllocSegs: 0.00

VprocNo: 1 Vproctype: AMP Status: UProcId: 134 HostId/ClusterNo: 1

SessLogCount: 0 SessRunCount: 0

CPUUse: 21.4 PctService: 0.8PctAMPWT: 20.7 DiskUse: 95.9DiskReads: 4.00 DiskWrites: 3821.00 DiskOutReqAvg: 8.82

NetReads: 238.00 NetWrites: 238.00NVMemAllocSegs: 0.00

VprocNo: 2 Vproctype: AMP Status: UProcId: 134 HostId/ClusterNo: 0

SessLogCount: 0 SessRunCount: 0

CPUUse: 22.2 PctService: 0.7PctAMPWT: 21.5 DiskUse: 98.1DiskReads: 3.00 DiskWrites: 3913.00 DiskOutReqAvg: 8.11

Flavor Length Body

Num Name Bytes Field Char/Decimal

0001 Req 28 Request MONITOR VIRTUAL RESOURCE

0003 Data 6 MonVerID 2

0004 Resp 6 BufferSize 32731

Page 184: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

184 Workload Management API: PM/API and Open API

NetReads: 244.00 NetWrites: 244.00NVMemAllocSegs: 0.00

VprocNo: 3 Vproctype: AMP Status: UProcId: 134 HostId/ClusterNo: 1

SessLogCount: 0 SessRunCount: 0

CPUUse: 22.0 PctService: 0.9PctAMPWT: 21.2 DiskUse: 99.3DiskReads: 5.00 DiskWrites: 3902.00 DiskOutReqAvg: 8.89

NetReads: 244.00 NetWrites: 243.00NVMemAllocSegs: 0.00

VprocNo: 10237 Vproctype: VSS Status: UProcId: 135 HostId/ClusterNo: 0

SessLogCount: 1

CPUUse: 0.0 PctService: 0.0CPUExecPart31: 0.0 DiskUse: 0.0AllocatorMapIOsDone: 0.00 PendingAllocatorMapIOs: 0.00

NetReads: 0.00 NetWrites: 0.00NVMemAllocSegs: 0.00

VprocNo: 10238 Vproctype: VSS Status: UProcId: 134 HostId/ClusterNo: 0

SessLogCount: 0

CPUUse: 0.5 PctService: 0.3CPUExecPart31: 0.3 DiskUse: 0.0AllocatorMapIOsDone: 492.00 PendingAllocatorMapIOs: 0.00

NetReads: 493.00 NetWrites: 493.00NVMemAllocSegs: 0.00

VprocNo: 16380 Vproctype: PE Status: UProcId: 135 HostId/ClusterNo: 1025

SessLogCount: 1 SessRunCount: 0

CPUUse: 0.0 PctService: 0.0PctParser: 0.0 PctDispatcher: 0.0 CICUse: 0.0HstBlkRds: 0.00 HstBlkWrts: 0.00

NetReads: 7.00 NetWrites: 6.00NVMemAllocSegs: 0.00

VprocNo: 16381 Vproctype: PE Status: UProcId: 135 HostId/ClusterNo: 1025

SessLogCount: 0 SessRunCount: 0

CPUUse: 0.0 PctService: 0.0PctParser: 0.0 PctDispatcher: 0.0 CICUse: 0.0

Page 185: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

Workload Management API: PM/API and Open API 185

HstBlkRds: 0.00 HstBlkWrts: 0.00

NetReads: 1.00 NetWrites: 1.00NVMemAllocSegs: 0.00

VprocNo: 16382 Vproctype: PE Status: UProcId: 134 HostId/ClusterNo: 1025

SessLogCount: 0 SessRunCount: 0

CPUUse: 0.0 PctService: 0.0PctParser: 0.0 PctDispatcher: 0.0 CICUse: 0.0HstBlkRds: 0.00 HstBlkWrts: 0.00

NetReads: 0.00 NetWrites: 0.00NVMemAllocSegs: 0.00

VprocNo: 16383 Vproctype: PE Status: UProcId: 134 HostId/ClusterNo: 1025

SessLogCount: 1 SessRunCount: 0

CPUUse: 0.0 PctService: 0.0PctParser: 0.0 PctDispatcher: 0.0 CICUse: 0.0HstBlkRds: 0.00 HstBlkWrts: 0.00

NetReads: 0.00 NetWrites: 0.00NVMemAllocSegs: 0.00

Warning and Error Messages

All users who are logged on and issue a MONITOR VIRTUAL RESOURCE request after a system restart, or after the last rate change can expect to receive a warning message. Generally, two types of situations can produce warning messages:

• After a system restart, before and after a sample period has expired.

If the sample period has not expired and the user issues the next MONITOR VIRTUAL RESOURCE request, many of the values returned are NULL.

• After the last rate change, before and after a sample period has expired.

If the sample period has not expired and the user issues the next MONITOR VIRTUAL RESOURCE request, many of the values returned are NULL.

In addition, these specific messages may be returned by the MONITOR VIRTUAL RESOURCE request:

Message Number Description

3271 Data Unavailable: Resource Usage Sampling is not currently enabled.

Remedy: Set the ResMonitor Rate to a valid non-zero value, wait for at least one collection period to expire, and resubmit this request.

Page 186: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

186 Workload Management API: PM/API and Open API

For a discussion of general warning and error messages that may be returned by MONITOR VIRTUAL RESOURCE and other requests, see “Common Warning and Error Messages” on page 50.

For more detailed information on warning and error messages, see Messages.

Relationship Between MONITOR VIRTUAL RESOURCE andABORT SESSION

For information on this PMPC CLIv2 interface relationship, see “Relationship Between ABORT SESSION and MONITOR VIRTUAL RESOURCE” on page 66.

Relationship Between MONITOR VIRTUAL RESOURCE andSET RESOURCE RATE

You must execute the SET RESOURCE RATE request to activate vproc resource data collection before you execute a MONITOR VIRTUAL RESOURCE or MONITOR PHYSICAL RESOURCE request. This means that you must set the resource monitoring rate (VProcMonitor) to nonzero. If the VProcMonitor rate is zero, you will receive the error message:

Data unavailable: No vproc resource usage sampling currently active.

A change in the resource collection rate by User A, for example, may affect the data reported by MONITOR VIRTUAL RESOURCE or MONITOR PHYSICAL RESOURCE request made

3272 Warning: Resource Data is incomplete for one of the following reasons:

• The system has gone through recovery and a full collection period has not expired since.

• The Resource Monitor Rate has been changed and a full collection period has not expired since.

• For the MONITOR SUMMARY request only, Resource Monitoring is not enabled.

Remedy: Wait for a full collection period to expire and resubmit the request, or in the case of a MONITOR SUMMARY request when the Resource Monitoring is not enabled, set the ResMonitor Rate to a valid non-zero value, wait for at least one collection period to expire, and resubmit this request.

3273 Warning: Resource Monitoring Rate has been altered.

Remedy: This warning is informational.

3289 Invalid Rate: The Logging Sample Rate must be an integral multiple of the Monitoring Sample Rate.

Remedy: Select an acceptable rate that fits the criterion and resubmit the request.

3290 The VIRTUAL CHANGE option must have a value of Y, y, N, n, BLANK, or NULL.

Remedy: Correct the error and resubmit the request.

Message Number Description

Page 187: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL RESOURCE

Workload Management API: PM/API and Open API 187

by User B. If the resource monitoring rate has been altered, User B receives the following warning message upon executing a subsequent MONITOR VIRTUAL RESOURCE or MONITOR PHYSICAL RESOURCE request:

Warning: Resource monitoring rate has been altered.

Relationship Between MONITOR VIRTUAL SUMMARY and ABORT SESSION

For information on this PMPC CLIv2 interface relationship, see “Relationship Between ABORT SESSION and MONITOR VIRTUAL SUMMARY” on page 66.

Relationship Between MONITOR VIRTUAL SUMMARY and SET RESOURCE RATE

The SET RESOURCE RATE request sets the VProcMonitor and VProcLogging rates, which are among the responses returned by the MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY request. Any change to either the VProcMonitor or VProcLogging rate results in changes in the corresponding response returned by the MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY request.

You must set VProcMonitor to a nonzero rate for MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY to return meaningful vproc utilization data. A zero VProcMonitor rate returns NULL values for vproc utilization information.

Relationship Between MONITOR VIRTUAL SUMMARY andSET SESSION RATE

Changes to the session-level rates (system and local) specified by SET SESSION RATE are reported in the data returned by MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY.

Note: The local rate reported is your own local rate. If the local rate is not set, the local rate is reported as zero.

As more session-level monitoring is done (by setting a faster SET SESSION RATE), the resulting overhead may increase the level of CPU usage (reported in MONITOR VIRTUAL SUMMARY or MONITOR PHYSICAL SUMMARY data) by your system. However, this may depend on the size of the rate change and the type of work done by other sessions.

Relationship Between MONITOR VIRTUAL SUMMARY and MONITOR VIRTUAL CONFIG

For information on this PMPC CLIv2 interface relationship, see “Relationship Between MONITOR VIRTUAL CONFIG and MONITOR VIRTUAL SUMMARY” on page 165.

Page 188: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL SUMMARY

188 Workload Management API: PM/API and Open API

MONITOR VIRTUAL SUMMARY

PurposeCollects global summary information on system utilization.

Input Data

Monitor Privileges

Unless monitor privileges have been established as part of the default role for the user, users must set a session role before exercising any of the monitor privileges for that role. If the current role is a specified non-NULL role, the user may be able to utilize monitor privileges via the current role or its nested roles. If the current role is ALL, the user may be able to use monitor privileges via any roles directly and indirectly granted. For more information, see Database Administration and Security Administration.

Usage Notes

The MONITOR VIRTUAL SUMMARY request reports the following types of information:

• CPU usage: average by vproc type (online only)

• Disk usage: average, high, and low, by vproc ID

• AMP usage: average, high, and low, by AMP ID

• PE usage: average, high, and low, by PE ID

• Number of logged on sessions

• Rate information: vproc resource logging rate, vproc resource usage monitoring rate, session-level system and local monitoring rates

Element Data TypeLength(Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Page 189: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL SUMMARY

Workload Management API: PM/API and Open API 189

• Current software release and version numbers

A user must have any one of the following MONITOR privileges to execute the MONITOR VIRTUAL SUMMARY request:

• ABORTSESSION

• MONRESOURCE

• MONSESSION

• SETRESRATE

• SETSESSRATE

You must set the VProcMonitor rate (the rate at which vproc resource usage data is updated within memory) to a nonzero value for the MONITOR VIRTUAL SUMMARY request to return meaningful data. If you set the VProcMonitor rate to zero, NULL values are returned for all columns related to vproc utilization.

After a system outage or a change in the VProcMonitor rate, do not request data again until after the completion of the first sample period requested after the outage or change in rate. If you ignore this, the data returned contains NULL values and may not be fully representative. This is because after an outage, the in-memory counters are reset, and usually the contents of the counters are not well defined until a full sample period has elapsed. For example, if you were logged on prior to the system outage and you issue your first MONITOR VIRTUAL SUMMARY request after the outage, you will receive a warning that the Teradata Database server has been restarted.

Parcels

The response returned from the Teradata Database resembles a summary of the type of response returned by a MONITOR VIRTUAL RESOURCE request. The response is one row of 35 fields.

The response returned from the Teradata Database contains the following sequence of parcel types.

Parcel Sequence

Parcel Flavor

Length(Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 ActivityCount =1

ActivityType = 93 (PCLMONVSUMMARY)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This contains the IndicData virtual summary information.

EndStatement 11 6 StatementNo = 2-byte integer

Page 190: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL SUMMARY

190 Workload Management API: PM/API and Open API

The Record parcel in the MONITOR VIRTUAL SUMMARY response returns the following resource usage information.

EndRequest 12 4 None

Field Name Data Type/RangeLength(Bytes) Description

AMPAvgCPU FLOAT, NULLABLE, range 0 to 100%

8 The average % CPU usage (CPUUse) of all online AMPs in the configuration.

This value is NULL if:

• The VProcMonitor rate (the rate at which resource data is updated within memory) is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Assuming n is the number of online AMPs in the configuration, AMPAvgCPU is computed from CPUUse data as:

(CPUUse1 + ... + CPUUsen) / n

AMPAvgDisk FOAT, NULLABLE

The average physical disk usage (DiskUse) of all online AMPs in the configuration.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Assuming n is the number of online AMPs in the configuration, AMPAvgDisk is computed from DiskUse data as:

(DiskUse1 + ... + DiskUsen) / n

Parcel Sequence

Parcel Flavor

Length(Bytes) Comments/Key Parcel Body Fields

Page 191: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL SUMMARY

Workload Management API: PM/API and Open API 191

AMPAvgDiskIO FLOAT, NULLABLE

8 The average physical disk DiskReads and DiskWrites of all online AMPs in the configuration.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period that following either a system outage or a change in the VProcMonitor rate.

Assuming n is the number of online AMPs in the configuration, AMPAvgDiskIO is computed from DiskReads and DiskWrites data as:

(DiskReads1 + DiskWrites1 + ... + DiskReads1 + DiskWritesn) / n

HiCPUAMPUse FLOAT, NULLABLE

8 The highest CPUUse percentage currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiCPUAMPNo SMALLINT, NULLABLE

2 The VProcNo of an AMP with CPUUse equal to the value reported as HiCPUAMPUse.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiCPUAMPProc SMALLINT, NULLABLE

2 The ID of the node currently responsible for managing the AMP reported as HiCPUAMPNo.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Field Name Data Type/RangeLength(Bytes) Description

Page 192: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL SUMMARY

192 Workload Management API: PM/API and Open API

LoCPUAMPUse FLOAT, NULLABLE

8 The lowest CPUUse percentage currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• The request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoCPUAMPNo SMALLINT, NULLABLE

2 The VProcNo of an AMP with CPUUse equal to the value reported as LoCPUAMPUse.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoCPUAMPProc SMALLINT, NULLABLE

2 The ID of the node currently responsible for managing the AMP reported as LoCPUAMPNo.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiDiskAMP FLOAT, NULLABLE

8 The highest DiskUse percentage currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiDiskAMPNo SMALLINT, NULLABLE

2 The number of an AMP with DiskUse equal to the value reported as HiDiskAMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Field Name Data Type/RangeLength(Bytes) Description

Page 193: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL SUMMARY

Workload Management API: PM/API and Open API 193

HiDiskAMPProc SMALLINT, NULLABLE

2 The ID of the node currently responsible for managing the AMP reported in HiDiskAMPNo.

The value is NULL when HiDiskAMPNo is NULL.

LoDiskAMP FLOAT, NULLABLE

8 The lowest DiskUse percentage currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoDiskAMPNo SMALLINT, NULLABLE

2 The number of an AMP with DiskUse equal to the value reported as LoDiskAMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoDiskAMPProc SMALLINT, NULLABLE

2 The ID of the node currently responsible for managing the AMP reported as LoDiskAMPNo.

This value is NULL when LoDiskAMPNo is NULL.

HiDiskAMPIO FLOAT, NULLABLE

8 The highest DiskReads and DiskWrites value currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Field Name Data Type/RangeLength(Bytes) Description

Page 194: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL SUMMARY

194 Workload Management API: PM/API and Open API

HiDiskAMPIONo SMALLINT, NULLABLE

2 The number of an AMP with the highest DiskReads and DiskWrites equal to the value reported as HiDiskAMPIO.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiDiskAMPIOProc SMALLINT, NULLABLE

2 The ID of the node currently responsible for managing the AMP reported in HiDiskAMPIONo.

This value is NULL when HiDiskAMPIONo is NULL.

LoDiskAMPIO FLOAT, NULLABLE

8 The lowest DiskReads and DiskWrites number currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoDiskAMPIONo SMALLINT, NULLABLE

2 The ID of an AMP with lowest DiskReads and DiskWrites equal to the value reported as LoDiskAMPIO.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoDiskAMPIOProc SMALLINT, NULLABLE

2 The ID of the node currently responsible for managing the AMP reported as LoDiskAMPIONo.

This value is NULL when LoDiskAMPIONo is NULL.

Field Name Data Type/RangeLength(Bytes) Description

Page 195: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL SUMMARY

Workload Management API: PM/API and Open API 195

PEAvgCPU FLOAT, NULLABLE

8 The average CPUUse for all online PEs in the configuration.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiCPUPEUse FLOAT, NULLABLE

8 The highest CPUUse percentage currently associated with any online PE.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiCPUPENo SMALLINT, NULLABLE

2 The VProcNo of a PE with CPUUse equal to the value reported as HiCPUPEUse.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiCPUPEProc SMALLINT, NULLABLE

2 The ID of the node currently responsible for managing the PE reported in HiCPUPENo.

This value is NULL when HiCPUPENo is NULL.

LoCPUPEUse FLOAT, NULLABLE

8 The lowest CPUUse percentage currently associated with any online PE.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoCPUPENo SMALLINT, NULLABLE

2 The VProcNo of a PE with CPUUse equal to the value reported as LoCPUPEUse.

This value is NULL when LoCPUPEUse is NULL.

Field Name Data Type/RangeLength(Bytes) Description

Page 196: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL SUMMARY

196 Workload Management API: PM/API and Open API

LoCPUPEProc SMALLINT, NULLABLE

2 The ID of the node currently responsible for managing the PE reported as LoCPUPENo.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

SessLogCount FLOAT, NULLABLE

8 The total number of sessions currently logged onto the system. This value is usually equal to the sum of the SessLogCount values for all PEs.

This value is NULL if:

• VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

SesMonitorSys SMALLINT, range 0-3600 seconds

2 The system-wide monitoring rate at which session-level statistics are collected within memory for reporting via the PM/API. This system rate is the default sampling rate for all MONITOR sessions. A rate of zero turns off the sampling capability.

This rate can be changed with the SET SESSION RATE request by specifying a system-wide option and can be saved on disk (in the version record) when it is changed.

SesMonitorLoc SMALLINT, range 0-3600 seconds

2 The local monitoring rate at which session-level statistics are collected within memory for reporting via the PM/API. This rate is initiated within a MONITOR session and may update session-level data within the system. A rate of zero allows SesMonitorSys to override the current local rate for that session.

This rate can be changed with the SET SESSION RATE request by specifying the a LOCAL rate change option and can be saved on disk and may be lost during a system outage.

Field Name Data Type/RangeLength(Bytes) Description

Page 197: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL SUMMARY

Workload Management API: PM/API and Open API 197

Sample Input

This example shows how the parcels for a MONITOR VIRTUAL SUMMARY request built by CLIv2 look when sent to the Teradata Database. The size of the response buffer in the example is set at the maximum (32,731 bytes), although you can set it to any size.

VprocLogging SMALLINT, range 0- 3600 seconds

2 The rate, in seconds, at which AMP and PE resource usage data is written to the applicable ResUsageXyyy tables. A rate of zero turns off the logging capability.

This rate can be changed with the SET RESOURCE RATE request. This rate is saved on disk (in the version record) when it is changed.

VprocMonitor CHAR 3 The rate, in seconds, at which AMP and PE resource usage data is written to the applicable ResUsageXyyy tables. A rate of zero turns off the logging capability.

This rate can be changed with the SET RESOURCE RATE request. This rate is saved on disk (in the version record) when it is changed.

Release CHAR 29 The release number of the currently running Teradata Database software (for example, 13.00.00.00).

This value is supplied by Teradata Database.

Version CHAR 32 The version number of the currently running Teradata Database software (for example, 13.00.00.00).

This value is supplied by Teradata Database.

Field Name Data Type/RangeLength(Bytes) Description

Flavor Length Body

Num Name Bytes Field Value

0001 Req 27 Request MONITOR VIRTUAL SUMMARY

0003 Data 6 MonVerID 2

0004 Resp 6 BufferSize 32731

Page 198: Workload management api

Chapter 3: PMPC APIsMONITOR VIRTUAL SUMMARY

198 Workload Management API: PM/API and Open API

Sample Output

This example shows the values returned in character text format for the MONITOR VIRTUAL SUMMARY request. Your application program may display returned values in a different format.

Success parcel:StatementNo: 1 ActivityCount: 1ActivityType: 93 FieldCount: 35

DataInfo parcel:FieldCount: 35

Record parcel.Parcel flavor: 10 Parcel body length: 211AMPAvgCPU = 0.0%, AMPAvgDisk = 0.0%, AMPAvgDiskIO = 0.0,HiCPUAMPUse = 0.0%, HiCPUAMPNo = 15, HiCPUAMPProc = 736,LoCPUAMPUse = 0.0%, LoCPUAMPNo = 0, LoCPUAMPProc = 746, HiDiskAMP =

0.0%,HiDiskAMPNo = 15, HiDiskAMPProc = 736, LoDiskAMP = 0.0%, LoDiskAMPNo

= 0,LoDiskAMPProc = 746, HiDiskAMPIO = 0.0, HiDiskAMPIONo = 15,HiDiskAMPIOProc = 736, LoDiskAMPIO = 0.0, LoDiskAMPIONo = 0,LoDiskAMPIOProc = 746, PEAvgCPU = 0.0%, HiCPUPEUse = 0.0%,HiCPUPENo = 1023, HiCPUPEProc = 736, LoCPUPEUse = 0.0%, LoCPUPENo =

1020,LoCPUPEProc = 746, SessionCount = 3.0, SesMonitorSys = 0,SesMonitorLoc = 6, VProcLogging = 600, VProcMonitor = 10,Release = "13.00.00.00",Version = "13.00.00.00".

EndStatement.EndRequest.

Warning and Error Messages

MONITOR VIRTUAL SUMMARY may produce the warning messages described in this section. All users who are logged on and issue a MONITOR VIRTUAL SUMMARY request after a system restart or after the last rate change can expect to receive one of the warnings. Typically, the types of situations that can produce warning messages are:

• After a system restart, before and after a sample period has expired.

If the sample period has not expired and the user issues the next MONITOR VIRTUAL SUMMARY request, many of the values returned are NULL.

• After the last rate change, before and after a sample period has expired.

If the sample period has not expired and the user issues the next MONITOR VIRTUAL SUMMARY request, many of the values returned are NULL.

• If the resource usage sampling rate (VProcMonitor) is not enabled, that is, if rate is set to zero. When the user issues the next MONITOR VIRTUAL SUMMARY request, many of the values returned are NULL.

Page 199: Workload management api

Chapter 3: PMPC APIsSET RESOURCE RATE

Workload Management API: PM/API and Open API 199

SET RESOURCE RATE

PurposeSets either the resource monitoring or logging rate.

Input Data

ElementData Type/Range

Length(Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

sample_rate SMALLINT, range 0-3600 secs

2 The value of the sample rate, used either to sample resource usage sampling or to log resource usage data to the resource usage tables.

Each logging rate must be an integral multiple of the non-zero monitoring rate.

Note: The value must be an integral divisor of 3600.

Specify a resource monitoring rate value if you want to change the resource monitoring rate. Specify a logging rate value if you want to write resource usage data to disk. Specify zero to turn off resource monitoring or logging.

log_change CHAR, NULLABLE

1 Indicator of whether this rate applies to logging or monitoring. Specify Y or y for logging rate. Specify N, n, NULL, or blank for monitoring rate.

virtual_change CHAR, NULLABLE

1 Indicator of whether this rate applies to vproc or node. Specify Y or y for vproc. Specify N, n, NULL, or blank for node.

Page 200: Workload management api

Chapter 3: PMPC APIsSET RESOURCE RATE

200 Workload Management API: PM/API and Open API

Usage Notes

The following table describes the different rates that can be set by the SET RESOURCE RATE request.

Monitoring and logging are independent of each other because you can monitor without wanting to log to the ResUsage tables, or you can log without monitoring.

Note: You can only set one resource monitoring or logging rate within one SET RESOURCE RATE request. For example, to set both the vproc monitoring and vproc logging rates at the

The rate... Sets the...

VProcMonitor vproc-level collection rate. Use this rate to set the maximum frequency at which vproc resource data is updated within memory.

The resource monitoring rate is returned as a VProcMonitor data value in a MONITOR VIRTUAL SUMMARY request. For details, see “MONITOR VIRTUAL SUMMARY” on page 188.

Note: The VProcMonitor and the ResMonitor Rates are no longer independent rate settings. When one rate is set, the other rate will default to the same setting.

VProcLogging rate at which vproc-level resource usage data is written to one or more active ResUsage database tables. The ResUsage tables are named DBC.ResUsageXyyy, where Xyyy is Sawt, Svpr, Sldv, and so forth. For more information, see Resource Usage Macros and Tables.

The resource logging rate is returned as a VProcLogging data value in a MONITOR VIRTUAL SUMMARY request. For details, see “MONITOR VIRTUAL SUMMARY” on page 188.

Note: The logging rates must be set at an integer multiple of the smallest collection. The logging rate cannot be less than the corresponding collection rate.

ResMonitor node-level collection rate. Use this rate to set the maximum frequency at which node resource data is updated within memory.

The resource monitoring rate is returned as a ResMonitor data value in a MONITOR PHYSICAL SUMMARY request. For details see “MONITOR PHYSICAL SUMMARY” on page 108.

Note: The VProcMonitor and the ResMonitor Rates are no longer independent rate settings. When one rate is set, the other rate will default to the same setting.

ResLogging frequency at which node resource usage data is written to one or more active ResUsage database tables. The node ResUsage tables are named DBC.ResUsageXyyy, where Xyyy is Spma and Scpu (see Resource Usage Macros and Tables). A rate of zero turns off logging capability.

The resource logging rate is returned as a ResLogging data value in a MONITOR PHYSICAL SUMMARY request. For details, see “MONITOR PHYSICAL SUMMARY” on page 108.

Note: The Virtual and Physical Resource rates must be the same, but not for the Logging rates.

Page 201: Workload management api

Chapter 3: PMPC APIsSET RESOURCE RATE

Workload Management API: PM/API and Open API 201

same time, you must issue two SET RESOURCE RATE requests and specify the USING Data String appropriately.

A user must have SETRESRATE privilege to execute the SET RESOURCE RATE request.

Node resource data is placed in a memory repository separate and independent from session usage data. Therefore, any changes in the resource monitoring rate does not impact session usage data.

Remember that node utilization data collected by the resource monitoring rate is collected and reported differently from session utilization data. Whereas session usage data is collected cumulatively, node resource data is collected for a particular sample period. The data reported is based on the activity that occurred during that sample period and does not include any cumulative data over sample periods.

There is a difference between saving statistics in the resource memory repository and returning the data for display. Resource usage data can be saved after a sampling interval is set to a nonzero rate, but no return of data occurs until a MONITOR request is issued. When this request is issued, the system clock is checked to determine the start time and how much interval time has expired. If the interval time has not expired, the data in the previous interval is displayed. If the interval time has expired, the last interval of data that has expired is displayed.

The resource monitoring rate (VProcMonitor for vprocs, and ResMonitor for node) and the logging rate (VProcLogging for vprocs, and ResLogging for node) are saved on disk in the Version Record when they are changed. For this reason, the SET RESOURCE RATE request can block if someone else is updating the GDO control record. If a block occurs, you must wait until the block clears.

Note: When you execute the SET RESOURCE RATE request, the change is saved in the DBC.SW_Event_Log table (accessible from the DBC.Software_Event_LogV view) and written to the system console running Database Windows.

Parcels

The response returned from Teradata Database contains the following sequence of parcel types.

Parcel Sequence

Parcel Flavor

Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 Activity Count = Contains previous rate.

Activity Type = 87 (PCLSETRESSR)

DataInfo 71 6 to 32004 This parcel is present if request was IndicReq parcel; depends on the data type.

EndStatement 11 6 StatementNo: 2-byte integer

EndRequest 12 4 None

Page 202: Workload management api

Chapter 3: PMPC APIsSET RESOURCE RATE

202 Workload Management API: PM/API and Open API

Sample Input

This example shows how the parcels for a SET RESOURCE RATE request built by CLIv2 look when sent to the Teradata Database server using a sample_rate of 600 seconds and a logging_change of Y. The size of the response buffer is set in the example at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

With a a sample_rate of 600 and a logging_change of y, this example shows the values returned in character text format for the SET RESOURCE RATE request. Your application program may display returned values in a different format.

Success parcel:StatementNo: 1 ActivityCount: 60ActivityType: 87 FieldCount: 0

DataInfo parcel:FieldCount: 0

EndStatement.EndRequest.

Warning and Error Messages

The following table lists error messages that a SET RESOURCE RATE request might return.

Flavor Length Body

Num Name Bytes Field Value

0001 Req 21 Request SET RESOURCE RATE

003 Data 11 MonVerID

SampleRate

LoggingChg

VirtualChg

2

600

Y

Y

0004 Resp 6 Buffer Size 32731

MessageNumber Description

3255 Invalid Rate: Must be from 0 to 3600, inclusive, or OFF.

Remedy: Correct the error and resubmit the request.

3262 The LOCAL CHANGE option must have a value of Y, y, N, n, BLANK, or NULL.

Remedy: Correct the error and resubmit the request.

3263 The LOGGING CHANGE option must have a value of Y, y, N, n, BLANK, or NULL.

Remedy: Correct the error and resubmit the request.

Page 203: Workload management api

Chapter 3: PMPC APIsSET RESOURCE RATE

Workload Management API: PM/API and Open API 203

For additional messages, see “Common Warning and Error Messages” on page 50; for detailed explanations, see Messages.

Relationship Between SET RESOURCE RATE and MONITOR PHYSICAL RESOURCE

For information on this PMPC CLIv2 interface relationship, see“Relationship Between MONITOR PHYSICAL RESOURCE and SET RESOURCE RATE” on page 106.

Relationship Between SET RESOURCE RATE and MONITOR VIRTUAL RESOURCE

For information on this PMPC CLIv2 interface relationship, see “Relationship Between MONITOR VIRTUAL RESOURCE and SET RESOURCE RATE” on page 186.

Relationship Between SET RESOURCE RATE andMONITOR PHYSICAL SUMMARY

For information on this PMPC CLIv2 interface relationship, see “Relationship Between MONITOR PHYSICAL SUMMARY and SET RESOURCE RATE” on page 106.

Relationship Between SET RESOURCE RATE andMONITOR VIRTUAL SUMMARY

For information on this PMPC CLIv2 interface relationship, see “Relationship Between MONITOR VIRTUAL SUMMARY and SET RESOURCE RATE” on page 187.

Page 204: Workload management api

Chapter 3: PMPC APIsSET SESSION ACCOUNT

204 Workload Management API: PM/API and Open API

SET SESSION ACCOUNT

PurposeUpgrades or downgrades the priority of requests made by a user, with ABORTSESSION privileges, for a specified session to any priority that exists on the system.

Input Data

ElementData Type/Range

Length(Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you ar e using Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

host_id SMALLINT, range 0-32767

2 The ID of the host upon which the session was issued. host_id cannot exceed 1023. A host_id of zero identifies the database operator console. If you do not specify a valid host_id, an error message is returned to CLIv2. Use only if you have DBA privileges.

session_no INTEGER, range 0-4294967295

4 The number of the session. session_no combined with the host_id produces a unique Session ID. If you do not specify a valid session_no, an error message is returned to CLIv2. Use only if you have DBA privileges.

account CHAR 30 Account string, including the priority of the session or request. You can adjust the priority to one higher or lower than that currently defined for the account. For example, if $Hacct is defined for a user, you can change the account/priority to $Macct or $Lacct. If you do not specify a valid account, an error message is returned to the CLI.

The new account takes effect immediately. If requests or steps are executing, they switch to the new account/priority.

Page 205: Workload management api

Chapter 3: PMPC APIsSET SESSION ACCOUNT

Workload Management API: PM/API and Open API 205

Usage Notes

A user must have the privileges to abort the session for another user (equivalent to the PM/API ABORTSESSION privilege).

The account/priority change is recorded in the DBC.SW_Event_Log table (accessible from the DBC.Software_Event_LogV view) with the following text in the TEXT column:

SESSION session_no HOSTID host_id CHANGED FROM ACCOUNT account TO ACCOUNT account ON sess_req

The EVENT_TAG field contains an event number. THEDATE and THETIME fields, which make up the index of the DBC.SW_Event_Log table (accessible from the DBC.Software_Event_LogV view), contain the date and time of the account/priority change. All other fields of the table are blank.

When Teradata Dynamic Workload Management Category 3 is enabled, the SET SESSION ACCOUNT request will:

• Fail and return an error.

For the resulting error code, see Teradata Dynamic Workload Manager User Guide.

• Or succeed for a session, but the request in which it is running will continue to run the old (existing) account string. Future requests will run with the new account string.

Parcels

The response returned from Teradata Database contains the following sequence of parcel types:

sess_req CHAR 1 Indicator of how the new account/priority affects requests for a specified session.

If you specify Y or y, the change applies to all current and future requests for a specified session. If no requests or steps are executing, the new account/priority takes effect at the next request, and the DBC.SessionTbl table reflects the new account/priority for the current session.

If you specify NULL, blank, N, or n, then the change applies to the current request for the specified session. If no request is executing, the next request for the specified session has the old account/priority.

ElementData Type/Range

Length(Bytes) Description

Parcel Sequence

Parcel Flavor

Length (Bytes) Comments/Key Parcel

Success 8 18 to 273 StatementNo = 1

ActivityCount = 1

ActivityType = 108 (SET SESSION ACCOUNT)

Page 206: Workload management api

Chapter 3: PMPC APIsSET SESSION ACCOUNT

206 Workload Management API: PM/API and Open API

The Data parcel sent from the host should be 39 bytes long for record mode or 40 bytes long for indicator mode.

The Record parcel returns the Old Account and Error Code columns.

Note: The Column Name and Column Contents field values are not returned in the Record parcel. These values are returned in an IDENTIFY request.

The Error Code column can contain any of the following return codes:

Sample Input

This is an example of the request parcels sent from a mainframe client. It shows how the parcels for a SET SESSION ACCOUNT request built by CLIv2 look when sent to the Teradata Database server, where account is $Haccnt, sess_req is Y, host_id is 348, and session_no is 1000.

In this sample, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicReq parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

This record contains the Old account, and an error code.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Error-Name Code Text

ErrPFMNoAr 3250 No access right.

ErrPFMBadSes 3256 User entered invalid session x HostId.

ErrPFMBadAcc 3292 User entered invalid account.

ErrPFMUpdSesTbl 3293 Failed to update the session table with the new account.

ErrPFMBadSesReqInd 3294 Invalid session/request indicator value for set session account.

ErrPFMInvSes 3295 Invalid session specified.

ErrPFMTimeOut 3296 Asynchronous account change time-out.

Parcel Sequence

Parcel Flavor

Length (Bytes) Comments/Key Parcel

Page 207: Workload management api

Chapter 3: PMPC APIsSET SESSION ACCOUNT

Workload Management API: PM/API and Open API 207

Sample Output

This sample shows typical values returned in character text format for SET SESSION ACCOUNT. Your application may return values in a different format.

Success Parcel:Statement No: 1Activity Count: 1Activity Type: 108FieldCount: 2DataInfo Parcel:Field Count: 2Record Parcel:Parcel Flavor: 10Parcel Body Length:32OldAcct: “$MAcct”, ErrorCode = 0EndStatement.EndRequest.

Warning and Error Messages

SET SESSION ACCOUNT may return one of the following:

Flavor Length Body

Num Name Bytes Field Value

0001 Req 22 Request SET SESSION ACCOUNT

0003 Data 45 MonVerID 2

HostId 348

SessionNo 1000

Account $Haccnt

Session/Request Indicator

Y

0004 Resp 6 BufferSize 32731

Message Number Description

3292 No such Account is currently logged on.

Remedy: Check the status of the account entered.

3293 Failure to update session table with new Account.

Remedy: Check the status of DBC.SessionTbl, then try the command again. If the command continues to fail, contact your support representative.

3294 Invalid Session/Request indicator value for SET SESSION ACCOUNT.

Remedy: Correct the error and resubmit the request.

3295 Invalid session specified.

Remedy: Correct the error and resubmit the request.

3296 PMPC request processing timed out.

Remedy: Retry or check the session itself.

Page 208: Workload management api

Chapter 3: PMPC APIsSET SESSION ACCOUNT

208 Workload Management API: PM/API and Open API

For additional messages, see “Common Warning and Error Messages” on page 50; for detailed explanations, see Messages.

Page 209: Workload management api

Chapter 3: PMPC APIsSET SESSION RATE

Workload Management API: PM/API and Open API 209

SET SESSION RATE

PurposeSets the system-wide and local rates for updating session-level statistics within memory.

Input Data

Usage Notes

A user must have SETSESSRATE privilege to execute the SET SESSION RATE request.

Changes to either the system or local rate can reset the starting point at which data is collected and may cause data to look different. Therefore, it is recommended that the SET SESSION RATE privilege be granted to a restricted number of users (such as DBAs or certain application programmers).

You can set the SET SESSION RATE request to either system-wide or local sampling rate:

ElementData Type/Range

Length(Bytes) Description

IndByte BYTE 1 The indicator bits that specify which fields to treat as Null if you are using Indicator mode.

Each bit in the byte corresponds to one field in the input data.

If data is supplied for that field, then set the bit to zero.

If the data for that field is Null (that is, there is no data supplied for that field), then set the bit to 1.

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 2, 3, 4, 5, 6, or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

sample_rate SMALLINT, range 0-3600 seconds

2 The value of the sample interval. When this rate is set to zero, the sampling capability is disabled.

local_change CHAR, NULLABLE

1 The type of session to which this rate change applies. Specify Y or y if the rate is set within a local session. Specify N, n, NULL, or blank if the rate applies to system-wide queries.

Page 210: Workload management api

Chapter 3: PMPC APIsSET SESSION RATE

210 Workload Management API: PM/API and Open API

In addition to altering the specified rate, this request is recorded in the DBC.SW_Event_Log table (accessible from the DBC.Software_Event_LogV view) and also written to the DBW. System rate updates are recorded only in the GDO control record.

Session usage data is placed in a separate, independent memory repository from processor resource usage data. As a result, any changes in the session monitoring rate have no impact on resource usage data. However, a user who sets a local sampling rate could affect the session

Rate Type Description

System-Wide (SesMonitorSys)

System-wide (across all sessions) sampling rate at which session-level statistics are collected within memory. The system rate is the default sampling rate that collects session-level information for all MONITOR sessions in the system. It is the rate at which users (who do not have the privilege to execute this request) see their session-level data updated.

This rate is saved on disk (in the GDO control record) whenever it is changed.

This rate is returned as part of the response to a MONITOR VIRTUAL SUMMARY request.

Local (SesMonitorLoc)

The local sampling rate is initiated within a MONITOR session, which allows the individual session rate to override the system rate within the your own MONITOR session. Use the local rate to sample data more frequently than the system rate is sampling. After the local rate sampling is completed and the local rate is set back to zero, the local rate is no longer in effect. The rate in effect then for that session becomes the system rate that has been saved on disk. The local rate is not saved on disk, and it may be lost during a system outage. In a system outage, the running sessions default to the system rate. The local rate, like the system rate, collects session-level statistics within memory. Use the local sampling rate for problem analysis.

Even though you are using the local rate from your own session, session-level data is still collected across all sessions (system wide). The impact of the local rate may not be transparent to those users who are issuing MONITOR SESSION requests at the system rate. For an example, see “Rate Scenario 2: Affects On Other Users When Increasing the Local Rate” on page 212.

Note: If the system rate has not been set, data will not be collected by the local rate.

This rate is returned as SesMonitorLoc as part of the response to a MONITOR VIRTUAL SUMMARY request.

The following are examples of when you might want to set a local rate:

• When your are troubleshooting an application that is hung, set the local rate to sample more frequently than the system rate. For example, if data is being collected system-wide every 10 minutes (or 600 seconds), setting a faster local rate of 6 seconds collects more current information on session status and locks for the application that requires resolution.

• If you have coded a new application and you want to troubleshoot its implementation, setting a more frequent local sampling rate enables you to better monitor its impact on the system.

• For performance analysis.

Page 211: Workload management api

Chapter 3: PMPC APIsSET SESSION RATE

Workload Management API: PM/API and Open API 211

usage data that other users see because all session usage data is stored in the same memory repository.

Session-level resource usage data is collected differently from the way processor resource usage data is collected. Processor resource usage data is collected for a particular sample period, while session usage data is collected cumulatively. The report can include cumulative data over many sample periods.

Monitoring a system may cause some form of global performance degradation. To limit the overhead cost, it is recommended that you set the system rate at 3600 seconds (or 1 hour) for general system monitoring. To perform problem analysis more quickly, you can set a more frequent local rate. After the analysis is done, terminate the session or set the local rate to zero. The lower system rate takes effect again in that session.

If both the system and local rates are set to zero at the same time, session-level monitoring stops, and all accumulated session-level data is discarded. PM/API starts collecting session-level data again the next time the system or local rate is reset to a nonzero value.

To avoid confusion, it is recommended that applications not query data more frequently than the faster of the two rates. If MONITOR SESSION requests are executed too frequently, one of the following may occur:

• The user application program sees duplicated data and CPU resources are wasted.

• The user application program sees data showing the result of an alteration caused by another user.

It is also recommended that you restrict the SET SESSION RATE privilege to the database administrator or system administrator.

A change to the system rate may cause a block because:

• Someone else is changing the system rate at the same time.

Rate change requests are queued and processed in the order received because the system does not allow different rates to be used on different processors. The system ensures that all processors use the same rate.

• The GDO control record is being updated.

Rate Scenario 1: Affects on Other Users When Increasing the System Rate

User A has the SET SESSION RATE privilege. User B does not.

Step Action

1 User A changes the system (or global) rate from 10 minutes to 5 minutes at 8:55. User A now requests data every 5 minutes instead of 10 minutes.

2 User A makes a request at 8:57. Data returned shows data from the interval of 8:50 to 8:57, plus the cumulative data from 8:00 to 8:50. By forcing an update of the data at 8:57, User A has reset the collection start time (or time-stamp) to 8:57 because the current time (8:57) minus the time-stamp of the data (8:50) is greater than the session collection rate of 5 minutes. Resetting the collection start time means resetting the time from which the interval is calculated to 8:57.

Page 212: Workload management api

Chapter 3: PMPC APIsSET SESSION RATE

212 Workload Management API: PM/API and Open API

If User B is not aware that the system rate has been changed to 5 minutes, then the application for User B continues to request data every 10 minutes. User B is requesting data at a less frequent rate than the data collection rate. User B may not notice a difference in data, since the data is cumulative. However, since all session resource data is deposited in the same memory pool, a change in collection rate by another user could affect the data User B sees.

Although it is transparent to the user, the user data impacted depends on which user request is received first. This usually happens when the user is not requesting data at the same rate as data is collected.

For example, User A makes a request at 9:00 and the request made by User A is received before the request (also at 9:00) made by User B. As described previously, User A sees data returned that is cumulative from 8:00 to 8:57.

Rate Scenario 2: Affects On Other Users When Increasing the Local Rate

Users A and B are requesting session-level data at the same rate as data is collected.

3 User A makes a next request at 9:00. Data returned is the same data that was returned at 8:57. The reason is that the current session-level data that was available was considered current, that is, the age of the data (9:00 - 8:57 = 3) is less than the session collection rate of 5.

Step Action

1 The request made by User B at 9:00 is queued. User B gets the cumulative data from 8:00 to 8:57 because User A made a request at 8:57. The request made by User B does not trigger an update because the request made by User A resets the time-stamp (or start time) to 8:57, and the elapsed time between 8:57 to 9:00 is less than 5 minutes (the data collection rate of the session). Thus, User B gets data from 8:50 to 8:57, plus the cumulative data from 8:00 to 8:50. In this case, there is no difference in the data User A or User B sees as a result of the request order.

2 User B gets a warning message that the rate has been changed to 5 minutes. User B can check to see what the new system rate is if MONITOR SESSION is being run. The data returned in the first Record parcel is the SampleSec, which indicates the duration of the sampling period in seconds. User B can observe that SampleSec reports 300 seconds (or 5 minutes) instead of 600 seconds (or 10 minutes).

Step Action

Step Action

1 User A wants to troubleshoot a new application program and at 9:00 sets a local rate of 1 minute within his session. The local rate now overrides the system rate of 10 minutes within the session for User A. User A now requests data every 1 minute instead of 10 minutes.

2 User A makes a request at 9:01. Data returned shows data from the interval of 9:00 to 9:01 (because User A has reset the session beginning collection time to 9:00), plus the cumulative data from 8:00 to 9:00.

Page 213: Workload management api

Chapter 3: PMPC APIsSET SESSION RATE

Workload Management API: PM/API and Open API 213

The actions made by User A in setting a local rate does not change the current system collection rate of 10 minutes.

The way the session for User B is calculating its collection interval does not change. Therefore, the collection rate and request rate for User B continues at 10-minute intervals. However, since all session usage data is stored in the same memory repository, the more frequent collection for User A may affect the cumulative data that User B might see.

User B may see more dynamic data than previously and receive more data than expected. Each of the requests made by User B could potentially include data from one sample period mixed in with data from a subsequent sample period that was initiated by a different use. In this case, the 1-minute interval collection for User A.

While the local rate for User A is in effect, User B makes a request at 9:00. Data returned shows data from the interval of 8:50 to 9:00, plus the cumulative data from 8:00 to 8:50.

If User B were to make a request at 9:04, User B would see data returned from 9:00 to 9:04, plus the cumulative data from 8:00 to 9:00. Because of the local data sampling for User A, User B can take advantage of the faster sampling rate and thus receive more data than expected.

On the other hand, if the local rate for User A were not in effect and User B makes a request at 9:04, the data returned would be from the interval of 8:00 to 9:00 only.

Rate Scenario 3: How Request Order Affects Data Reported

The DBA sets the system rate at 8:00 a.m. to collect every 10 minutes. User A decides to reset the global or system rate from 10 minutes to 5 minutes. In addition, User B decides to request session-level data at a different rate than the data collection rate.

User A does not know that the data timestamp has been altered by the request made by User B because User A had sent in a request immediately after the request made by User B.

3 User A makes the next request at 9:02. Data returned shows data from the interval of 9:01 to 9:02, plus the cumulative data from 8:00 to 9:01. From now on, responses to queries for User A returns data updated every 1 minute.

Step Action

Step Action

1 User A resets the global session sampling rate to 300 seconds (or 5 minutes) at 9:00, thus setting the timestamp for any current data to 9:00.

2 At 9:00, User A also sets a local sampling rate of 1 minute for his session.

3 User B makes a request for data at 9:05:25.

4 User B receives the cumulative data from 8:00 to 9:05:25 and, in the process, resets the data time-stamp to 9:05:25.

Page 214: Workload management api

Chapter 3: PMPC APIsSET SESSION RATE

214 Workload Management API: PM/API and Open API

The request made by User A for data at 9:06:00 is queued behind the request made by User B of 9:05:25. Because the current data is considered current (9:06:00 - 9:05:25 = 0:00:35, which is less than the local sampling rate of 1 minute), User A receives the same data (from 8:00 to 9:05:25) that User B received.

In this case, the request order affects the data User A receives. If not the earlier request made by User B, User A could have received data from the 8:00 to 9:06 interval, which User A probably expected.

Rate Scenario 4: Different Collection and Request Rates

Users A and B are running different application programs and are monitoring the applications with MONITOR SESSION and/or MONITOR VIRTUAL SUMMARY. User A has the SET SESSION RATE privilege. User A is requesting session-level data at a different rate from the rate at which data is collected.

User A is using the system collection rate of 10 minutes set by the DBA. However, User A wants to troubleshoot a new program and decides to set the application program to request data every 6 seconds.

Clearly, User A is requesting data more frequently than the data collection rate. Every 6 seconds, User A sees a data display that will show the same data until the 10-minute interval has elapsed.

In this case, data returned from monitoring the session for User A would probably be more meaningful if User A had set the system collection rate to the same rate as the request rate.

Parcels

The response returned from the Teradata Database contains the following sequence of parcel type:

Sample Input

This example shows how the parcels for a SET SESSION RATE request built by CLIv2 look when sent to the Teradata Database server with a sample_rate of 6 and a local_change of y. In the example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

Parcel Sequence

Parcel Flavor

Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 Activity Count = Previous rate

Activity Type = 83 (PCLSETSESSR)

DataInfo 71 6 to 32004 This parcel is present if request was IndicReq parcel; depends on the data type.

EndStatement 11 6 StatementNo: 2-byte integer

EndRequest 12 4 None

Page 215: Workload management api

Chapter 3: PMPC APIsSET SESSION RATE

Workload Management API: PM/API and Open API 215

Sample Output

With a sample_rate of 6 and a local_change of y, this example shows the values returned in character text format for the SET SESSION RATE request. Your application program may display returned values in a different format.

Success parcel:StatementNo: 1 ActivityCount: 0ActivityType: 83 FieldCount: 0

DataInfo parcel:FieldCount: 0

EndStatement.EndRequest.

Warning and Error Messages

The following table describes the error messages that may be returned with the SET SESSION RATE request.

For a discussion of common warning and error messages returned in response to SET SESSION RATE or other requests, see “Common Warning and Error Messages” on page 50.

For more detailed information on warning and error messages, see Messages.

Flavor Length Body

Num Name Bytes Field Value

0001 Req 20 Request SET SESSION RATE

0003 Data 9 MonVerID

SampleRate

LocalChg

2

6

Y

0004 Resp 6 BufferSize 32731

Message Number Description

3255 Invalid Rate: Must be from 0 to 3600, inclusive, or OFF.

Remedy: Correct the error and resubmit the request.

3262 The LOCAL CHANGE option must have a value of Y, y, N, n, BLANK, or NULL.

Remedy: Correct the error and resubmit the request.

3263 The LOGGING CHANGE option must have a value of Y, y, N, n, BLANK, or NULL.

Remedy: Correct the error and resubmit the request.

Page 216: Workload management api

Chapter 3: PMPC APIsSET SESSION RATE

216 Workload Management API: PM/API and Open API

Relationship Between SET SESSION RATE and MONITOR SESSION

For information on this PMPC CLIv2 interface relationship, see“Relationship Between MONITOR SESSION and SET SESSION RATE” on page 145.

Relationship Between SET SESSION RATE and MONITOR PHYSICAL SUMMARY

For information on this PMPC CLIv2 interface relationship, see“Relationship Between MONITOR PHYSICAL SUMMARY and SET SESSION RATE” on page 106.

Relationship Between SET SESSION RATE and MONITOR VIRTUAL SUMMARY

For information on this PMPC CLIv2 interface relationship, see“Relationship Between MONITOR VIRTUAL SUMMARY and SET SESSION RATE” on page 187.

Page 217: Workload management api

Chapter 3: PMPC APIsSQL Interfaces

Workload Management API: PM/API and Open API 217

SQL Interfaces

This section describes how to access PMPC data through SQL interfaces consisting of UDFs. The PMPC UDFs, like the PMPC CLIv2 interfaces, are used to monitor system and session-level performance and set sampling and logging rates. However, the PMPC UDFs can be invoked from any application.

The PMPC UDFs provide similar functionality to the PMPC CLIv2 interfaces.

Page 218: Workload management api

Chapter 3: PMPC APIsAbortSessions

218 Workload Management API: PM/API and Open API

AbortSessions

PurposeAborts any outstanding request or transaction of one or more sessions, and optionally logs those sessions off Teradata Database.

Definition

REPLACE FUNCTION AbortSessions (HostIdIn SMALLINT, UserNameIn VARCHAR(30), SessionNoIn INTEGER, LogoffSessions VARCHAR(1), UserOverride VARCHAR(1) )...;

Input Parameters

Parameter Description

HostIdIn The logical ID of a host (or client) with sessions logged on.

A value of -1 indicates all hosts.

UserNameIn The user name of the session specified.

An asterisk (*) or NULL indicates all users.

SessionNoIn The ID of the session to abort.

A value of zero indicates all sessions.

LogoffSessions Indicator of whether or not to log off sessions to Teradata Database in addition to aborting them. The following values apply:

• Y = Log off and abort sessions.

• N or NULL = Do not log sesssions off.

Page 219: Workload management api

Chapter 3: PMPC APIsAbortSessions

Workload Management API: PM/API and Open API 219

Usage Notes

The AbortSessions function provides similar functionality to a PMPC ABORT SESSION request with ListSessions set to ‘Y’ or ‘Yes’. For information about this interface, see “ABORT SESSION” on page 54.

Return Value

If successful, this function returns the number of sessions that were aborted.

Example 1

SELECT AbortSessions (1, 'User14', 0, 'Y', 'Y');

* * * Query completed. One row found. one column returned.* * * Total elapsed time was 5 seconds.

AbortSessions (1, 'User14', 0, 'Y', 'Y')---------------------------------------- 5

Example 2

SELECT AbortSessions (HostId, UserName, SessionNo, 'Y', 'Y'); FROM TABLE (MonitorSession(-1, '*', 0)) AS t1WHERE username= 'user14';

* * * Query completed. 5 rows found. one column returned.* * * Total elapsed time was 2 seconds.

AbortSessions (HostId, UserName, SessionNo, 'Y', 'Y')---------------------------------------------------- 1 1 1 1

UserOverride Indicator of whether or not to override an ABORT SESSION failure. The following values apply:

• Y = Override the ABORT SESSION request to fail in any of the following cases:

• An identified session is being session-switched.

• An identified session is executing its own ABORT SESSION request.

• An identified session has a PEState of IDLE: IN-DOUBT as a result of a 2PC.

Note: Sessions are marked IN-DOUBT by the 2PC protocol, which governs how transactions are committed by multiple systems that do not share memory. The protocol guarantees that either all systems commit or all roll back.

• N or NULL = Do not override.

Parameter Description

Page 220: Workload management api

Chapter 3: PMPC APIsAbortListSessions

220 Workload Management API: PM/API and Open API

AbortListSessions

PurposeReturns the status information of the aborted sessions.

Definition

REPLACE FUNCTION AbortListSessions (HostIdIn SMALLINT, UserNameIn VARCHAR(30), SessionNoIn INTEGER, LogoffSessions VARCHAR(1), UserOverride VARCHAR(1) RETURNS TABLE (HostId SMALLINT, SessionNo INTEGER, UserName VARCHAR(30), AbortStatus CHAR(1) )...;

Input Parameters

Parameter Description

HostIdIn The logical ID of a host (or client) with sessions logged on.

A value of -1 indicates all hosts.

UserNameIn The user name of the session specified.

An asterisk (*) or NULL indicates all users.

SessionNoIn The ID of the session to abort.

A value of zero indicates all sessions.

LogoffSessions Indicator of whether or not to log off sessions to Teradata Database in addition to aborting them. The following values apply:

• Y = Log off and abort sessions.

• N or NULL = Do not log sessions off.

UserOverride Indicator of whether or not to override an ABORT SESSION failure.

Page 221: Workload management api

Chapter 3: PMPC APIsAbortListSessions

Workload Management API: PM/API and Open API 221

Usage Notes

This table function is only supported in Constant Mode.

AbortListSessions cannot be used to abort delayed utility sessions because these sessions are not completely logged on.

This function provides similar functionality to a PMPC ABORT SESSION request with ListSessions set to ‘N’ or ‘No’.

Result Rows

The following values apply:

• Y = Override the ABORT SESSION request to fail in any of the following cases:

• An identified session is being session-switched.

• An identified session is executing its own ABORT SESSION request.

• An identified session has a PEState of IDLE: IN-DOUBT as a result of a 2PC.

Note: Sessions are marked IN-DOUBT by the 2PC protocol, which governs how transactions are committed by multiple systems that do not share memory. The protocol guarantees that either all systems commit or all roll back.

• N or NULL = Do not override.

Parameter Description

Column Name Description

HostId The logical host ID of (or client) the aborted sessions were logged on to. For a PE, HostId identifies one of the hosts or LANs associated with the described PE. For a session, the combination of a host ID and a session number uniquely identifies a user session on the system.

Note: This value is NULL for AMPs. A value of zero represents the Supervisor window.

SessionNo The number of the session that was aborted. Together with a given host ID, a session number uniquely identifies a session on the Teradata Database system. This value is assigned by the host (or client) at logon time.

UserName The user name of the session that was aborted. This is the name specified when the user is created; it is used to log on to a session. Within Teradata Database, user name is almost equivalent to database name.

Page 222: Workload management api

Chapter 3: PMPC APIsAbortListSessions

222 Workload Management API: PM/API and Open API

Example

SELECT * from TABLE (AbortListSessions(1, 'User14', 0, 'Y', 'Y')) AS t1;

*** Query completed. 5 rows found. 4 columns returned. *** Total elapsed time was 4 seconds.

HostId SessionNo UserName AbortStatus------ ----------- ------------------------------ ----------- 1 1007 USER14 1 1011 USER14 1 1010 USER14 1 1009 USER14 1 1008 USER14

AbortStatus The status of the sessions aborted.

The following values apply:

• I = In-Doubt

• A = Aborting a transaction

• C = Committing a transaction

• E = Executing an ABORT SESSION request

• S = Switching

• An empty string = In some state other than the above. This value is returned when issuing an SQL function.

For an ABORT without LOGOFF, any status except NULL indicates the reason the request could not impact the associated session.

For an ABORT with LOGOFF, an I, E, or S status value indicates that the associated session cannot be aborted or logged off.

Column Name Description

Page 223: Workload management api

Chapter 3: PMPC APIsIdentifyDatabase

Workload Management API: PM/API and Open API 223

IdentifyDatabase

PurposeReturns the name of the specified database ID.

Definition

REPLACE FUNCTION IdentifyDatabase (DatabaseId INTEGER) RETURNS VARCHAR(30)...;

Input Parameter

The DatabaseId parameter is the specified database ID.

Usage Notes

The IdentifyDatabase function provides similar functionality to a PMPC IDENTIFY DATABASE request. For information about this interface, see “IDENTIFY” on page 67.

Return Value

This function returns the name of the database.

Example

SEL IdentifyUser(blk1userid) as "blocking user", IdentifyTable(blk1objtid) as "blocking table", IdentifyDatabase(blk1objdbid) as "blocking db"FROM TABLE (MonitorSession(-1,'*',0)) AS t1WHERE Blk1UserId > 0;

*** Query completed. One row found. 3 columns returned. *** Total elapsed time was 4 seconds.

blocking user blocking table blocking db--------------------------- -------------------------- -------------user1 skewAmp1 DBaaa

Page 224: Workload management api

Chapter 3: PMPC APIsIdentifySession

224 Workload Management API: PM/API and Open API

IdentifySession

PurposeIdentifies the name of a user, by session, who is causing a block.

Definition

REPLACE FUNCTION IdentifySession (HostId INTEGER, SessionNo INTEGER

RETURNS VARCHAR(30)...;

Input Parameters

Usage Notes

The IdentifySession function provides similar functionality to a PMPC IDENTIFY SESSION request. For information about this interface, see “IDENTIFY” on page 67.

Return Value

Returns the name of the user, by session, who is causing a block.

Example

sel IdentifySession(blk1Hostid,blk1sessno)FROM TABLE (MonitorSession(-1,'*',0)) AS t1WHERE Blk1UserId > 0;

*** Query completed. One row found. One column returned. *** Total elapsed time was 1 second.

IdentifySession(Blk1HostId,Blk1SessNo)--------------------------------------USER1

Parameter Description

HostId The ID of the blocking host.

SessionNo The number of the session that is blocked.

Page 225: Workload management api

Chapter 3: PMPC APIsIdentifyTable

Workload Management API: PM/API and Open API 225

IdentifyTable

PurposeReturns the name of the specified table ID.

Definition

REPLACE FUNCTION IdentifyTable (TableId INTEGER)

RETURNS VARCHAR(30)...;

Input Parameter

The TableID parameter is the specified ID of the locked table.

Usage Notes

The IdentifyTable function provides similar functionality to a PMPC IDENTIFY TABLE request. For information about this interface, see “IDENTIFY” on page 67.

Return Value

This function returns the name of the table.

Example

SEL IdentifyUser(blk1userid) as "blocking user", IdentifyTable(blk1objtid) as "blocking table", IdentifyDatabase(blk1objdbid) as "blocking db"FROM TABLE (MonitorSession(-1,'*',0)) AS t1WHERE Blk1UserId > 0;

*** Query completed. One row found. 3 columns returned. *** Total elapsed time was 4 seconds.

blocking user blocking table blocking db--------------------------- ----------------------- -------------user1 skewAmp1 DBaaa

Page 226: Workload management api

Chapter 3: PMPC APIsIdentifyUser

226 Workload Management API: PM/API and Open API

IdentifyUser

PurposeReturns the name of the specified user ID who is causing a block.

Definition

REPLACE FUNCTION IdentifyUser (UserId INTEGER)

RETURNS VARCHAR(30)...;

Input Parameter

The UserId parameter is the ID of the user who is causing the block.

Usage Notes

The IdentifyUser function provides similar functionality to a PMPC IDENTIFY USER request. For information about this interface, see “IDENTIFY” on page 67.

Return Value

This function returns the name of the user.

Example

SEL IdentifyUser(blk1userid) as "blocking user", IdentifyTable(blk1objtid) as "blocking table", IdentifyDatabase(blk1objdbid) as "blocking db"FROM TABLE (MonitorSession(-1,'*',0)) AS t1WHERE Blk1UserId > 0;

*** Query completed. One row found. 3 columns returned. *** Total elapsed time was 4 seconds.

blocking user blocking table blocking db--------------------------- ----------------------- -------------user1 skewAmp1 DBaaa

Page 227: Workload management api

Chapter 3: PMPC APIsMonitorAWTResource

Workload Management API: PM/API and Open API 227

MonitorAWTResource

PurposeCollects statistics on AMPs based on the in-use Amp Worker Tasks (AWTs).

Definition

REPLACE FUNCTION MonitorAWTResource() RETURNS TABLE (IntervalCount1 INTEGER, IntervalCount2 INTEGER, IntervalCount3 INTEGER, IntervalCount4 INTEGER, FlowControl INTEGER, HighAMP1VprocId INTEGER, HighAMP1InUseCount INTEGER, HighAMP2VprocId INTEGER, HighAMP2InUseCount INTEGER, HighAMP3VprocId INTEGER, HighAMP3InUseCount INTEGER, HighAMP4VprocId INTEGER, HighAMP4InUseCount INTEGER, HighAMP5VprocId INTEGER, HighAMP5InUseCount INTEGER, LowAMP1VprocId INTEGER, LowAMP1InUseCount INTEGER, LowAMP2VprocId INTEGER, LowAMP2InUseCount INTEGER, LowAMP3VprocId INTEGER, LowAMP3InUseCount INTEGER, LowAMP4VprocId INTEGER, LowAMP4InUseCount INTEGER, LowAMP5VprocId INTEGER, LowAMP5InUseCount INTEGER, FCVprocId1 INTEGER, FCVprocId2 INTEGER, FCVprocId3 INTEGER, FCVprocId4 INTEGER, FCVprocId5 INTEGER )...;

Usage Notes

The MonitorAWTResource function provides similar functionality to the PMPC MONITOR AWT RESOURCE request. For information about this interface, see “MONITOR AWT RESOURCE” on page 75.

Page 228: Workload management api

Chapter 3: PMPC APIsMonitorAWTResource

228 Workload Management API: PM/API and Open API

Result Rows

Column Name Description

IntervalCount1 The number of AMPs in the system whose in-use AWT counts fall at, or above, the Threshold 1 value and do not qualify for the higher thresholds.

IntervalCount2 The number of AMPs in the system whose in-use AWT counts fall at, or above, the Threshold 2 value and do not qualify for the higher thresholds.

IntervalCount3 The number of AMPs in the system whose in-use AWT counts fall at, or above, the Threshold 3 value and do not qualify for the higher thresholds.

IntervalCount4 The number of AMPs in the system whose in-use AWT counts fall at, or above, the Threshold 4 value and do not qualify for the higher thresholds.

FlowControl The number of AMPs currently in some form of Flow Control.

HighAMP1VprocId The vproc ID of the AMP with the highest in-use count in the system. A value of -1 indicates this field is not defined.

HighAMP1InUseCount The in-use count associated with the AMP 1 Vproc ID. This is only applicable if AMP 1 is defined.

HighAMP2VprocId The vproc ID of the AMP with the next highest in-use count in the system. A value of -1 indicates this field is not defined.

HighAMP2InUseCount The in-use count associated with the AMP 2 Vproc ID. This is only applicable if AMP 2 is defined.

HighAMP3VprocId The vproc ID of the AMP with the next highest in-use count in the system. A value of -1 indicates this field is not defined.

HighAMP3InUseCount The in-use count associated with the AMP 3 Vproc ID. This is only applicable if AMP 3 is defined.

HighAMP4VprocId The vproc ID of the AMP with the next highest in-use count in the system. A value of -1 indicates this field is not defined.

HighAMP4InUseCount The in-use count associated with the AMP 4 Vproc ID. This is only applicable if AMP 4 is defined.

HighAMP5VprocId The vproc ID of the AMP with the next highest in-use count in the system. A value of -1 indicates this field is not defined.

HighAMP5InUseCount The in-use count associated with the AMP 5 Vproc ID. This is only applicable if AMP 5 is defined.

LowAMP1VprocId The vproc ID of the AMP with the lowest in-use count in the system. A value of -1 indicates this field is not defined.

LowAMP1InUseCount The in-use count associated with the AMP 1 Vproc ID. This is only applicable if AMP 1 is defined.

Page 229: Workload management api

Chapter 3: PMPC APIsMonitorAWTResource

Workload Management API: PM/API and Open API 229

Example

BTEQ -- Enter your DBC/SQL request or BTEQ command:.set sidetitles on

BTEQ -- Enter your DBC/SQL request or BTEQ command:.set foldline on

BTEQ -- Enter your DBC/SQL request or BTEQ command:SELECT * FROM TABLE (MonitorAWTResource()) AS t1;

*** Query completed. One row found. 30 columns returned. *** Total elapsed time was 1 second. IntervalCount1 0 IntervalCount2 0 IntervalCount3 0 IntervalCount4 4 FlowControl 0 HighAMP1VprocId 3HighAMP1InUseCount 1 HighAMP2VprocId 2HighAMP2InUseCount 1 HighAMP3VprocId 1HighAMP3InUseCount 1

LowAMP2VprocId The vproc ID of the AMP with the lowest in-use count in the system. A value of -1 indicates this field is not defined.

LowAMP2InUseCount The in-use count associated with the AMP 2 Vproc ID. This is only applicable if AMP 2 is defined.

LowAMP3VprocId The vproc ID of the AMP with the lowest in-use count in the system. A value of -1 indicates this field is not defined.

LowAMP3InUseCount The in-use count associated with the AMP 3 Vproc ID. This is only applicable if AMP 3 is defined.

LowAMP4VprocId The vproc ID of the AMP with the lowest in-use count in the system. A value of -1 indicates this field is not defined.

LowAMP4InUseCount The in-use count associated with the AMP 4 Vproc ID. This is only applicable if AMP 4 is defined.

LowAMP5VprocId The vproc ID of the AMP with the lowest in-use count in the system. A value of -1 indicates this field is not defined.

LowAMP5InUseCount The in-use count associated with the AMP 5 Vproc ID. This is only applicable if AMP 5 is defined.

FCVprocId1,

FCVprocId2,

FCVprocId3,

FCVprocId4,

FCVprocId5

The vproc ID of the AMP in flow control. A value of -1 indicates this field is not defined.

Column Name Description

Page 230: Workload management api

Chapter 3: PMPC APIsMonitorAWTResource

230 Workload Management API: PM/API and Open API

HighAMP4VprocId 0HighAMP4InUseCount 1 HighAMP5VprocId -1HighAMP5InUseCount 0 LowAMP1VprocId 3 LowAMP1InUseCount 1 LowAMP2VprocId 2 LowAMP2InUseCount 1 LowAMP3VprocId 1 LowAMP3InUseCount 1 LowAMP4VprocId 0 LowAMP4InUseCount 1 LowAMP5VprocId -1 LowAMP5InUseCount 0 FCVprocId1 -1 FCVprocId2 -1 FCVprocId3 -1 FCVprocId4 -1 FCVprocId5 -1

Page 231: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

Workload Management API: PM/API and Open API 231

MonitorMySessions

PurposeCollects the session information for the current user on the current host.

Definition

REPLACE FUNCTION MonitorMySessions() RETURNS TABLE

(HostId SMALLINT, SessionNo INTEGER, LogonPENo SMALLINT, RunVprocNo SMALLINT, PartName VARCHAR(16), PEstate VARCHAR(18), LogonTime VARCHAR(22), UserId INTEGER, LSN INTEGER, UserName VARCHAR(30), UserAccount VARCHAR(30), PECPUsec FLOAT, XActCount FLOAT, ReqCount FLOAT, ReqCacheHits FLOAT, AMPState VARCHAR(18), AMPCPUSec FLOAT, AMPIO FLOAT, ReqSpool FLOAT, Blk1HostId SMALLINT, Blk1SessNo INTEGER, Blk1UserId INTEGER, Blk1Lmode CHAR, Blk1Otype CHAR, Blk1ObjDBID INTEGER, Blk1ObjTID INTEGER, Blk1Status CHAR, Blk2HostId SMALLINT, Blk2SessNo INTEGER, Blk2UserId INTEGER, Blk2Lmode CHAR, Blk2Otype CHAR, Blk2ObjDBID INTEGER, Blk2ObjTID INTEGER, Blk2Status CHAR, Blk3HostId SMALLINT, Blk3SessNo INTEGER, Blk3UserId INTEGER, Blk3Lmode CHAR, Blk3Otype CHAR, Blk3ObjDBID INTEGER, Blk3ObjTID INTEGER, Blk3Status CHAR,

Page 232: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

232 Workload Management API: PM/API and Open API

MoreBlockers CHAR, LogonSource VARCHAR(128), HotAmp1CPU FLOAT, HotAmp2CPU FLOAT, HotAmp3CPU FLOAT, HotAmp1CPUId FLOAT, HotAmp2CPUId FLOAT, HotAmp3CPUId FLOAT, HotAmp1IO FLOAT, HotAmp2IO FLOAT, HotAmp3IO FLOAT, HotAmp1IOId INTEGER, HotAmp2IOId INTEGER, HotAmp3IOId INTEGER, LowAmp1CPU FLOAT, LowAmp2CPU FLOAT, LowAmp3CPU FLOAT, LowAmp1CPUId INTEGER, LowAmp2CPUId INTEGER, LowAmp3CPUId INTEGER, LowAmp1IO FLOAT, LowAmp2IO FLOAT, LowAmp3IO FLOAT, LowAmp1IOId INTEGER, LowAmp2IOId INTEGER, LowAmp3IOId INTEGER, AvgAmpCPUSec FLOAT, AvgAmpIOCnt FLOAT, AmpCount INTEGER, TempSpaceUsg FLOAT, ReqStartTime VARCHAR(22), ReqCPU FLOAT, ReqIO FLOAT, ReqNo INTEGER,

WlcId INTEGER, DontReclassifyFlag SMALLINT,

ProxyUser VARCHAR (128), )...;

Usage Notes

The following CPU fields in the MonitorMySessions response are affected by the MonSesCPUNormalization field:

The MonSesCPUNormalization field, a DBS Control General Record field, controls whether normalized or non-normalized statistical CPU data is reported by the functions: MonitorMySessions and MonitorSession, and by the MONITOR SESSION request. For more

• AMPCPUSec

• AvgAmpCPUSec

• HotAmp1CPU

• HotAmp2CPU

• HotAmp3CPU

• LowAmp1CPU

• LowAmp2CPU

• LowAmp3CPU

• PECPUSec

• RequestAmpCPU

Page 233: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

Workload Management API: PM/API and Open API 233

information about the MonSesCPUNormalization field and CPU normalization, see the DBS Control utility in Utilities.

For a complete description of these fields, see the topic that follows.

You can also refer to “MonitorSession” on page 262 or “MONITOR SESSION” on page 116 for a list of these CPU fields.

Result Rows

Column Name Description

HostId The logical Host ID associated with a PE or session. For a PE, HostId identifies one of the hosts or LANs associated with the described PE. For a session, the combination of a host ID and a session number uniquely identifies a user session on the system.

Note: This value is NULL for AMPs. A value of zero represents the Supervisor window.

SessionNo The number of the current session. Together with a given host ID, a session number uniquely identifies a session on the Teradata Database system. This value is assigned by the host (or client) at logon time.

LogonPENo The vproc number of the PE the session is currently logged on to; it identifies the PE that has control responsibility for the session. Normally, this is the PE that processed the logon request; but if that PE goes offline, it will be the PE to which the session was switched.

RunVprocNo The vproc number of the AMP or PE currently assigned to process the session requests.

For sessions in Teradata SQL partitions, this value is identical to the LogonPENo. For sessions in FastLoad or MultiLoad partitions, this is the AMP that initially processes the data being loaded. For HUTPARSE or HUTCTL (Archive/Restore) sessions, this value is NULL.

If a RunVprocNo value of -1 in record mode or NULL in indicator mode is returned by MonitorMySessions for FastLoad, MultiLoad or FastExport sessions, this indicates that the session is in the process of starting up.

PartName The name of the session partition associated with this session. Following a successful logon request by a session or as part of a connect request, the session identifies the partition with which the user wants the session to be associated. FASTLOAD, Teradata SQL, MONITOR, INTERNAL are examples of valid partition names.

PEstate The current state of the session within the PE.

For a list of the different states, see the MONITOR SESSION PEState field.

LogonTime The date and time portion of the information recorded by Session Control when a session successfully logs on. It is usually formatted for display as yyyy/mm/dd 99:99:99.99, which represents the year, month, day, hours: minutes: seconds.

Page 234: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

234 Workload Management API: PM/API and Open API

UserId The user or internal ID of a user for this session. Within the Teradata Database, UserId is equivalent to Database ID. Typically, UserId is used when the associated record is known to be a user name, and Database ID is used when the associated record is known to be a database. However, UserId can identify either a given user or database name.

LSN The Logon Sequence Number (LSN) that is associated with a session when the session logs on. It identifies a collection of sessions performing a related activity. For example, in a FastLoad job, a user is logged on as a Teradata SQL session, as well as n FastLoad sessions with the same user name. Therefore, n+1 sessions (1 Teradata SQL and n FastLoad) with the same LSN are all associated with the given FastLoad job. To see how the FastLoad job is doing, the user can pick out all sessions reported with the same LSN number.

Note: This information supplies the parent-child relationship for sessions involved with FastLoad, MultiLoad, and Archive and Recovery jobs.

UserName The user name of the session. This is the name specified when the user is created; it is used to log on to a session. Within Teradata Database, user name is almost equivalent to the database name.

UserAccount The account currently with which the user is logged in. When a user is created or altered, that user is allowed to run in association with one or more accounts. During the logon process, a particular user session establishes its priority and charges resource usage to one of the allowed accounts.

PECPUsec The CPU time (in seconds) used in a PE by the associated session for parsing and dispatching requests. It is accurate to the second.

This value is valid only when associated with Teradata SQL and MONITOR partition sessions. The value is NULL when it is returned for all other sessions.

XActCount The number of explicit and implicit transactions executed by the session.

This value is valid only when returned for Teradata SQL sessions, and is NULL for all other partition sessions. For this value, you must make a request for data before completion of the first sample period that follows either a system outage or a change in the VProcMonitor rate.

ReqCount The number of requests (Tequel Start Request [TSR] messages) initiated by the session.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or change in the VProcMonitor rate.

ReqCacheHits The number of times that this session processed a request using information from the Teradata SQL Parser request cache, specifically, how many times there was a request cache hit.

This value is valid only for Teradata SQL sessions, and is NULL for all other partition sessions. This value is also NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Column Name Description

Page 235: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

Workload Management API: PM/API and Open API 235

AMPState The current state of the associated session in AMP vprocs in decreasing priority:

• ABORTING: The transaction is being rolled back; session is aborting.

• BLOCKED: Some background activity is in progress and the last request is on hold until this background activity is completed.

• ACTIVE: Normal, on-going activity is being done by this session.

• IDLE: No work in progress for this session on any AMP.

• UNKNOWN: No recorded activity by this session since monitoring began.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

AMPCPUSec The current elapsed CPU time, in seconds, used on all AMPs by the associated session for executing requests. For example, for Teradata SQL requests, this is the time spent by the Teradata Database actively working or rolling back an aborted transaction. This does not include any UNIX/PDE CPU time spent handling Teradata Database requests. This value is accurate to the second.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

AMPIO The current number of logical Reads and Writes issued across all AMPs by the associated session.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

ReqSpool The current spool used by current request across all AMPs, expressed as a number of bytes.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Column Name Description

Page 236: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

236 Workload Management API: PM/API and Open API

Blk1HostId,

Blk2HostId,

Blk3HostId

The logical host ID of a session causing a block. This value is derived from equating the transactions causing a Teradata Database lock conflict to the sessions that issued those transactions. The Blk_x_HostId in combination with Blk_x_SessNo uniquely identifies the session that is causing a block.

A valid value is not returned if an inactive Archive/Recovery job is causing the lock conflict, because no session is logged in.

This value is NULL if:

• The host ID is not available.

• The session does not have an AMPState of BLOCKED.

If the Blk_x_HostId, Blk_x_SessNo, and Blk_x_UserID values all return as NULLs and AMPState is BLOCKED, a Host Utility (HUT) lock left over after the session holding the lock was aborted or logged off. The lock was never released, and no blocking information is available because the session no longer exists.

Use the Show Locks utility to obtain the user name that placed the HUT lock. For more information, see Utilities.

Blk1SessNo,

Blk2SessNo,

Blk3SessNo

The number of the session causing a block. This value is derived from associating the transactions causing a lock conflict to the sessions that issued those transactions. The Blk_x_SessNo in combination with Blk_x_HostId uniquely identifies the session causing a block.

This information is unavailable if an inactive Archive/Recovery job is causing the lock conflict.

This value is NULL if:

• SessNo is not available.

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

If the Blk_x_HostId, Blk_x_SessNo, and Blk_x_UserID values all return as NULLs and AMPState is BLOCKED, a host utility lock left over after the session holding the lock was aborted or logged off. The lock was never released, and no blocking information is available because the session no longer exists.

Use the Show Locks utility to obtain the user name that placed the HUT lock. For more information, see Utilities.

Column Name Description

Page 237: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

Workload Management API: PM/API and Open API 237

Blk1UserId,

Blk2UserId,

Blk3UserId

The ID of the user or host utility job preventing the session from being granted a lock. This information is especially important when an Archive/Recovery job is holding the lock, because the user ID is the only information available about who placed the lock.

This value is NULL if:

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

If the Blk_x_HostId, Blk_x_SessNo, and Blk_x_UserID values all return as NULLs and AMPState is BLOCKED, a host utility lock left over after the session holding the lock was aborted or logged off. The lock was never released, and no blocking information is available because the session no longer exists.

Use the Show Locks utility to obtain the user name that placed the HUT lock. For more information, see Utilities.

Blk1Lmode,

Blk2Lmode,

Blk3Lmode

The mode (severity) of the lock involved in causing a block.

The following values apply:

• E = Exclusive

• W = Write

• R = Read

• A = Access

Locks are reported in decreasing order of severity because removing the most severe lock conflict may eliminate the source of the lock conflict.

This value is NULL if:

• The session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Note: A session may be blocked by either a granted lock or an ungranted lock that precedes the blocked lock in the queue and is in conflict with the lock requested by this blocked session. For information on whether the lock is granted, see the MONITOR SESSSION fields: Blk1Status, Blk2Status, and Blk3Status.

Column Name Description

Page 238: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

238 Workload Management API: PM/API and Open API

Blk1Otype,

Blk2Otype,

Blk3Otype

The type of object whose lock is causing the session described by the associated row to be blocked:

• D = Database

• T= Table

• R = Row hash

However, this object is not necessarily the type of object the blocked session is trying to access. For example, if the session is requesting a row hash lock, the blocking object could be a database, table, or row hash.

This value is NULL if:

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

For a Table T, it is possible for User A to block User B with a table level lock on Table T on AMP_1 and with a Row Hash Level lock on that same Table T on AMP_2. When that occurs, the only lock conflict reported is that User B is blocked by User A on a table.

Blk1ObjDBID,

Blk2ObjDBID,

Blk3ObjDBID

The unique ID of the database object over which a lock conflict is preventing the session from being granted a lock.

Within the Teradata Database system, Database ID is equivalent to User ID. Typically, User ID is used when the associated record is known to be a user name, and Database ID is used when the associated record is known to be a database. However, Database ID can identify either a user or database name.

This value is NULL if:

• The session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Blk1ObjTID,

Blk2ObjTID,

Blk3ObjTID

The unique ID of the table object over which a lock conflict is preventing the session from being granted a lock.

This value is NULL if:

• The session does not have an AMPState of BLOCKED.

• The Blk_x_OType is D.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Column Name Description

Page 239: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

Workload Management API: PM/API and Open API 239

Blk1Status,

Blk2Status,

Blk3Status

The status of lock causing a block:

• W= Waiting

• G = Granted

This value is NULL if:

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Note: A lock request may be blocked by either a granted lock or an ungranted lock that precedes the blocked lock request in the queue and is in conflict with it.

A status of Waiting has a higher priority than that of Granted when there is more than one lock involved. For example, for a given object and a given session, a session that is blocked by a Waiting lock on one AMP and a Granted lock on another AMP has Waiting reported as its status.

MoreBlockers An indicator of more lock conflicts. The following values apply:

• Blank = Blkx information is a complete list of sessions blocking the session described.

• Asterisk (*) = additional sessions are blocking the session described. The Blkx information shows only three blocking sessions.

This value is NULL if:

• The state of the session is not BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

LogonSource The logon source information. At logon time, this information is optionally supplied by the Teradata Director Program or the LAN Gateway to further identify the physical or logical location of the session, the logon user name, and the interface under which the session was initiated. (For example, the data string may include DBC as the user ID and BTEQ as the interface.)

Note: A two-byte value precedes the LogonSource data to indicate the length of the string. The length value is zero if LogonSource is NULL.

For a list of the commonly seen LogonSource string application names, see SQL Data Definition Language.

HotAmp1CPU The CPU time of the highest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp2CPU The CPU time of the second highest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

Column Name Description

Page 240: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

240 Workload Management API: PM/API and Open API

HotAmp3CPU The CPU time of the third highest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

HotAmp1CPUId The vproc ID of the highest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp2CPUId The vproc ID of the second highest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp3CPUId The vproc ID of the third highest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs in the system.

HotAmp1IO The IO count of the highest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp2IO The IO count of the second highest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp3IO The IO count of the third highest IO utilized AMP for the last collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs in the system.

HotAmp1IOId The vproc ID of the highest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp2IOId The vproc ID of the second highest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp3IOId The vproc ID of the third highest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs in the system.

LowAmp1CPU The CPU time of the lowest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp2CPU The CPU time of the second lowest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

Column Name Description

Page 241: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

Workload Management API: PM/API and Open API 241

LowAmp3CPU The CPU time of the third lowest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

LowAmp1CPUId The vproc ID of the lowest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp2CPUId The vproc ID of the second lowest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp3CPUId The vproc ID of the third lowest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

LowAmp1IO The IO count of the lowest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp2IO The IO count of the second lowest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp3IO The IO count of the third lowest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

LowAmp1IOId The vproc ID of the lowest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp2IOId The vproc ID of the second lowest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp3IOId The vproc ID of the third lowest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

AvgAmpCPUSec The average AMP CPU utilization for the last session collection interval. The average is calculated as the sum of CPU utilization for all amps participating divided by the number of online AMPs.

This value is NULL if the request is made before the sample period expires.

Column Name Description

Page 242: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

242 Workload Management API: PM/API and Open API

Example 1

sel * FROM TABLE (MonitorMySessions()) AS t1;

*** Query completed. One row found. 80 columns returned. *** Total elapsed time was 1 second.

HostId 1 SessionNo 1003 LogonPENo 16383 RunVprocNo 6383 PartName DBC/SQL

AvgAmpIOCnt The average AMP IO utilization for the last session collection interval. The average is calculated as the sum of IO utilization for all AMPs participating divided by the number of online AMPs.

This value is NULL if the request is made before the sample period expires.

AmpCount The current number of AMPs currently executing on the associated node.

TempSpaceUsg Total amount, in bytes, of temporary space used by the session.

This value is NULL if the session did not materialize any temporary tables.

ReqStartTime The date and time of the current request on the session started. It is usually formatted for display as yyyy/mm/dd 99:99:99.99, which represents the year, month, day hours: minutes: seconds.

ReqCPU The total CPU usage by the current SQL request on the session on all AMPs.This value contains proper request-level statistics for DBC/SQL sessions running SQL requests only. Ignore the value returned in this field for other types of sessions, such as DBC/SQL sessions linked to a utility job.

This field is equivalent to the MONITOR SESSION RequestAmpCPU field.

ReqIO The total number of accesses by the current SQL request for the session on all AMPs. This value contains proper request-level statistics for DBC/SQL sessions running SQL requests only. Ignore the value returned in this field for other types of sessions, such as DBC/SQL sessions linked to a utility job.

This field is equivalent to the MONITOR SESSION RequestAmpI/O field.

ReqNo The active request number.

If no request is running, then a value of zero or NULL is displayed in indicator mode.

WlcId The workload class ID associated with the specified request.

DontReclassifyFlag A flag indicating that the next request on the session will not be classified but will use the workload class ID (WlcId) already assigned to the session. This will occur if this is a utility session or a WlcId was assigned to the session using the TDWMAssignWD function or the TDWM WD ASSIGNMENT request. For more information on these APIs, see Chapter 4: “Teradata Dynamic Workload Management APIs.”

ProxyUser The name of the proxy user if this session has a proxy connection.

Column Name Description

Page 243: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

Workload Management API: PM/API and Open API 243

PEstate ACTIVE LogonTime 2007/12/20 13:44:44.00 UserId 1120 LSN 0 UserName TRUSTUSER1 UserAccount DBC PECPUsec 2.03000000000000E-001 XActCount 1.00000000000000E 000 ReqCount 6.00000000000000E 000 ReqCacheHits 0.00000000000000E 000 AMPState ACTIVE AMPCPUSec 1.60000000000000E-002 AMPIO 4.00000000000000E 000 ReqSpool 0.00000000000000E 000 Blk1HostId 0 Blk1SessNo 0 Blk1UserId 0 Blk1Lmode Blk1Otype Blk1ObjDBID 0 Blk1ObjTID 0 Blk1Status Blk2HostId 0 Blk2SessNo 0 Blk2UserId 0 Blk2Lmode Blk2Otype Blk2ObjDBID 0 Blk2ObjTID 0 Blk2Status Blk3HostId 0 Blk3SessNo 0 Blk3UserId 0 Blk3Lmode Blk3Otype Blk3ObjDBID 0 Blk3ObjTID 0 Blk3Status MoreBlockers LogonSource (TCP/IP) 042B 192.168.106.128 DG2 5276 ADMINISTRAT HotAmp1CPU 1.60000000000000E-002 HotAmp2CPU 0.00000000000000E 000 HotAmp3CPU 0.00000000000000E 000 HotAmp1CPUId 1 HotAmp2CPUId 0 HotAmp3CPUId 0 HotAmp1IO 0.00000000000000E 000 HotAmp2IO 0.00000000000000E 000 HotAmp3IO 0.00000000000000E 000 HotAmp1IOId 0 HotAmp2IOId 0 HotAmp3IOId 0 LowAmp1CPU 0.00000000000000E 000 LowAmp2CPU 1.60000000000000E-002 LowAmp3CPU 0.00000000000000E 000 LowAmp1CPUId 0 LowAmp2CPUId 1 LowAmp3CPUId 0 LowAmp1IO 0.00000000000000E 000

Page 244: Workload management api

Chapter 3: PMPC APIsMonitorMySessions

244 Workload Management API: PM/API and Open API

LowAmp2IO 0.00000000000000E 000 LowAmp3IO 0.00000000000000E 000 LowAmp1IOId 1 LowAmp2IOId 0 LowAmp3IOId 0 AvgAmpCPUSec 8.00000000000000E-003 AvgAmpIOCnt 0.00000000000000E 000 AmpCount 2 TempSpaceUsg 0.00000000000000E 000 ReqStartTime 2007/12/20 14:44:18.00 ReqCPU 1.60000000000000E-002 ReqIO 0.00000000000000E 000 ReqNo 6 WlcId 0DontReclassifyFlag 255 ProxyUser PXYUSER3

Example 2

Sel Hostid, sessionNo, username, PEState FROM TABLE (MonitorMySessions()) AS t1;

*** Query completed. One row found. 4 columns returned. *** Total elapsed time was 1 second.

HostId SessionNo UserName PEstate----------- ----------- ------------------------------ -------------- 1 1015 TDWM DISPATCHING

Page 245: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalConfig

Workload Management API: PM/API and Open API 245

MonitorPhysicalConfig

PurposeCollects overall information on node availability.

Definition

REPLACE FUNCTION MonitorPhysicalConfig() RETURNS TABLE (ProcId SMALLINT, Status CHAR, CPUType VARCHAR(7), CPUCount SMALLINT )...;

Usage Notes

The MonitorPhysicalConfig function provides similar functionality to a PMPC MONITOR PHYSICAL CONFIG request. For information about this interface, see “MONITOR PHYSICAL CONFIG” on page 82.

Result Rows

Column Name Description

ProcId The ID associated with a node. This value is computed as the module number within a cabinet plus 100 times the cabinet number. Usually formatted for display as zz9-99. However, this display format can be changed by the user.

Status The status of the node, AMP, or PE associated with this record. The following values apply:

• U = Up/online

• D = Down

• S = Standby

A vproc or node is up (U) when it is:

• Configured into the system

• Online

• Capable of actively performing tasks associated with normal Teradata Database activity

Down (D) represents all other potential states.

Standby (S) indicates the vproc or node is ready to join the configuration in place if another vproc or node goes down.

Page 246: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalConfig

246 Workload Management API: PM/API and Open API

Example

SELECT t2.* FROM TABLE (MonitorPhysicalConfig()) AS t2;

*** Query completed. One row found. 4 columns returned. *** Total elapsed time was 1 second.

ProcId Status CPUType CPUCount----------- ------ ------- ----------- 33 U PentPro 4

CPUType The type of CPU installed in this node, for example: 'Pentium', 'PentPro', or 'Unknown'.

CPUCount The number of CPUs in this node.

Column Name Description

Page 247: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalResource

Workload Management API: PM/API and Open API 247

MonitorPhysicalResource

PurposeCollects node resource usage data.

Definition

REPLACE FUNCTION MonitorPhysicalResource() RETURNS TABLE (ProcId SMALLINT, Status CHAR, AmpCount SMALLINT, PECount SMALLINT, CPUUse FLOAT, PrcntKernel FLOAT, PrcntService FLOAT, PrcntUser FLOAT, DiskUse FLOAT, DiskReads FLOAT, DiskWrites FLOAT, DiskOutReqAvg FLOAT, NetAUse FLOAT, NetBUse FLOAT, NetReads FLOAT, NetWrites FLOAT, CICUse FLOAT, HstBlkRd FLOAT, HstBlkWrts FLOAT, MemAllocates FLOAT, MemAllocateKB FLOAT, MemFailures FLOAT, MemAgings FLOAT, NVMemAllocate FLOAT, NVMemAllocSegs FLOAT, NVMemAgings FLOAT )...;

Usage Notes

The MonitorPhysicalResource function returns the detailed resource usage information for each node. Because the function reports on each node, you can isolate performance concerns by node.

The MonitorPhysicalResource function provides similar functionality to a PMPC MONITOR PHYSICAL RESOURCE request. For information about this interface, see “MONITOR PHYSICAL RESOURCE” on page 88.

Page 248: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalResource

248 Workload Management API: PM/API and Open API

Result Rows

Column Name Description

ProcId The ID associated with a node. This value is computed as the module number within a cabinet plus 100 times the cabinet number. Usually formatted for display as zz9-99. However, this display format can be changed by the user.

Status The status of the node, AMP, or PE associated with this record. The following values apply:

• U = Up/online

• D = Down

• S = Standby

A vproc or node is up (U) when it is:

• Configured into the system

• Online

• Capable of actively performing tasks associated with normal Teradata Database activity

Down (D) represents all other potential states.

Standby (S) indicates the vproc or node is ready to join the configuration in place if another vproc or node goes down.

AmpCount The current number of AMPs currently executing on the associated node.

PECount The current number of active PEs on the associated node.

CPUUse The % of CPU usage not spent being idle. The node-level display is computed from ResUsageSpma table data as:

PercntUser + PercntService

The vproc-level displays is computed from ResUsageSvpr table data as:

100.00 * (CPUUExecPart00 + CPUUExecPart01 + ... + CPUUExecPart15 + CPUUServPart00 + CPUUServPart01 + ... + CPUUServPart15) / (x * SampleSec)

This value is NULL if:

• Nodes, AMPs, or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Page 249: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalResource

Workload Management API: PM/API and Open API 249

PrcntKernel The % of CPU resources spent in UNIX/PDE kernel processing. This value is computed from ResUsageSpma data as follows, where x is the number of CPUs:

CPUIOWAIT */(x * SampleSec)

This value is NULL if:

• Nodes are down or offline.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

PrcntService The % of CPU resources spent in UNIX/PDE user service processing. For node-level displays, the value is computed from the ResUsageSpma table data, where x represents the number of CPUs:

CPUUServ * (x * SampleSec)

For vproc-level displays, the value is computed from the ResUsageSvpr table data, where x represents the number of CPUs:

(CPUUServPart00 + CPUUServPart01 + ... + CPUUServPart15)* / (x * SampleSec)

This value is NULL if:

• Nodes, AMPs, or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

PrcntUser The % of CPU resources spent in non-service user code processing. This value is computed from the ResUsageSpma table data, where x represents the number of CPUs:

CPUUExec * / (x * SampleSec)

This value is NULL if:

• Nodes are down or offline.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Column Name Description

Page 250: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalResource

250 Workload Management API: PM/API and Open API

DiskUse The % of disk usage per node or AMP. For node-level displays, this value is computed from ResUsageSldv table data as follows, assuming n is the number of ldv controllers used by this node:

(LdvOutReqTime 1 + ... + LdvOutReqTime n) / (n*SampleSec)

For vproc-level displays, this value is computed from the ResUsageSvdsk table data, assuming it is the number of logical devices used by this AMP:

(OutReqTime 1 + ... + OutReqTime n) / SampleSec

Note: DiskUse does not take into account overlapping of operations among multiple storage controllers, but it allows for the possibility of multiple requests for the same controller.

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

DiskReads The total number of physical disk reads per node or AMP during the sample period. For node-level displays, this value is computed from ResUsageSpma table data as:

MemTextPageReads + MemCtxtPageReads + MemSwapReads + FileAcqReads

Note: You can determine node-level DiskReads by summing the vproc level values across all vprocs on a given node with the MemTextPageReads value for that node.

For vproc-level displays, this value is computed from the ResUsageSvpr table data as:

MemCtxtPageReads + MemSwapReads + FilePCiAcqReads + FilePDbAcqReads + FileSCiAcqReads + FileSDbAcqReads + FileTJtAcqReads + FileAPtAcqReads

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Column Name Description

Page 251: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalResource

Workload Management API: PM/API and Open API 251

DiskWrites The total number of physical disk writes per node or AMP during the sample period. For node-level displays, this value is computed from ResUsageSpma table data as:

MemCtxtPageWrites + FileWrites

Note: For the total number of node-level DiskWrites, add all the vproc values across all AMPs on a given node.

For vproc-level displays, this value is computed from ResUsageSvpr table data as:

MemCtxtPageWrites + FilePCiFWrites + FilePDbFWrites + FileSCiFWrites + FileSDbFWrites + FileTJtFWrites + FileAPtFWrites + FilePCiDyAWrites + FilePDbDyAWrites + FileSCiDyAWrites + FileSDbDyAWrites + FileTJtDyAFWrites + FileAPtDyAWrites

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made during the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

DiskOutReqAvg The average number of outstanding disk requests.

For node-level displays, this value is computed from ResUsageSldv table data as follows, assuming n is the number of ldv controllers used by this node:

(LdvOutReqSum 1 + ... + LdvOutReqSum n) / collectintervals

For vproc-level displays, this value is computed from ResUsageSvdsk table data, assuming n is the number of storage devices used by this vproc:

(ReadRespTot 1 + WriteRespTot 1 + ... + ReadRespTot n + WriteRespTot n) / SampleSec

This value is NULL if:

• Nodes, AMPs, or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Column Name Description

Page 252: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalResource

252 Workload Management API: PM/API and Open API

NetAUse The % of BYNET A usage. This is the actual BYNET receiver usage. (The BYNET transmitter usage is maintained in ResUsage separately and is typically lower than the receiver usage. This is caused by multicasts, where one transmitter sends a message to many receivers.) This value is computed from the ResUsageSpma table data as:

(netsamples ? nettxidle) / netsamples * 100.0

This value is NULL if:

• ResMonitor is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

NetBUse This field is obsolete. It returns the same value as NetAUse.

NetReads The number of Reads from the BYNET to the node or vproc during the sample period. For node-level displays, this value is computed from the ResUsageSpma table data as:

Netrxcircbrd + Netrxcircptp

For vproc-level displays, the value is computed from the ResUsageSvpr table data as:

NetBrdReads + NetPtPReads

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

NetWrites The number of messages written from the node, AMP, or PE to the BYNET during the sample period. For node-level displays, the value is computed from the ResUsageSpma table data as:

Nettxcircbrd + Nettxcircptp

For vproc-level displays, the value is computed from the ResUsageSvpr table data as:

NetBrdWrites + NetPtPWrites

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

CICUse This field is obsolete.

Column Name Description

Page 253: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalResource

Workload Management API: PM/API and Open API 253

HstBlkRds The number of message blocks (one or more messages sent in one physical group) received from all clients. For node-level displays, this value is computed from ResUsageShst data, assuming n is the number of vprocs on this node:

HostBlockReads1 + ... + HostBlockReadsn

For vproc-level displays, this value corresponds to the column totals in the DBC.ResUsage.Shst table supplying HostBlockReads for this vproc.

This value is NULL for:

• Down or offline nodes or PEs.

• AMPs.

• A request for data that is made before completion of the first sample period following a system outage.

• For nodes, a request for data that is made before the completion of the first sample period following a change in the ResMonitor rate.

• For PEs, a request for data that is made before the completion of the first sample period following a change in the VProcMonitor rate.

HstBlkWrts The number of message blocks (that is, one or more messages sent in one physical group) sent to all hosts. For node displays, this value is computed from ResUsageShst data, assuming n is the number of PEs on this node:

HostBlockWrites1 + ... + HostBlockWritesn

For PE display, this value corresponds to the column totals in the DBC.ResUsageShst table with the same names.

This value is NULL if:

• Nodes or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For PEs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Column Name Description

Page 254: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalResource

254 Workload Management API: PM/API and Open API

MemAllocates The number of segments allocated to memory resources. This value corresponds to the ResUsageSpma and ResUsageSvpr table columns with the same name.

This value is NULL if:

• Nodes are down or offline.

• AMPs or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

MemAllocateKB, MemAllocates, MemFailures, and MemAgings together indicate if memory resources are taxed, and may assist in determining if more memory is needed.

MemAllocateKB The number of KB allocated to memory resources. For node-level displays, the value is computed from the ResUsageSpma table data as:

(fixed_pg_size * MemTextAllocs) + MemVprAllocKB

Note: You can determine the node-level value, MemVprAllocKB, by summing vproc-level values across all vprocs on a given node.

For vproc-level displays the value is computed from the ResUsageSvpr table data as:

fixed_pg_size * (MemCtxtAllocs + MemPDbAllocKB + MemPCiAllocKB + ... + MemAPtAllocKB)

This value is NULL if:

• Nodes, AMPs, or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs and PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

For vproc-level displays, this value is computed from the ResUsageSvpr table data as:

MemCtxtAllocs + MemPDbAllocs + MemPCiAllocs + MemSDbAllocs + MemSCiAllocs + MemTJtAllocs + MemAPtAllocs

Column Name Description

Page 255: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalResource

Workload Management API: PM/API and Open API 255

MemFailures The number of failed segment allocation attempts.

A request retries until memory is allocated. Thus, a single request can fail several times. As a result, if this value is large for a single sampling interval, it is no cause for concern. On the other hand, if the value is large over several sampling intervals, there may be a memory resource problem. MemAllocateKB, MemAllocates, MemFailures, and MemAgings together indicate whether memory resources are taxed, and may help to determine if more memory is needed.

This value is NULL if:

• Nodes are down or offline.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

MemAgings The number of memory agings and collections done on old segments (per second per PE or AMP). This value corresponds to the ResUsageSpma table column with the same name.

MemAllocateKB, MemAllocates, MemFailures, and MemAgings together indicate if memory resources are taxed, and may assist in determining if more memory is needed.

Teradata Database manages the use of memory segments on a Least Recently Used (LRU) basis, where counters are assigned to each segment allocated. The counters are decremented for each aging cycle until the value reaches zero, whereupon the segment is collected (written to disk). If a segment is reused before the counter reaches zero, the counter is reset to its initial value.

This value is NULL if:

• Nodes are down or offline.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

NVMemAllocate This field is obsolete.

NVMemAllocSegs This field is obsolete.

NVMemAgings This field is obsolete.

Column Name Description

Page 256: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalResource

256 Workload Management API: PM/API and Open API

Example

SELECT t2.* FROM TABLE (MonitorPhysicalResource()) AS t2;

*** Query completed. One row found. 26 columns returned. *** Total elapsed time was 1 second.

ProcId 33 Status U AmpCount 8 PECount 1 CPUUse 0.00000000000000E 000 PrcntKernel 0.00000000000000E 000 PrcntService 0.00000000000000E 000 PrcntUser 0.00000000000000E 000 DiskUse 0.00000000000000E 000 DiskReads 0.00000000000000E 000 DiskWrites 0.00000000000000E 000 DiskOutReqAvg 0.00000000000000E 000 NetAUse 0.00000000000000E 000 NetBUse 0.00000000000000E 000 NetReads 0.00000000000000E 000 NetWrites 0.00000000000000E 000 CICUse 0.00000000000000E 000 HstBlkRds 0.00000000000000E 000 HstBlkWrts 0.00000000000000E 000 MemAllocates 0.00000000000000E 000 MemAllocateKB 0.00000000000000E 000 MemFailures 0.00000000000000E 000 MemAgings 0.00000000000000E 000 NVMemAllocate 0.00000000000000E 000NVMemAllocSegs 0.00000000000000E 000 NVMemAgings 0.00000000000000E 000

Page 257: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalSummary

Workload Management API: PM/API and Open API 257

MonitorPhysicalSummary

PurposeCollects global summary information that includes the following types of information:

• CPU usage: average by processor type (online only)

• Disk usage: average, high, and low, by processor ID

• BYNET usage: total, up/down

• Rate information: resource logging rate and resource usage monitoring rate

• Current software release and version numbers

Definition

REPLACE FUNCTION MonitorPhysicalSummary() RETURNS TABLE

(AvgCPU FLOAT, AvgDisk FLOAT, AvgDiskIO FLOAT, HighCPUUse FLOAT, HighDisk FLOAT, HighDiskIO FLOAT, HighCPUProcId SMALLINT, HighDiskProcId SMALLINT, HighDiskIOProcId SMALLINT, LowCPUUse FLOAT, LowDisk FLOAT, LowDiskIO FLOAT, LowCPUProcId SMALLINT, LowDiskProcId SMALLINT, LowDiskIOProocId SMALLINT, NetUse FLOAT, NetAUp CHAR(1), NetBUp CHAR(1), ResLogging SMALLINT, ResMonitor SMALLINT, ReleaseNum VARCHAR(30), Version VARCHAR(32) )...;

Usage Notes

The MonitorPhysicalSummary function provides similar functionality to a PMPC MONITOR PHYSICAL SUMMARY request. For information about this interface, see “MONITOR PHYSICAL SUMMARY” on page 108.

Page 258: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalSummary

258 Workload Management API: PM/API and Open API

Result Rows

Column Name Description

AvgCPU The average % CPU usage (CPUUse) time of all online nodes currently in the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate (the rate at which resource data is updated within memory) is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

AvgDisk The average % disk usage (from DiskUse) of all online nodes currently in the Teradata Database configuration.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Assuming n is the number of online AMPs in the configuration, AMPAvgDisk is computed from DiskUse data as:

(DiskUse1 + ... + DiskUsen) / n

AvgDiskIO The average physical disk DiskReads and DiskWrites of all online AMPs in the configuration.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period that following either a system outage or a change in the VProcMonitor rate.

Assuming n is the number of online AMPs in the configuration, AMPAvgDiskIO is computed from DiskReads and DiskWrites data as:

(DiskReads1 + DiskWrites1 + ... + DiskReads1 + DiskWritesn) / n

HighCPUUse The vproc ID of the AMP with the next highest in-use count in the system. A value of -1 (or NULLABLE) indicates this field is not defined.

HighDisk The highest % disk usage (from DiskUse) associated with any online node that is currently part of the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

HighDiskIO The ID of a node with DiskReads and DiskWrites equal to the value reported as HighDiskIO.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Page 259: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalSummary

Workload Management API: PM/API and Open API 259

HighCPUProcId The in-use count associated with the AMP 3 Vproc ID. This is only applicable if AMP 3 is defined.

HighDiskProcId The ID of a node with DiskUse equal to the value reported as HighDisk.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

HighDiskIOProcId The ID of a node with DiskReads and DiskWrites equal to the value reported as HighDiskIO.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

LowCPUUse The lowest CPUUse number associated with any online node that is currently part of the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

LowDisk The lowest % disk usage (from DiskUse) associated with any online node that is currently part of the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

LowDiskIO The lowest DiskReads and DiskWrites number associated with any online node that is currently part of the Teradata Database configuration.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

LowCPUProcId The ID of a node with CPPUse equal to the value reported as LowCPUUse.

This value is NULL if:

• The ResMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

LowDiskProcId The ID of a node with DiskUse equal to the value reported as LowDisk.

This value is NULL when LowDisk is NULL.

Column Name Description

Page 260: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalSummary

260 Workload Management API: PM/API and Open API

Example

sel * FROM TABLE (MonitorPhysicalSummary()) AS t1;

*** Query completed. One row found. 22 columns returned.

LowDiskIOProocId The ID of a node with DiskReads and DiskWrites equal to the value reported as LowDiskIO.

This value is NULL when LowDiskIO is NULL.

NetUse The % of total BYNET use; that is, average of the online BYNETs.

If both BYNETs are up, the value is computed from ResUsageSpma table data as:

(NetAUse + NetBUse) / 2

This value is NULL if:

• ResMonitor is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Note: ResUsage data for this field is not currently available. The NetAUse value returned is zero.

NetAUp,NetBUp

The status of the BYNETs (if there are more than two, the first two) on a system-wide basis.

The following values apply:

• D = Down/Offline

• U = Up/Online

• S = Standby

Note: The NetBUp value is always zero.

ResLogging The frequency at which node resource usage data is written to one or more active ResUsage database tables. The node ResUsage tables are named DBC.ResUsageXyyy, where Xyyy is Spma and Scpu (see Resource Usage Macros and Tables). A rate of zero turns off logging capability.

This rate can be changed with the SetResourceRate function. When changed, the rate is saved on disk (in the version record).

ResMonitor The rate at which node resource usage data is collected within memory for reporting. A rate of zero turns off sampling capability.

This rate can be changed with the SetResourceRate function. The rate is saved on disk when it is changed.

ReleaseNum The release number of the currently running Teradata Database software (for example, 13.00.00.00).

This value is supplied by Teradata Database.

Version The version number of the currently running Teradata Database software (for example, 13.00.00.00).

This value is supplied by Teradata Database.

Column Name Description

Page 261: Workload management api

Chapter 3: PMPC APIsMonitorPhysicalSummary

Workload Management API: PM/API and Open API 261

*** Total elapsed time was 1 second.

AvgCPU 0.00000000000000E 000 AvgDisk 3.66666666666667E 000 AvgDiskIO 2.47300000000000E 003 HighCPUUse 0.00000000000000E 000 HighDisk 3.66666666666667E 000 HighDiskIO 2.47300000000000E 003 HighCPUProcId 33 HighDiskProcId 33HighDiskIOProcId 33 LowCPUUse 0.00000000000000E 000 LowDisk 3.66666666666667E 000 LowDiskIO 2.47300000000000E 003 LowCPUProcId 33 LowDiskProcId 33LowDiskIOProocId 33 NetUse 0.00000000000000E 000 NetAUp NetBUp ResLogging 600 ResMonitor 600 ReleaseNum 13.00.00.00

Version 13.00.00.00

Page 262: Workload management api

Chapter 3: PMPC APIsMonitorSession

262 Workload Management API: PM/API and Open API

MonitorSession

PurposeCollects current status and activity information for one or more logged on sessions.

Definition

REPLACE FUNCTION MonitorSession (HostIdIn SMALLINT,

UserNameIn VARCHAR(30), SessionNoIn INTEGER

RETURNS TABLE(HostId SMALLINT,

SessionNo INTEGER, LogonPENo SMALLINT, RunVprocNo SMALLINT, PartName VARCHAR(16), PEstate VARCHAR(18), LogonTime VARCHAR(22), UserId INTEGER, LSN INTEGER, UserName VARCHAR(30), UserAccount VARCHAR(30), PECPUsec FLOAT, XActCount FLOAT, ReqCount FLOAT, ReqCacheHits FLOAT, AMPState VARCHAR(18), AMPCPUSec FLOAT, AMPIO FLOAT, ReqSpool FLOAT, Blk1HostId SMALLINT, Blk1SessNo INTEGER, Blk1UserId INTEGER, Blk1Lmode CHAR, Blk1Otype CHAR, Blk1ObjDBID INTEGER, Blk1ObjTID INTEGER, Blk1Status CHAR, Blk2HostId SMALLINT, Blk2SessNo INTEGER, Blk2UserId INTEGER, Blk2Lmode CHAR, Blk2Otype CHAR, Blk2ObjDBID INTEGER, Blk2ObjTID INTEGER, Blk2Status CHAR, Blk3HostId SMALLINT, Blk3SessNo INTEGER, Blk3UserId INTEGER, Blk3Lmode CHAR,

Page 263: Workload management api

Chapter 3: PMPC APIsMonitorSession

Workload Management API: PM/API and Open API 263

Blk3Otype CHAR, Blk3ObjDBID INTEGER, Blk3ObjTID INTEGER, Blk3Status CHAR, MoreBlockers CHAR, LogonSource VARCHAR(128), HotAmp1CPU FLOAT, HotAmp2CPU FLOAT, HotAmp3CPU FLOAT, HotAmp1CPUId FLOAT, HotAmp2CPUId FLOAT, HotAmp3CPUId FLOAT, HotAmp1IO FLOAT, HotAmp2IO FLOAT, HotAmp3IO FLOAT, HotAmp1IOId INTEGER, HotAmp2IOId INTEGER, HotAmp3IOId INTEGER, LowAmp1CPU FLOAT, LowAmp2CPU FLOAT, LowAmp3CPU FLOAT, LowAmp1CPUId INTEGER, LowAmp2CPUId INTEGER, LowAmp3CPUId INTEGER, LowAmp1IO FLOAT, LowAmp2IO FLOAT, LowAmp3IO FLOAT, LowAmp1IOId INTEGER, LowAmp2IOId INTEGER, LowAmp3IOId INTEGER, AvgAmpCPUSec FLOAT, AvgAmpIOCnt FLOAT, AmpCount INTEGER, TempSpaceUsg FLOAT, ReqStartTime VARCHAR(22), ReqCPU FLOAT, ReqIO FLOAT, ReqNo INTEGER, WlcId INTEGER, DontReclassifyFlag SMALLINT,

ProxyUser VARCHAR (128), )...;

Input Parameters

Parameter Description

HostIdIn The logical ID of a host (or client) with sessions logged on.

A value of -1 indicates all hosts.

UserNameIn The user name of the session specified.

An asterisk (*) indicates all users.

Page 264: Workload management api

Chapter 3: PMPC APIsMonitorSession

264 Workload Management API: PM/API and Open API

Usage Notes

This table function is only supported in Constant Mode.

The following CPU fields in the MonitorSession response are affected by the MonSesCPUNormalization field:

The MonSesCPUNormalization field, a DBS Control General Record field, controls whether normalized or non-normalized statistical CPU data is reported by the functions: MonitorSession and MonitorMySessions, and by the MONITOR SESSION request. For more information about the MonSesCPUNormalization field and CPU normalization, see the DBS Control utility in Utilities.

For a complete description of these fields, see the topic that follows.

You can also refer to “MonitorMySessions” on page 231 or “MONITOR SESSION” on page 116 for a list of these CPU fields.

The MonitorSession function provides similar functionality to a PMPC MONITOR SESSION request. For information about this interface, see “MONITOR SESSION” on page 116.

Result Rows

SessionNoIn The number of the session specified.

A value of zero indicates all sessions.

Parameter Description

• AMPCPUSec

• AvgAmpCPUSec

• HotAmp1CPU

• HotAmp2CPU

• HotAmp3CPU

• LowAmp1CPU

• LowAmp2CPU

• LowAmp3CPU

• PECPUSec

• RequestAmpCPU

Column Name Description

HostId The logical host ID associated with a PE or session. For a PE, HostId identifies one of the hosts or LANs associated with the described PE. For a session, the combination of a host ID and a session number uniquely identifies a user session on the system.

Note: This value is NULL for AMPs. A value of zero represents the Supervisor window.

SessionNo The number of the current session. Together with a given host ID, a session number uniquely identifies a session on the Teradata Database system. This value is assigned by the host (or client) at logon time.

Page 265: Workload management api

Chapter 3: PMPC APIsMonitorSession

Workload Management API: PM/API and Open API 265

LogonPENo The Vproc number of the PE the session is currently logged on to; it identifies the PE that has control responsibility for the session. Normally, this is the PE that processed the logon request; but if that PE goes offline, it will be the PE to which the session was switched.

RunVprocNo The Vproc number of the AMP or PE currently assigned to process the session requests.

For sessions in Teradata SQL partitions, this value is identical to the LogonPENo. For sessions in FastLoad or MultiLoad partitions, this is the AMP that initially processes the data being loaded. For HUTPARSE or HUTCTL (Archive/Restore) sessions, this value is NULL.

If a RunVprocNo value of -1 in record mode or NULL in indicator mode is returned by MonitorSession for FastLoad, MultiLoad or FastExport sessions, this indicates that the session is in the process of starting up.

PartName The name of the session partition associated with this session. Following a successful logon request by a session or as part of a connect request, the session identifies the partition with which the user wants the session to be associated. FASTLOAD, Teradata SQL, MONITOR, INTERNAL are examples of valid partition names.

PEstate The current state of the session within the PE.

For a list of the different session states, see the MONITOR SESSION PEState field.

LogonTime The date and time portion of the information recorded by Session Control when a session successfully logs on. It is usually formatted for display as yyyy/mm/dd 99:99:99.99, which represents the year, month, day, hours: minutes: seconds.

UserId The user or internal ID of a user for this session. Within the Teradata Database, UserId is equivalent to Database ID. Typically, UserId is used when the associated record is known to be a user name, and Database ID is used when the associated record is known to be a database. However, UserId can identify either a given user or database name.

LSN The Logon Sequence Number (LSN) that is associated with a session when the session logs on. It identifies a collection of sessions performing a related activity. For example, in a FastLoad job, a user is logged on as a Teradata SQL session, as well as n FastLoad sessions with the same user name. Therefore, n+1 sessions (1 Teradata SQL and n FastLoad) with the same LSN are all associated with the given FastLoad job. To see how the FastLoad job is doing, the user can pick out all sessions reported with the same LSN number.

Note: This information supplies the parent-child relationship for sessions involved with FastLoad, MultiLoad, and Archive and Recovery jobs.

UserName The user name of the session. This is the name specified when the user is created; it is used to log on to a session. Within Teradata Database, user name is almost equivalent to database name.

Column Name Description

Page 266: Workload management api

Chapter 3: PMPC APIsMonitorSession

266 Workload Management API: PM/API and Open API

UserAccount The account currently with which the user is logged in. When a user is created or altered, that user is allowed to run in association with one or more accounts. During the logon process, a particular user session establishes its priority and charges resource usage to one of the allowed accounts.

PECPUsec The CPU time, in seconds, used in a PE by the associated session for parsing and dispatching requests. It is accurate to the second.

This value is valid only when associated with Teradata SQL and MONITOR partition sessions. The value is NULL when it is returned for all other sessions.

XActCount The number of explicit and implicit transactions executed by the session.

This value is valid only when returned for Teradata SQL sessions, and is NULL for all other partition sessions. For this value, you must make a request for data before completion of the first sample period that follows either a system outage or a change in the VProcMonitor rate.

ReqCount The number of requests (Tequel Start Request (TSR) messages) initiated by the session.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or change in the VProcMonitor rate.

ReqCacheHits The number of times that this session processed a request using information from the Teradata SQL Parser request cache, specifically, how many times there was a request cache hit.

This value is valid only for Teradata SQL sessions, and is NULL for all other partition sessions. This value is also NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

AMPState The current state of the associated session in AMP vprocs in decreasing priority:

• ABORTING: The transaction is being rolled back; session is aborting.

• BLOCKED: Some background activity is in progress and the last request is on hold until this background activity is completed.

• ACTIVE: Normal, on-going activity is being done by this session.

• IDLE: No work in progress for this session on any AMP.

• UNKNOWN: No recorded activity by this session since monitoring began.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Column Name Description

Page 267: Workload management api

Chapter 3: PMPC APIsMonitorSession

Workload Management API: PM/API and Open API 267

AMPCPUSec The current elapsed CPU time, in seconds, used on all AMPs by the associated session for executing requests. For example, for Teradata SQL requests, this is the time spent by the Teradata Database actively working or rolling back an aborted transaction. This does not include any UNIX/PDE CPU time spent handling Teradata Database requests. This value is accurate to the second.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

AMPIO The current number of logical Reads and Writes issued across all AMPs by the associated session.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

ReqSpool The current spool used by current request across all AMPs, expressed as a number of bytes.

This value is NULL when a request for data is made before completion of the first sample period following either a system outage or a change in the ResMonitor rate.

Blk1HostId,

Blk2HostId,

Blk3HostId

The logical host ID of a session causing a block. This value is derived from equating the transactions causing a Teradata Database lock conflict to the sessions that issued those transactions. The Blk_x_HostId in combination with Blk_x_SessNo uniquely identifies the session that is causing a block.

A valid value is not returned if an inactive Archive/Recovery job is causing the lock conflict, because no session is logged in.

This value is NULL if:

• The host ID is not available.

• The session does not have an AMPState of BLOCKED.

If the Blk_x_HostId, Blk_x_SessNo, and Blk_x_UserID values all return as NULLs and AMPState is BLOCKED, a Host Utility (HUT) lock left over after the session holding the lock was aborted or logged off. The lock was never released, and no blocking information is available because the session no longer exists.

Use the Show Locks utility to obtain the user name that placed the HUT lock. For more information, see Utilities.

Column Name Description

Page 268: Workload management api

Chapter 3: PMPC APIsMonitorSession

268 Workload Management API: PM/API and Open API

Blk1SessNo,

Blk2SessNo,

Blk3SessNo

The number of the session causing a block. This value is derived from associating the transactions causing a lock conflict to the sessions that issued those transactions. The Blk_x_SessNo in combination with Blk_x_HostId uniquely identifies the session causing a block.

This information is unavailable if an inactive Archive/Recovery job is causing the lock conflict.

This value is NULL if:

• SessNo is not available.

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

If the Blk_x_HostId, Blk_x_SessNo, and Blk_x_UserID values all return as NULLs and AMPState is BLOCKED, a host utility lock left over after the session holding the lock was aborted or logged off. The lock was never released, and no blocking information is available because the session no longer exists.

Use the Show Locks utility to obtain the user name that placed the HUT lock. For more information, see Utilities.

Blk1UserId,

Blk2UserId,

Blk3UserId

The ID of the user or host utility job preventing the session from being granted a lock. This information is especially important when an Archive/Recovery job is holding the lock, because the user ID is the only information available about who placed the lock.

This value is NULL if:

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

If the Blk_x_HostId, Blk_x_SessNo, and Blk_x_UserID values all return as NULLs and AMPState is BLOCKED, a host utility lock left over after the session holding the lock was aborted or logged off. The lock was never released, and no blocking information is available because the session no longer exists.

Use the Show Locks utility to obtain the user name that placed the HUT lock. For more information, see Utilities.

Column Name Description

Page 269: Workload management api

Chapter 3: PMPC APIsMonitorSession

Workload Management API: PM/API and Open API 269

Blk1Lmode,

Blk2Lmode,

Blk3Lmode

The mode (severity) of the lock involved in causing a block.

The following values apply:

• E = Exclusive

• W = Write

• R = Read

• A = Access

Locks are reported in decreasing order of severity because removing the most severe lock conflict may eliminate the source of the lock conflict.

This value is NULL if:

• The session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

A session may be blocked by either a granted lock or an ungranted lock that precedes the blocked lock in the queue and is in conflict with the lock requested by this blocked session. For information on whether the lock is granted, see the MONITOR SESSSION fields: Blk_1_Status, Blk_2_Status, and Blk_3_Status.

Blk1Otype,

Blk2Otype,

Blk3Otype

The type of object whose lock is causing the session described by the associated row to be blocked:

• D = Database

• T= Table

• R = Row hash

However, this object is not necessarily the type of object the blocked session is trying to access. For example, if the session is requesting a row hash lock, the blocking object could be a database, table, or row hash.

This value is NULL if:

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

For a Table T, it is possible for User A to block User B with a table level lock on Table T on AMP_1 and with a Row Hash Level lock on that same Table T on AMP_2. When that occurs, the only lock conflict reported is that User B is blocked by User A on a table.

Column Name Description

Page 270: Workload management api

Chapter 3: PMPC APIsMonitorSession

270 Workload Management API: PM/API and Open API

Blk1ObjDBID,

Blk2ObjDBID,

Blk3ObjDBID

The unique ID of the database object over which a lock conflict is preventing the session from being granted a lock.

Within the Teradata Database system, Database ID is equivalent to User ID. Typically, User ID is used when the associated record is known to be a user name, and Database ID is used when the associated record is known to be a database. However, Database ID can identify either a user or database name.

This value is NULL if:

• The session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Blk1ObjTID,

Blk2ObjTID,

Blk3ObjTID

The unique ID of the table object over which a lock conflict is preventing the session from being granted a lock.

This value is NULL if:

• The session does not have an AMPState of BLOCKED.

• The BlkxOType is D.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Blk1Status,

Blk2Status,

Blk3Status

The status of lock causing a block:

• W= Waiting

• G = Granted

This value is NULL if:

• Session does not have an AMPState of BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Note: A lock request may be blocked by either a granted lock or an ungranted lock that precedes the blocked lock request in the queue and is in conflict with it.

A status of Waiting has a higher priority than that of Granted when there is more than one lock involved. For example, for a given object and a given session, a session that is blocked by a Waiting lock on one AMP and a Granted lock on another AMP has Waiting reported as its status.

MoreBlockers An indicator of more lock conflicts. The following values apply:

• Blank = Blkx information is a complete list of sessions blocking the session described.

• Asterisk (*) = additional sessions are blocking the session described. The Blkx information shows only three blocking sessions.

This value is NULL if:

• The state of the session is not BLOCKED.

• A request for data is made before completion of the first sample period following either a system outage or a change in the SesMonitorLoc or SesMonitorSys rate.

Column Name Description

Page 271: Workload management api

Chapter 3: PMPC APIsMonitorSession

Workload Management API: PM/API and Open API 271

LogonSource The logon source information. At logon time, this information is optionally supplied by the Teradata Director Program or the LAN Gateway to further identify the physical or logical location of the session, the logon user name, and the interface under which the session was initiated. (For example, the data string may include DBC as the user ID and BTEQ as the interface.)

Note: A two-byte value precedes the LogonSource data to indicate the length of the string. The length value is zero if LogonSource is NULL.

For a list of the commonly seen LogonSource string application names, see SQL Data Definition Language.

HotAmp1CPU The CPU time of the highest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp2CPU The CPU time of the second highest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp3CPU The CPU time of the third highest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

HotAmp1CPUId The vproc ID of the highest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp2CPUId The vproc ID of the second highest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp3CPUId The vproc ID of the third highest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs in the system.

HotAmp1IO The IO count of the highest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp2IO The IO count of the second highest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp3IO The IO count of the third highest IO utilized AMP for the last collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs in the system.

Column Name Description

Page 272: Workload management api

Chapter 3: PMPC APIsMonitorSession

272 Workload Management API: PM/API and Open API

HotAmp1IOId The vproc ID of the highest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp2IOId The vproc ID of the second highest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

HotAmp3IOId The vproc ID of the third highest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs in the system.

LowAmp1CPU The CPU time of the lowest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp2CPU The CPU time of the second lowest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp3CPU The CPU time of the third lowest CPU utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

LowAmp1CPUId The vproc ID of the lowest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp2CPUId The vproc ID of the second lowest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp3CPUId The vproc ID of the third lowest CPU utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

LowAmp1IO The IO count of the lowest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp2IO The IO count of the second lowest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp3IO The IO count of the third lowest IO utilized AMP during the collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

Column Name Description

Page 273: Workload management api

Chapter 3: PMPC APIsMonitorSession

Workload Management API: PM/API and Open API 273

LowAmp1IOId The vproc ID of the lowest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp2IOId The vproc ID of the second lowest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires.

LowAmp3IOId The vproc ID of the third lowest IO utilized AMP for the last session collection interval.

This value is NULL if the request is made before the sample period expires, and if there are only two AMPs on the system.

AvgAmpCPUSec The average AMP CPU utilization for the last session collection interval. The average is calculated as the sum of CPU utilization for all amps participating divided by the number of online AMPs.

This value is NULL if the request is made before the sample period expires.

AvgAmpIOCnt Average AMP IO utilization for the last session collection interval. The average is calculated as the sum of IO utilization for all AMPs participating divided by the number of online AMPs.

This value is NULL if the request is made before the sample period expires.

AmpCount The current number of AMPs currently executing on the associated node.

TempSpaceUsg Total amount, in bytes, of temporary space used by the session.

This value is NULL if the session did not materialize any temporary tables.

ReqStartTime The date and time of the current request on the session started. It is usually formatted for display as yyyy/mm/dd 99:99:99.99, which represents the year, month, day hours: minutes: seconds.

ReqCPU The total CPU usage by the current SQL request on the session on all AMPs. This value contains proper request-level statistics for DBC/SQL sessions running SQL requests only. Ignore the value returned in this field for other types of sessions, such as DBC/SQL sessions linked to a utility job.

This field is equivalent to the MONITOR SESSION field RequestAmpCPU.

ReqIO The total number of accesses by the current SQL request for the session on all AMPs. This value contains proper request-level statistics for DBC/SQL sessions running SQL requests only. Ignore the value returned in this field for other types of sessions, such as DBC/SQL sessions linked to a utility job.

This field is equivalent to the MONITOR SESSION field “RequestAmpI/O.”

ReqNo The Active Request Number.

If no request is running, then a value of zero or NULL is displayed in indicator mode.

WDId The workload class ID associated with the specified request.

Column Name Description

Page 274: Workload management api

Chapter 3: PMPC APIsMonitorSession

274 Workload Management API: PM/API and Open API

Example 1

sel * FROM TABLE (MonitorSession(1,'trustuser1',0)) AS t1;

*** Query completed. One row found. 80 columns returned. *** Total elapsed time was 2 seconds.

HostId 1 SessionNo 1003 LogonPENo 16383 RunVprocNo 6383 PartName DBC/SQL PEstate IDLE LogonTime 2007/12/20 13:44:44.00 UserId 1120 LSN 0 UserName TRUSTUSER1 UserAccount DBC PECPUsec 4.70000000000000E-002 XActCount 0.00000000000000E 000 ReqCount 2.00000000000000E 000 ReqCacheHits 0.00000000000000E 000 AMPState IDLE AMPCPUSec 0.00000000000000E 000 AMPIO 4.00000000000000E 000 ReqSpool 0.00000000000000E 000 Blk1HostId 0 Blk1SessNo 0 Blk1UserId 0 Blk1Lmode Blk1Otype Blk1ObjDBID 0 Blk1ObjTID 0 Blk1Status Blk2HostId 0 Blk2SessNo 0 Blk2UserId 0 Blk2Lmode Blk2Otype Blk2ObjDBID 0 Blk2ObjTID 0 Blk2Status Blk3HostId 0 Blk3SessNo 0 Blk3UserId 0 Blk3Lmode

DontReclassifyFlag A flag indicating that the next request on the session will not be classified but will use the workload definition ID (WlcId) already assigned to the session. This will occur if this is a utility session or a WlcId was assigned to the session using the TDWMAssignWD function or the TDWM WD ASSIGNMENT request. For more information on these APIs, see Chapter 4: “Teradata Dynamic Workload Management APIs.”

ProxyUser The name of the proxy user if this session has a proxy connection.

Column Name Description

Page 275: Workload management api

Chapter 3: PMPC APIsMonitorSession

Workload Management API: PM/API and Open API 275

Blk3Otype Blk3ObjDBID 0 Blk3ObjTID 0 Blk3Status MoreBlockers LogonSource (TCP/IP) 042B 192.168.106.128 DG2 5276 A HotAmp1CPU 0.00000000000000E 000 HotAmp2CPU 0.00000000000000E 000 HotAmp3CPU 0.00000000000000E 000 HotAmp1CPUId 0 HotAmp2CPUId 0 HotAmp3CPUId 0 HotAmp1IO 0.00000000000000E 000 HotAmp2IO 0.00000000000000E 000 HotAmp3IO 0.00000000000000E 000 HotAmp1IOId 0 HotAmp2IOId 0 HotAmp3IOId 0 LowAmp1CPU 0.00000000000000E 000 LowAmp2CPU 0.00000000000000E 000 LowAmp3CPU 0.00000000000000E 000 LowAmp1CPUId 0 LowAmp2CPUId 0 LowAmp3CPUId 0 LowAmp1IO 0.00000000000000E 000 LowAmp2IO 0.00000000000000E 000 LowAmp3IO 0.00000000000000E 000 LowAmp1IOId 0 LowAmp2IOId 0 LowAmp3IOId 0 AvgAmpCPUSec 0.00000000000000E 000 AvgAmpIOCnt 0.00000000000000E 000 AmpCount 0 TempSpaceUsg 0.00000000000000E 000 ReqStartTime 0000/00/00 00:00:00.00 ReqCPU 0.00000000000000E 000 ReqIO 0.00000000000000E 000 ReqNo 0 WlcId 0DontReclassifyFlag 255 ProxyUser PXYUSER3

Example 2

SELECT Hostid, sessionNo, username FROM TABLE (MonitorSession(-1,'*',0)) AS t2;

*** Query completed. 6 rows found. 3 columns returned. *** Total elapsed time was 1 second.

HostId SessionNo UserName----------- ----------- ------------------------------ 1 1045 USER14 1 1046 USER14 1 1047 USER14 1 1048 USER14 1 1049 TDWM 1 1050 TDWMOA

Page 276: Workload management api

Chapter 3: PMPC APIsMonitorSessionRate

276 Workload Management API: PM/API and Open API

MonitorSessionRate

PurposeReturns the sample rate that was set for updating session-level statistics within memory.

Definition

REPLACE FUNCTION MonitorSessionRate(HostIdIn SMALLINT,

UserNameIn VARCHAR(30), SessioNoIn INTEGER

RETURNS SMALLINT...;

Input Parameters

Usage Notes

Before you monitor the sample rate, you use the SetSessionRate function to set the sample rate for updating session-level statistics within memory.

The MonitorSessionRate function provides similar functionality to a PMPC Monitor Session request. For information about this interface, see “MONITOR SESSION” on page 116.

Return Value

This function returns the sample rate (that is, the duration of the sample period in seconds).

Parameter Description

HostIdIn The logical ID of a host (or client) with sessions logged on.

A value of -1 indicates all hosts.

UserNameIn The user name of the sessions specified.

An asterisk (*) indicates all users.

SessionNoIn The number of the session specified.

A value of zero indicates all sessions.

Page 277: Workload management api

Chapter 3: PMPC APIsMonitorSessionRate

Workload Management API: PM/API and Open API 277

Example

SELECT MonitorSessionRate(1,'*',0);

*** Query completed. One row found. One column returned. *** Total elapsed time was 7 seconds.

MonitorSessionRate(1, '*', 0)----------------------------- 60

Page 278: Workload management api

Chapter 3: PMPC APIsMonitorSQLCurrentStep

278 Workload Management API: PM/API and Open API

MonitorSQLCurrentStep

PurposeReturns data about the step being executed of the currently running request for the specified host, session, and vproc.

Definition

REPLACE FUNCTION MonitorSQLCurrentStep (HostIdIn SMALLINT, SessionNoIn INTEGER, RunVProcNo SMALLINT) RETURNS TABLE (HostId SMALLINT, SessionNo INTEGER, NumOfSteps SMALLINT, CurLvl1StepNo SMALLINT, CurLvl2StepNo SMALLINT )...;

Input Parameters

Usage Notes

This table function is only supported in Constant Mode.

The MonitorSQLCurrentStep function provides similar functionality to a PMPC MONITOR SQL request. For information about this interface, see “MONITOR SQL” on page 147.

Parameter Description

HostIdIn The logical ID of a host (or client) with sessions logged on.

SessionNoIn The session number of the SQL to monitor.

RunVprocNo The PE vproc number where the session runs.

Page 279: Workload management api

Chapter 3: PMPC APIsMonitorSQLCurrentStep

Workload Management API: PM/API and Open API 279

Result Rows

Example

sel * from table(MonitorSQLCurrentStep(1, 1083, 16383)) as t1;

*** Query completed. One row found. 5 columns returned. *** Total elapsed time was 1 second.

HostId 1 SessionNo 1083 NumOfSteps 4CurLvl1StepNo 1CurLvl2StepNo 1

BTEQ -- Enter your DBC/SQL request or BTEQ command:

Column Name Description

HostId The logical host ID associated with a PE or session. For a PE, HostId identifies one of the hosts or LANs associated with the described PE. For a session, the combination of a host ID and a session number uniquely identifies a user session on the system.

Note: This value is NULL for AMPs. A value of zero represents the Supervisor window.

SessionNo The number of the current session. Together with a given host ID, a session number uniquely identifies a session on the Teradata Database system. This value is assigned by the host (or client) at logon time.

NumOfSteps The number of steps contained in the description text.

CurLvl1StepNo The number of the currently executing step. If parallel steps are executing, it is the number of the lowest executing step.

CurLvl2StepNo The number of the currently executing step. If parallel steps are executing, it is the number of the highest executing step. If only one step is executing, CurLvl1StepNo and CurLvl2StepNo are identical.

Page 280: Workload management api

Chapter 3: PMPC APIsMonitorSQLSteps

280 Workload Management API: PM/API and Open API

MonitorSQLSteps

PurposeReturns the steps text (a scaled-down version of the output of the EXPLAIN request modifier) of the currently running request for the specified host, session, and vproc.

Definition

REPLACE FUNCTION MonitorSQLSteps (HostIdIn SMALLINT, SessionNoIn INTEGER, RunVProcNo SMALLINT) RETURNS TABLE (HostId SMALLINT, SessionNo INTEGER, StepNum SMALLINT, Confidence SMALLINT, EstRowCount FLOAT, ActRowCount FLOAT, EstElapsedTime FLOAT, ActElapsedTime FLOAT, SQLStep VARCHAR(128) )...;

Input Parameters

Usage Notes

This table function is only supported in Constant Mode.

The MonitorSQLSteps function provides similar functionality to a PMPC MONITOR SQL request. For information about this interface, see “MONITOR SQL” on page 147.

Parameter Description

HostIdIn The logical ID of a host (or client) with sessions logged on.

SessionNoIn The session number of the SQL to monitor.

RunVprocNo The PE vproc number where the session runs.

Page 281: Workload management api

Chapter 3: PMPC APIsMonitorSQLSteps

Workload Management API: PM/API and Open API 281

Result Rows

ExampleSELECT t2.StepNum, t2.EstRowCount, t2.SQLStep FROMTABLE (MonitorSQLSteps(1, 1001, 16382)) AS t2;

*** Query completed. 12 rows found. 3 columns returned. *** Total elapsed time was 38 seconds.

StepNum EstRowCount SQLStep------- ---------------------- ------------------------------------------- 1 0.00000000000000E 000 First, lock DBAAA."pseudo table" for read on a row hash. 2 0.00000000000000E 000 Next, we lock DBAAA.SKEWAMP1 for read.

3 1.25440000000000E 004 We do an All-AMPs RETRIEVE step from DBAAA.SKEWAMP1 by way of an all-rows scan into Spool 6, which is duplicated on all AMPs. This step begins a parallel block of steps.

3 1.25440000000000E 004 We do an All-AMPs RETRIEVE step from DBAAA.SKEWAMP1 by way of an all-rows scan into Spool 7, which is duplicated on all AMPs. This step is performed in parallel.

3 1.25440000000000E 004 We do an All-AMPs RETRIEVE step from DBAAA.SKEWAMP1 by way of an all-rows scan into Spool 8, which is duplicated on all AMPs. This step ends a parallel block of steps.

4 2.45862400000000E 006 We do an All-AMPs JOIN step from Spool 6 (Last Use) by way of an all-rows scan, which is joined to table SKEWAMP1. Spool 6 and table SKEWAMP1 are joined using a product join. The result goes into Spool 9, which is built

4 1.25440000000000E 004 We do an All-AMPs RETRIEVE step from DBAAA. SKEWAMP1 by way of an all-rows scan into Spool 10, which is duplicated on all AMPs. This step is performed in parallel.

4 2.45862400000000E 006 We do an All-AMPs JOIN step from Spool 7 (Last Use) by way of an all-rows scan, which is joined to table SKEWAMP1. Spool 7 and table SKEWAMP1 are joined using aproduct join The result goes into Spool 11, which is built

Column Name Description

HostId The logical host ID associated with a PE or session. For a PE, HostId identifies one of the hosts or LANs associated with the described PE. For a session, the combination of a host ID and a session number uniquely identifies a user session on the system.

Note: This value is NULL for AMPs. A value of zero represents the Supervisor window.

SessionNo The number of the current session. Together with a given host ID, a session number uniquely identifies a session on the Teradata Database system. This value is assigned by the host (or client) at logon time.

StepNum The unique number identifying the EXPLAIN step.

Confidence The confidence level as determined by the optimizer. The following values apply:

• 0 = Low

• 2 = Medium

• 3 = High

EstRowCount This is the row count generated from the Optimizer plan.

ActRowCount This is the row count that is returned from the AMP for this step.

EstElapsedTime This is the estimated time for the query as generated from the Optimizer plan.

ActElapsedTime This is the actual elapsed time calculated by the dispatcher.

SQLStep Generated text for the step.

Page 282: Workload management api

Chapter 3: PMPC APIsMonitorSQLSteps

282 Workload Management API: PM/API and Open API

5 3.85512243200000E 009 We do an All-AMPs JOIN step from Spool 8 (Last Use) by way of an all-rows scan, which is joined to Spool 9. Spool 8 and Spool 9 are joined using a product join. The result goes into Spool 12, which is built locally on the AMPs. This step begins a parallel block of

5 3.08409794560000E 010 We do an All-AMPs JOIN step from Spool 10 (Last Use) by way of an all-rows scan, which is joined to Spool 11. Spool 10 and Spool 11 are joined using a product join. The result goes into Spool 13, which is duplicated on all AMPs. This step ends a parallel block of

6 1.48619689657096E 019 We do an All-AMPs JOIN step from Spool 12 (Last Use) by way of an all-rows scan, which is joined to Spool 13. Spool 12 and Spool 13 are joined using a product join. The result goes into Spool 5, which is built locally on the AMPs.

7 0.00000000000000E 000 We send out an END TRANSACTION step to all AMPs involved in processing the request.

Page 283: Workload management api

Chapter 3: PMPC APIsMonitorSQLText

Workload Management API: PM/API and Open API 283

MonitorSQLText

PurposeReturns the SQL text of the request currently being executed for the specified host, session, and vproc.

Definition

REPLACE FUNCTION MonitorSQLText (HostIdIn SMALLINT, SessionNoIn INTEGER, RunVProcNo SMALLINT) RETURNS TABLE (HostId SMALLINT, SessionNo INTEGER,

SeqNum SMALLINT, SQLTxt VARCHAR(31000) )...;

Input Parameters

Usage Notes

This table function is only supported in Constant Mode.

The MonitorSQLText function provides similar functionality to a PMPC MONITOR SQL request. For information about this interface, see “MONITOR SQL” on page 147.

Result Rows

Parameter Description

HostIdIn The logical ID of a host (or client) with sessions logged on.

SessionNoIn The session number of the SQL to monitor.

RunVprocNo The PE vproc number where the session runs.

Column Name Description

HostId The host ID of the sqltext.

SessionNo The session number of the sqltext.

Page 284: Workload management api

Chapter 3: PMPC APIsMonitorSQLText

284 Workload Management API: PM/API and Open API

Example

SELECT SQLTxt FROM TABLE (MonitorSQLText(1, 1001, 16383)) AS t2;

*** Query completed. One row found. One column returned. *** Total elapsed time was 58 seconds.

SQLTxt------------------------------------------------------------------------select a11.c1, a12.c1, a13.c1, a21.c1, a22.c1, a23.c1 from dbaaa.skewAmp1 a11, dbaaa.skewAmp1 a12, dbaaa.skewAmp1 a13, dbaaa.skewAmp1 a21, dbaaa.skewAmp1 a22, dbaaa.skewAmp1 a23;

SeqNum The sequence number of the row. For example, if the SQL text exceeds 31,000 bytes, then the system will return multiple rows.

SQLTxt The SQL text of the running request.

Column Name Description

Page 285: Workload management api

Chapter 3: PMPC APIsMonitorVirtualConfig

Workload Management API: PM/API and Open API 285

MonitorVirtualConfig

PurposeCollects information on virtual processor (vproc) availability.

Definition

REPLACE FUNCTION MonitorVirtualConfig() RETURNS TABLE (ProcId SMALLINT, VprocNo SMALLINT, Vproctype VARCHAR(3), HostId SMALLINT, Status CHAR, DiskSlice SMALLINT

)...;

Usage Notes

The MonitorVirtualConfig function provides similar functionality to a PMPC MONITOR VIRTUAL CONFIG request. For more information, see “MONITOR VIRTUAL CONFIG” on page 159.

Result Rows

Column Name Description

ProcId The ID associated with a node. This value is computed as the module number within a cabinet plus 100 times the cabinet number. Usually formatted for display as zz9-99. However, this display format can be changed by the user.

VprocNo The ID of an AMP (that is, a set of disks and the associated tasks or processes that, in combination, make up the AMP), PE, or VSS vproc.

Vproctype The type of vproc: AMP, PE, and VSS.

HostId The logical host ID associated with a PE or session. For a PE, HostId identifies one of the hosts or LANs associated with the described PE. For a session, the combination of a host ID and a session number uniquely identifies a user session on the system.

Note: This value is NULL for AMP and VSS vprocs. A value of zero represents the Supervisor window.

Page 286: Workload management api

Chapter 3: PMPC APIsMonitorVirtualConfig

286 Workload Management API: PM/API and Open API

Example

SELECT t2.* FROM TABLE (MonitorVirtualConfig()) AS t2;

*** Query completed. 9 rows found. 6 columns returned. *** Total elapsed time was 4 seconds.

ProcId VprocNo Vproctype HostId Status DiskSlice----------- ----------- --------- ------ ------ ---------

134 0 AMP 0 U -1134 1 AMP 0 U -1134 2 AMP 0 U -1134 3 AMP 0 U -1135 10237 VSS 0 U 0134 10238 VSS 0 U 0135 16380 PE 0 U 0 135 16381 PE 0 U 0134 16382 PE 0 U 0

Status The status of the vproc associated with this record. A vproc is considered up or down depending on whether or not it is helping a query process SQL. For example, an AMP doing offline recovery is considered to be down because the AMP is not helping to process Teradata SQL. On the other hand, an up vproc is one that is online and fully up or is in online recovery.

The status of the node. The following values apply:

• U = Up or Online

• D = Down or Offline

• S = Standby (This value indicates the node is ready to join the configuration in place if another node goes down.)

DiskSlice The virtual disk ID defining the portion of a physical disk assigned to an AMP.

This value is NULL for VSS vprocs.

Column Name Description

Page 287: Workload management api

Chapter 3: PMPC APIsMonitorVirtualResource

Workload Management API: PM/API and Open API 287

MonitorVirtualResource

PurposeCollects performance information for each AMP, PE, or VSS vproc.

Definition

REPLACE FUNCTION MonitorVirtualResource() RETURNS TABLE (VprocNo SMALLINT, VprocType VARCHAR(3), Status CHAR, ProcId SMALLINT, ClusterNo SMALLINT,

SessRunCount SMALLINT, CPUUse FLOAT, PctService FLOAT, PctAMPWT FLOAT, DiskUse FLOAT, DiskReads FLOAT, DiskWrites FLOAT, DiskOutReqAvg FLOAT, PctParser FLOAT, PctDispatcher FLOAT, CICUse FLOAT, HstBlkRds FLOAT, HstBlkWrts FLOAT, NetReads FLOAT, NetWrites FLOAT, NVMemAllocSegs FLOAT )...;

Usage Notes

The MonitorVirtualResource function provides similar functionality to a PMPC MONITOR VIRTUAL RESOURCE request. For information about this interface, see “MONITOR VIRTUAL RESOURCE” on page 166.

Page 288: Workload management api

Chapter 3: PMPC APIsMonitorVirtualResource

288 Workload Management API: PM/API and Open API

Result Rows

Column Name Description

VprocNo The ID of an AMP (that is, a set of disks and the associated tasks or processes that, in combination, make up the AMP), PE or VSS vproc.

VprocType The type of vproc: PE, AMP, or VSS.

Status The status of the node, AMP, PE, or VSS associated with this record. The following values apply:

• U = Up/online

• D = Down

• S = Standby

A vproc or node is up (U) when it is:

• Configured into the system

• Online

• Capable of actively performing tasks associated with normal Teradata Database activity

Down (D) represents all other potential states.

Standby (S) indicates the vproc or node is ready to join the configuration in place if another vproc or node goes down.

ProcId The ID associated with a node. This value is computed as the module number within a cabinet plus 100 times the cabinet number. Usually formatted for display as zz9-99. However, this display format can be changed by the user.

ClusterNo Identifies the cluster to which this AMP has been assigned.

This field is not applicable to VSS vproc and a NULL value is returned.

SessLogCount SessLogCount is the number of current sessions logged to this PE. A logged on session is either a session whose logon request was delivered to this PE, or a session that was switched to this PE following its logon.

SubpoolId identifies the subpool associated with the allocator vproc. A subpool defines a set of storage and allocator vprocs assigned to that storage.

This value is NULL for:

• AMPs.

• Down or offline PEs.

• A request for data that is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Note: The SessLogCount field contains the SubPoolId if the vproc type is VSS.

Page 289: Workload management api

Chapter 3: PMPC APIsMonitorVirtualResource

Workload Management API: PM/API and Open API 289

SessRunCount The number of current sessions whose Initiate Requests (TSR messages) are addressed to this vproc. For example:

• PEs have a SessRunCount that includes all the Teradata SQL and MONITOR sessions logged on to that PE.

• AMPs may have a nonzero SessRunCount, since AMPs receive TSR messages from FastLoad or MultiLoad logons.

Note: Sessions involving Archive and Recovery jobs are not included in this SessRunCount because HUT sessions do not deliver TSR messages to a fixed AMP or PE.

This value is NULL for:

• Down or offline AMPs or PEs.

• A request for data that is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

CPUUse This field is obsolete.

PctService The % of CPU resources spent in UNIX/PDE user service processing. For node-level displays, the value is computed from the ResUsageSpma table data, where x represents the number of CPUs:

CPUUServ * (x * SampleSec)

For vproc-level displays, the value is computed from the ResUsageSvpr table data, where x represents the number of CPUs:

(CPUUServPart00 + CPUUServPart01 + ... + CPUUServPart15)* / (x * SampleSec)

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

Column Name Description

Page 290: Workload management api

Chapter 3: PMPC APIsMonitorVirtualResource

290 Workload Management API: PM/API and Open API

PctAMPWT The % of CPU resources used by either the AMP Worker Task (Partition 11) or by the VSS Task (Partition 31) depending on the type of vproc this record represents. For information on partition assignments, see Resource Usage Macros and Tables.

This value depends on the number of CPUs on the node but does not exceed 100%. It is computed from the ResUsageSvpr table data, where x represents the number of CPUs on a node:

For AMP vprocs:

CPUUExecPart11 * 100.00 / (x * SampleSec)

For VSS vprocs:

CPUUExecPart31 * 100.00 / (x * SampleSec)

The value is NULL for:

• PEs.

• Down or offline vproc.

• A request for data that is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

DiskUse The % of disk usage per node or AMP. For node-level displays, this value is computed from ResUsageSldv table data as follows, assuming n is the number of ldv controllers used by this node:

(LdvOutReqTime 1 + ... + LdvOutReqTime n) / (n*SampleSec)

For vproc-level displays, this value is computed from the ResUsageSvdsk table data, assuming it is the number of logical devices used by this AMP:

(OutReqTime 1 + ... + OutReqTime n) / SampleSec

Note: DiskUse does not take into account overlapping of operations among multiple storage controllers, but it allows for the possibility of multiple requests for the same controller.

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

Column Name Description

Page 291: Workload management api

Chapter 3: PMPC APIsMonitorVirtualResource

Workload Management API: PM/API and Open API 291

DiskReads The total number of physical disk reads per node or AMP during the sample period. For node-level displays, this value is computed from ResUsageSpma table data as:

MemTextPageReads + MemCtxtPageReads + MemSwapReads + FileAcqReads

Note: You can determine node-level DiskReads by summing the vproc level values across all vprocs on a given node with the MemTextPageReads value for that node.

For vproc-level displays, this value is computed from the ResUsageSvpr table data as:

MemCtxtPageReads + MemSwapReads + FilePCiAcqReads + FilePDbAcqReads + FileSCiAcqReads + FileSDbAcqReads + FileTJtAcqReads + FileAPtAcqReads

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

DiskWrites The total number of physical disk writes per node or AMP during the sample period. For node-level displays, this value is computed from ResUsageSpma table data as:

MemCtxtPageWrites + FileWrites

Note: For the total number of node-level DiskWrites, add all the vproc values across all AMPs on a given node.

For PE and AMP-level displays, this value is computed from ResUsageSvpr table data as:

MemCtxtPageWrites + FilePCiFWrites + FilePDbFWrites + FileSCiFWrites + FileSDbFWrites + FileTJtFWrites + FileAPtFWrites + FilePCiDyAWrites + FilePDbDyAWrites + FileSCiDyAWrites + FileSDbDyAWrites + FileTJtDyAFWrites + FileAPtDyAWrites

For VSS vproc displays, this value is computed from ResUsageSvpr table data as:

AllocatorMapIOsDone

This value is NULL if:

• Nodes or AMPs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made during the first sample period following a change in the ResMonitor rate.

• For AMPs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Column Name Description

Page 292: Workload management api

Chapter 3: PMPC APIsMonitorVirtualResource

292 Workload Management API: PM/API and Open API

DiskOutReqAvg The average number of outstanding disk requests.

For node-level displays, this value is computed from ResUsageSldv table data as follows, assuming n is the number of ldv controllers used by this node:

(LdvOutReqSum 1 + ... + LdvOutReqSum n) / collectintervals

For PE and AMP-level displays, this value is computed from ResUsageSvdsk table data, assuming n is the number of storage devices used by this vproc:

(ReadRespTot 1 + WriteRespTot 1 + ... + ReadRespTot n + WriteRespTot n) / SampleSec

For VSS vproc displays, this value is computed from ResUsageSvpr table data as:

AllocatorMapIOsStarted - AllocatorMapIOsDone

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

PctParser The % of CPU resources spent in PE Parser processing. This value depends on the number of CPUs on the node but does not exceed 100%. The value is computed from the ResUsageSvpr table data, where x represents the number of CPUs on a node:

CPUUExecPart14 * 100.00/(x * SampleSec)

This value is NULL for:

• AMPs.

• Down or offline PEs.

• A request for data that is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

PctDispatcher The % of CPU resources spent in PE Dispatcher processing. This value depends on the number of CPUs on the node but does not exceed 100%. This value is computed from the ResUsageSvpr table data, where x represents the number of CPUs on a node:

CPUUExecPart13 * 100.00 /(x * SampleSec)

This value is NULL for:

• AMPs.

• Down or offline PEs.

• A request for data that is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

CICUse This field is obsolete.

Column Name Description

Page 293: Workload management api

Chapter 3: PMPC APIsMonitorVirtualResource

Workload Management API: PM/API and Open API 293

HstBlkRds The number of message blocks (one or more messages sent in one physical group) received from all clients. For node-level displays, this value is computed from ResUsageShst data, assuming n is the number of vprocs on this node:

HostBlockReads1 + ... + HostBlockReadsn

For vproc-level displays, this value corresponds to the column totals in the DBC.ResUsage.Shst table supplying HostBlockReads for this vproc.

This value is NULL for:

• Down or offline nodes or PEs.

• AMPs.

• A request for data that is made before completion of the first sample period following a system outage.

• For nodes, a request for data that is made before the completion of the first sample period following a change in the ResMonitor rate.

• For PEs, a request for data that is made before the completion of the first sample period following a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

HstBlkWrts The number of message blocks (that is, one or more messages sent in one physical group) sent to all hosts. For node displays, this value is computed from ResUsageShst data, assuming n is the number of PEs on this node:

HostBlockWrites1 + ... + HostBlockWritesn

For PE display, this value corresponds to the column totals in the DBC.ResUsageShst table with the same names.

This value is NULL if:

• Nodes are down or offline.

• PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before the completion of the first sample period following a change in the ResMonitor rate.

• For PEs, a request for data is made before the completion of the first sample period following a change in the VProcMonitor rate.

Note: This field is not applicable to VSS vprocs.

Column Name Description

Page 294: Workload management api

Chapter 3: PMPC APIsMonitorVirtualResource

294 Workload Management API: PM/API and Open API

NetReads The number of Reads from the BYNET to the node or vproc during the sample period. For node-level displays, this value is computed from the ResUsageSpma table data as:

Netrxcircbrd + Netrxcircptp

For vproc-level displays, the value is computed from the ResUsageSvpr table data as:

NetBrdReads + NetPtPReads

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

NetWrites The number of messages written from the node, AMP, or PE to the BYNET during the sample period. For node-level displays, the value is computed from the ResUsageSpma table data as:

Nettxcircbrd + Nettxcircptp

For vproc-level displays, the value is computed from the ResUsageSvpr table data as:

NetBrdWrites + NetPtPWrites

This value is NULL if:

• Nodes or vprocs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

Column Name Description

Page 295: Workload management api

Chapter 3: PMPC APIsMonitorVirtualResource

Workload Management API: PM/API and Open API 295

Example

SELECT VprocNo, VprocType, Status, PRocId, ClusterNo FROMTABLE (MonitorVirtualResource()) AS t2;

*** Query completed. 9 rows found. 5 columns returned. *** Total elapsed time was 1 second.

VprocNo VprocType Status ProcId ClusterNo----------- --------- ------ ----------- ----------- 0 AMP U 16384 0 1 AMP U 16384 1 2 AMP U 16384 2 3 AMP U 16384 3 4 AMP U 16384 0 5 AMP U 16384 1 6 AMP U 16384 2

NVMemAllocSegs The number of complete and partial nonvolatile memory allocations of disk segments read (written) for backup storage during the sample period.

For node-level displays, the value is computed from ResUsageSpma table data as:

MemPDbBackCReads + MemPCiBackCReads + MemSDbBackCReads + MemSCiBackCReads + MemTJtBackCReads + MemAPtBackCReads + MemPDbBackPReads + MemPCiBackPReads + MemSDbBackPReads + MemSCiBackPReads + MemTJtBackPReads + MemAPtBackPReads

For vproc-level displays, the value is computed from ResUsageSvpr table data using:

• On MP-RAS, the following calculation:

MemPDbBackCWrites + MemPCiBackCWrites + MemSDbBackCWrites + MemSCiBackCWrites + MemTJtBackCWrites + MemAPtBackCWrites + MemPDbBackPWritets + MemPCiBackPWrites + MemSDbBackPWrites + MemSCiBackPWrites + MemTJtBackPWrites + MemAPtBackPWrites

• On Windows and Linux:

Svpr_IoRespMax (the maximum I/O response time in milliseconds for each AMP vproc on that node). For details, see Resource Usage Macros and Tables.

This value is NULL if:

• Nodes, AMPs, or PEs are down or offline.

• A request for data is made before completion of the first sample period following a system outage.

• For nodes, a request for data is made before completion of the first sample period following a change in the ResMonitor rate.

• For AMPs or PEs, a request for data is made before completion of the first sample period following a change in the VProcMonitor rate.

Note: This field is called “Max I/O Time” in PMON and “Maximum I/O Time” in Teradata Manager.

This field is not applicable to VSS vprocs.

Column Name Description

Page 296: Workload management api

Chapter 3: PMPC APIsMonitorVirtualResource

296 Workload Management API: PM/API and Open API

7 AMP U 16384 310237 VSS U 16384 010238 VSS U 16384 01638 PE U 16384 1025

Page 297: Workload management api

Chapter 3: PMPC APIsMonitorVirtualSummary

Workload Management API: PM/API and Open API 297

MonitorVirtualSummary

PurposeCollects global summary information on system utilization.

Definition

REPLACE FUNCTION MonitorVirtualSummary() RETURNS TABLE

(AMPAvgCPU FLOAT, AMPAvgDisk FLOAT, AMPAvgDiskIO FLOAT, HiCPUAMPUse FLOAT, HiDiskAMP FLOAT, HiDiskAMPIO FLOAT, HiCPUAMPNo SMALLINT, HiDiskAMPNo SMALLINT, HiDiskAMPIONo SMALLINT, HiCPUAMPProc SMALLINT, HiDiskAMPProc SMALLINT, HiDiskAMPIOProc SMALLINT, LoCPUAMPUse FLOAT, LoDiskAMP FLOAT, LoDiskAMPIO FLOAT, LoCPUAMPNo SMALLINT, LoDiskAMPNo SMALLINT, LoDiskAMPIONo SMALLINT, LoCPUAMPProc SMALLINT, LoDiskAMPProc SMALLINT, LoDiskAMPIOProc SMALLINT, PEAvgCPU FLOAT, HiCPUPEUse FLOAT, LoCPUPEUse FLOAT, HiCPUPENo SMALLINT, LoCPUPENo SMALLINT, HiCPUPEProc SMALLINT, LoCPUPEProc SMALLINT, SessionCnt FLOAT, SesMonitorSys SMALLINT, SesMonitorLoc SMALLINT, VprocLogging SMALLINT, VprocMonitor SMALLINT, ReleaseNum CHAR(30), Version CHAR(32)

)...;

Page 298: Workload management api

Chapter 3: PMPC APIsMonitorVirtualSummary

298 Workload Management API: PM/API and Open API

Usage Notes

The MonitorVirtualSummary provides similar functionality to a PMPC MONITOR VIRTUAL SUMMARY request. For information about this interface, see “MONITOR VIRTUAL SUMMARY” on page 188.

Result Rows

Column Name Description

AMPAvgCPU The average % CPU usage (CPUUse) of all online AMPs in the configuration.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Assuming n is the number of online AMPs in the configuration, AMPAvgDisk is computed from DiskUse data as:

(DiskUse1 + ... + DiskUsen) / n

AMPAvgDisk The average physical disk usage (DiskUse) of all online AMPs in the configuration.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Assuming n is the number of online AMPs in the configuration, AMPAvgDisk is computed from DiskUse data as:

(DiskUse1 + ... + DiskUsen) / n

AMPAvgDiskIO The average physical disk DiskReads and DiskWrites of all online AMPs in the configuration.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period that following either a system outage or a change in the VProcMonitor rate.

Assuming n is the number of online AMPs in the configuration, AMPAvgDiskIO is computed from DiskReads and DiskWrites data as:

(DiskReads1 + DiskWrites1 + ... + DiskReads1 + DiskWritesn) / n

Page 299: Workload management api

Chapter 3: PMPC APIsMonitorVirtualSummary

Workload Management API: PM/API and Open API 299

HiCPUAMPUse The highest CPUUse percentage currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiDiskAMP The highest DiskUse percentage currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiDiskAMPIO The highest DiskReads and DiskWrites value currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiCPUAMPNo The vproc number (VprocNo) of an AMP with CPUUse equal to the value reported as HiCPUAMPUse.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiDiskAMPNo The number of an AMP with DiskUse equal to the value reported as HiDiskAMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiDiskAMPIONo The number of an AMP with the highest DiskReads and DiskWrites equal to the value reported as HiDiskAMPIO.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Column Name Description

Page 300: Workload management api

Chapter 3: PMPC APIsMonitorVirtualSummary

300 Workload Management API: PM/API and Open API

HiCPUAMPProc The ID of the node currently responsible for managing the AMP reported as HiCPUAMPNo.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiDiskAMPProc The ID of the node currently responsible for managing the AMP reported in HiDiskAMPNo.

This value is NULL when HiDiskAMPNo is NULL.

HiDiskAMPIOProc The ID of the node currently responsible for managing the AMP reported in HiDiskAMPIONo.

This value is NULL when HiDiskAMPIONo is NULL.

LoCPUAMPUse The lowest CPUUse percentage currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• The request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoDiskAMP The lowest DiskUse percentage currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoDiskAMPIO The lowest DiskReads and DiskWrites number currently associated with any online AMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoCPUAMPNo The vproc number (VprocNo) of an AMP with CPUUse equal to the value reported as LoCPUAMPUse.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Column Name Description

Page 301: Workload management api

Chapter 3: PMPC APIsMonitorVirtualSummary

Workload Management API: PM/API and Open API 301

LoDiskAMPNo The number of an AMP with DiskUse equal to the value reported as LoDiskAMP.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoDiskAMPIONo The ID of an AMP with lowest DiskReads and DiskWrites equal to the value reported as LoDiskAMPIO.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoCPUAMPProc The ID of the node currently responsible for managing the AMP reported as LoCPUAMPNo.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoDiskAMPProc The ID of the node currently responsible for managing the AMP reported as LoDiskAMPNo.

This value is NULL when LoDiskAMPNo is NULL.

LoDiskAMPIOProc The ID of the node currently responsible for managing the AMP reported as LoDiskAMPIONo.

This value is NULL when LoDiskAMPIONo is NULL.

PEAvgCPU The average CPUUse for all online PEs in the configuration.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiCPUPEUse The highest CPUUse percentage currently associated with any online PE.

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

Column Name Description

Page 302: Workload management api

Chapter 3: PMPC APIsMonitorVirtualSummary

302 Workload Management API: PM/API and Open API

LoCPUPEUse The lowest CPUUse percentage currently associated with any online PE.

This value is NULL when LoCPUPEUse is NULL.

HiCPUPENo The vproc number (VProcNo) of a PE with CPUUse equal to the value reported as HiCPUPEUse.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

LoCPUPENo The vproc number (VProcNo) of a PE with CPUUse equal to the value reported as LoCPUPEUse.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

HiCPUPEProc The ID of the node currently responsible for managing the PE reported in HiCPUPENo.

This value is NULL when HiCPUPENo is NULL.

LoCPUPEProc The ID of the node currently responsible for managing the PE reported as LoCPUPENo.

This value is NULL if:

• The VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

SessionCnt The total number of sessions currently logged onto the system. This value is usually equal to the sum of the SessLogCount values for all PEs.

This value is NULL if:

• VProcMonitor rate is zero.

• A request for data is made before completion of the first sample period following either a system outage or a change in the VProcMonitor rate.

SesMonitorSys The system-wide monitoring rate at which session-level statistics are collected within memory for reporting. This system rate is the default sampling rate for all MONITOR sessions. A rate of zero turns off the sampling capability.

Column Name Description

Page 303: Workload management api

Chapter 3: PMPC APIsMonitorVirtualSummary

Workload Management API: PM/API and Open API 303

Example

sel * FROM TABLE (MonitorVirtualSummary()) AS t1;

*** Query completed. One row found. 35 columns returned. *** Total elapsed time was 1 second.

AMPAvgCPU 6.14583333333333E-003 AMPAvgDisk 4.25000000000000E-002 AMPAvgDiskIO 8.41250000000000E 001 HiCPUAMPUse 1.00000000000000E-002 HiDiskAMP 6.91666666666667E-002 HiDiskAMPIO 1.12000000000000E 002 HiCPUAMPNo 3 HiDiskAMPNo 0 HiDiskAMPIONo 0 HiCPUAMPProc 33 HiDiskAMPProc 33HiDiskAMPIOProc 33 LoCPUAMPUse 3.75000000000000E-003 LoDiskAMP 1.16666666666667E-002 LoDiskAMPIO 3.90000000000000E 001 LoCPUAMPNo 6 LoDiskAMPNo 5 LoDiskAMPIONo 5 LoCPUAMPProc 33 LoDiskAMPProc 33

SesMonitorLoc The local monitoring rate at which session-level statistics are collected within memory for reporting. This rate is initiated within a MONITOR session and may update session-level data within the system.

VprocLogging The rate at which vproc-level resource usage data is written to one or more active ResUsage database tables. The ResUsage tables are named DBC.ResUsageXyyy, where Xyyy is Sawt, Svpr, Sldv and so forth. For more information, see Resource Usage Macros and Tables.

This rate can be changed with the SetResourceRate function. When changed, the rate is saved on disk (in the version record).

VprocMonitor The rate, in seconds, at which AMP and PE resource usage data is collected for display within the memory of the associated node.

A rate of zero turns off the sampling capability.

This rate can be changed with the SetResourceRate function. The rate is saved on disk when it is changed.

ReleaseNum Release number of the currently running Teradata Database software (for example, 13.00.00.00).

This value is supplied by Teradata Database.

Version Version number of the currently running Teradata Database software (for example, 13.00.00.00).

This value is supplied by Teradata Database.

Column Name Description

Page 304: Workload management api

Chapter 3: PMPC APIsMonitorVirtualSummary

304 Workload Management API: PM/API and Open API

LoDiskAMPIOProc 33 PEAvgCPU 4.79166666666667E-002 HiCPUPEUse 4.79166666666667E-002 LoCPUPEUse 4.79166666666667E-002 HiCPUPENo 16383 LoCPUPENo 16383 HiCPUPEProc 33 LoCPUPEProc 33 SessionCnt 7.00000000000000E 000 SesMonitorSys 60 SesMonitorLoc 0 VprocLogging 600 VprocMonitor 600 ReleaseNum 13.00.00.00 Version 13.00.00.00

Page 305: Workload management api

Chapter 3: PMPC APIsSetResourceRate

Workload Management API: PM/API and Open API 305

SetResourceRate

PurposeSets the following rates:

• VprocMonitor

• VprocLogging

• ResMonitor

• ResLogging

Definition

REPLACE FUNCTION SetResourceRate (SampleRate INTEGER, LogChange VARCHAR(1), VProcChange VARCHAR(1)

) RETURNS INTEGER...;

Input Parameters

Usage Notes

The following table describes the different types of rates that can be set using the SetResourceRate function.

Parameter Description

SampleRate The VprocMonitor, VProcLogging, ResMonitor, and ResLogging rate specified. The value ranges from 0 to 3600 seconds.

LogChange Indicator of whether or not the rate applies to logging or monitoring. The following values apply:

• Y = Modify Logging Rate

• N or NULL = Modify Monitor Rate

VprocChange Indicator of whether or not the rate applies to the vproc or node. The following values apply:

• Y = Modify Vproc Rate

• N or NULL = Modify Node Rate

Page 306: Workload management api

Chapter 3: PMPC APIsSetResourceRate

306 Workload Management API: PM/API and Open API

The SetResourceRate function provides similar functionality to a PMPC SET RESOURCE RATE request. For information about this interface and the rates described above, see “SET RESOURCE RATE” on page 199.

Return Value

This function returns the previous sample rate value in seconds.

The rate... Sets the... To Set Individual Rates ...

VProcMonitor maximum frequency at which vproc resource data is updated within memory. The resource monitoring rate is returned as a VProcMonitor data value by the MonitorVirtualSummary function.

pass in 'N' for the LogChange input parameter and 'Y' for the VprocChange input parameter.

VProcLogging rate at which vproc-level resource usage data is written to one or more active ResUsage database tables. The ResUsage tables are named DBC.ResUsageXyyy, where Xyyy is Sawt, Svpr, Sldv and so forth. For more information, see Resource Usage Macros and Tables.

The resource logging rate is returned as a VProcLogging data value by the MonitorVirtualSummary function.

pass in 'Y' for the LogChange input parameter and 'Y' for the VprocChange input parameter.

ResMonitor maximum frequency at which node resource data is updated within memory. The resource monitoring rate is returned as a ResMonitor data value by the MonitorPhysicalSummary function.

pass in 'N' for the LogChange input parameter and 'Y' for the VprocChange input parameter.

ResLogging frequency at which node resource usage data is written to one or more active ResUsage database tables. The node ResUsage tables are named DBC.ResUsageXyyy, where Xyyy is Spma and Scpu (see Resource Usage Macros and Tables). A rate of zero turns off logging capability.

The resource logging rate is returned as a ResLogging data value by the MonitorPhysicalSummary function.

pass in 'Y' for the LogChange input parameter and 'Y' for the VprocChange input parameter.

Page 307: Workload management api

Chapter 3: PMPC APIsSetResourceRate

Workload Management API: PM/API and Open API 307

Example

This example uses SetResourceRate to set the ResMonitor rate.

SELECT SetResourceRate(60, 'N', 'N');

*** Query completed. One row found. One column returned. *** Total elapsed time was 5 seconds.

SetResourceRate(60,'N','N')---------------------------

600

Page 308: Workload management api

Chapter 3: PMPC APIsSetSessionAccount

308 Workload Management API: PM/API and Open API

SetSessionAccount

PurposeChanges the account string for a session or for the next request.

Definition

REPLACE FUNCTION SetSessionAccount (HostIdIn SMALLINT, SessionNoIn INTEGER, NewAcctString VARCHAR(30), EntireSession VARCHAR(1)

) RETURNS VARCHAR(30)...;

Input Parameters

Usage Notes

The SetSessionAccount function provides similar functionality to a PMPC SET SESSION ACCOUNT request. For information about this interface, see “SET SESSION ACCOUNT” on page 204.

Return Value

This function returns the new account string.

Parameter Description

HostIdIn The logical ID of a host (or client) with sessions logged on.

SessionNoIn The number of the session specified.

NewAcctString The account string, including the priority of the session or request. You can adjust the priority to one higher or lower than that currently defined for the account.

EntireSession Indicator of how the new account or priority affects requests for a specified session.

If you specify Y or y, then the change applies to all current and future requests for a specified session. If no requests or steps are executing, the new account or priority takes effect at the next request, and the DBC.SessionTbl table reflects the new account or priority for the current session.

If you specify NULL, blank, N, or n, then the change applies only to the current request for the specified session. If no request is executing, the next request for the specified session has the old account/priority.

Page 309: Workload management api

Chapter 3: PMPC APIsSetSessionAccount

Workload Management API: PM/API and Open API 309

Example 1

BTEQ -- Enter your DBC/SQL request or BTEQ command:SELECT SetSessionAccount(Hostid, sessionno, 'Accountx','Y')FROM TABLE (MonitorSession(1,'twmuser3',0)) AS t1;

SELECT SetSessionAccount(Hostid, sessionno, 'Accountx','Y')FROM TABLE (MonitorSession(1,'twmuser3',0)) AS t1;

*** Query completed. One row found. One column returned. *** Total elapsed time was 1 second.

SetSessionAccount(HostId,SessionNo,'Accountx','Y')--------------------------------------------------ACCOUNT3

Example 2

BTEQ -- Enter your DBC/SQL request or BTEQ command:SELECT SetSessionAccount(1, 4461, 'Account3','y');

SELECT SetSessionAccount(1, 4461, 'Account3','y');

*** Query completed. One row found. One column returned. *** Total elapsed time was 1 second.

SetSessionAccount(1,4461,'Account3','y')----------------------------------------ACCOUNTX

Page 310: Workload management api

Chapter 3: PMPC APIsSetSessionRate

310 Workload Management API: PM/API and Open API

SetSessionRate

PurposeSets the system-wide rates for updating session-level statistics within memory.

Definition

REPLACE FUNCTION SetSessionRate (SampleRate INTEGER) RETURNS INTEGER...;

Input Parameter

The SampleRate parameter sets the system-wide rate. The value ranges from 0 to 3600 seconds.

Note: The sample rate applies to system-wide queries.

Usage Notes

There is no option equivalent to the PMPC SET SESSION RATE request Local_Change = Y option because when using the SetSessionRate function, there is no local MONITOR PARTITION in which to apply the rate to.

You can set the SetSessionRate function to a system-wide (SesMonitorSys) rate. That is, a sampling rate at which session-level statistics are collected within memory. This rate is returned in the SesMonitorSys data value by the MONITORVIRTUALSUMMARY function.

The SetSessionRate function provides similar functionality to a PMPC SET SESSION RATE request. For information about this interface, see “SET SESSION RATE” on page 209.

Return Value

This function returns the previous sample rate value in seconds.

Example

SELECT SetSessionRate(600);

*** Query completed. One row found. One column returned. *** Total elapsed time was 1 second.

SetSessionRate(600)----------------------- 60

Page 311: Workload management api

Workload Management API: PM/API and Open API 311

CHAPTER 4 Teradata Dynamic WorkloadManagement APIs

This chapter discusses how to manage Teradata Dynamic Workload Management rules through two types of APIs: CLIv2 interfaces and SQL interfaces consisting of user-defined functions (UDFs) and external stored procedures.

Some of the SQL interfaces, such as TDWMObjectAssn, TDWMRuleControl, and TDWMSetLimits, allow you to update the tdwm database in addition to managing the workload rules.

To learn more about the different types of interfaces, see:

• “CLIv2 Interfaces” on page 312

• “SQL Interfaces” on page 352

Before using the Teradata Dynamic Workload Management APIs, you may want to familiarize yourself with the following topics:

• “What PM/API Is” on page 13

• “What the Open API Is” on page 14

• “Teradata Dynamic Workload Management Features” on page 19

• “Workload Management API Examples” on page 25

Page 312: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsCLIv2 Interfaces

312 Workload Management API: PM/API and Open API

CLIv2 Interfaces

This section describes the Teradata Dynamic Workload Management interfaces that use CLIv2. These interfaces are referred to as PM/API requests.

Note: The PM/API requests described in this section are shown in uppercase, although mixed case interfaces are also supported.

Page 313: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsEVENT STATUS

Workload Management API: PM/API and Open API 313

EVENT STATUS

PurposeReturns information about the current status of all event-related constructs, such as events through states, and information related to the current state.

Input Data

Usage Notes

A user must have ABORTSESSION and MONSESSION privileges to execute the EVENT STATUS request.

Teradata Manager can use the EVENT STATUS request to provide the user the current Teradata Dynamic Workload Management status.

Parcels

The following table lists information about the parcels.

Element Data TypeLength (Bytes) Description

mon_ver_id SMALLINT, NOT NULL

2 The MONITOR software version ID. This can be version 6 or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Request Type SMALLINT, NOT NULL

2 The type of status information requested.

If the value is set to 1, then ALL is returned. This includes the status of all events, expressions, SysCons, and OpEnvs defined in Teradata Dynamic Workload Management.

If the value is set to 2, then CURRENT is returned. This includes the status of those events and expressions that are related to the currently enforced system condition (SysCon) and operating environment (OpEnv).

ID Mapping SMALLINT 2 This field returns mapping information in the output, such as the names and IDs defined within the current rule set.

If a value of 1 is returned, mapping record types are included. Otherwise, no mapping information is returned.

Page 314: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsEVENT STATUS

314 Workload Management API: PM/API and Open API

Response

The EVENT STATUS request returns the status of all items that make up either the CURRENT or ALL states defined in the current rule set.

The output is divided into three statement types:

• The first statement type provides configuration overview information.

• The second statement type provides a series of records that represent the status of events, expressions and states in the system. Only events that are referenced in Expressions that have an action are included in this statement type. To optimize the interface, this information is provided using the internal ID of the various events, expressions and states.

• The third statement type, which is optional, provides the mapping of internal IDs to names.

Statement Type: 1

The first statement type returns information about the current configuration.

Parcel Sequence Flavor Field Length Comments and Key Parcel Body Fields

Success 8 18 to 273 StatementNo =1

ActivityCount = Not applicable

ActivityType = 170 (PCLEVENTSTATUSSTMT)

DataInfo 71 6 to 32004 Optional: this parcel is present if request was IndicData parcel.

Record 10 5 to 32004(record mode)

6 to 32004(Indicator mode)

Depending on the request (Data or IndicData) data is returned in Record or Indicator mode. This is the only record returned.

This record contains an indicator for each category indicating its status after processing this request (0=active, 1=inactive)

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Field Name Data Type Length (Bytes) Description

Config ID INTEGER,NOT NULL

2 The configuration ID of the current rule set.

Config Name CHAR 30 The name of the current rule set, blank filled.

Page 315: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsEVENT STATUS

Workload Management API: PM/API and Open API 315

Use this first statement to determine if a new configuration has been placed into effect. When a new configuration is placed into effect, the mapping record type should be requested to provide the mapping of object IDs to object names.

Statement Type: 2

The second statement type returns a series of records that provide the status of events, expressions, SysCons and OpEnvs in the system. The information returned shows the relationship between an Event, the Expression that references that Event, and the SysCon or OpEnv that is affected by that Expression.

There is one record returned for every Event that is referenced in the associated Expression. When CURRENT is requested only a single Expression associated with the CURRENT SysCon and OpEnv that caused that SysCon or OpEnv to be defined as enforced is returned. When ALL is requested, ALL expressions associated with each SysCon or OpEnv are returned. In addition, the ALL interface returns those expressions which do not have an action related to a SysCon or OpEnv. These are referred to as Notify Only Expressions.

The expression and owning SysCon or OpEnv ID fields are repeated until all events have been included. If events are repeated within multiple expressions, then those events will be reported within each of those expressions. For the case of the ALWAYS OpEnv and the NORMAL SysCon, there is no expression associated. Statements for these two items will have a value of zero for the Event and Expression ID fields.

Date DATE 4 The date when this configuration was first activated.

Time FLOAT 8 The time when this configuration was first activated.

Field Name Data Type Length (Bytes) Description

Field Name Data TypeLength (Bytes) Description

EventId INTEGER,NOT NULL

4 The internal ID of the Event. A value of zero indicates there is no event associated with this record entry. There are no expressions associated with the Normal SysCon, Always OpEnv, and a State.

Events are reported in the order they appear within the associated expression. Only events included in the associated expression are included.

EventStatus SMALLINT 2 The status of the event. The following values apply:

• 0 = Inactive (false)

• 1 = Active (true)

Page 316: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsEVENT STATUS

316 Workload Management API: PM/API and Open API

EventActiveDate DATE 4 The date when EventStatus was last changed. This is the date when EventStatus was set to Inactive (false) or Active (true).

Event Active Time FLOAT 8 The time EventStatus was last changed. This is the time when EventStatus was set to Inactive (false) or Active (true).

ExpressionId INTEGER,NOT NULL

4 The internal ID of the Expression.

A value of zero indicates there is no expression associated with this record entry. There are no expressions associated with the Normal SysCon, Always OpEnv, and a State.

For the CURRENT state request, the first TRUE expression associated with the associated State is included. When there are multiple true expressions for a state only the first one processed is reported. The order of processing is consistent within a rule set and, therefore, the same True expression is reported on every request.

Expression Status SMALLINT 2 The current status of the Expression. The following values apply:

• 0 = Inactive (false)

• 1 = Active (true)

Expression Active Date DATE 4 The date when Expression Status was last changed. This is the date when Expression Status was set Active (true) or Inactive (false).

Expression Active Time FLOAT 8 The time Expression Status was last changed. This is the time when Expression Status was set Active (true) or Inactive (false).

Field Name Data TypeLength (Bytes) Description

Page 317: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsEVENT STATUS

Workload Management API: PM/API and Open API 317

Record Type SMALLINT 2 The type of information contained in this record. The following values apply:

• 0 = SysCon

• 1 = OpEnv

• 2 = Notify Only Expression. The Notify Only Expression indicates the remaining fields are not applicable as only the Event or Expression relationship is reported in this statement.

• 3 = State. The State indicates the current active State. This is the result of the current SysCon and OpEnv. For this Record Type, the Event and Expression fields above are not valid.

For both the CURRENT and ALL requests, the order in which State information is returned is as follows:

• SysCon

• OpEnv

• State (Only the Enforced State is returned)

Note: Notify Only Expression is returned only for the ALL request.

Id INTEGER,NOT NULL

2 The internal ID of either a SysCon or an OpEnv depending on the Record Type specified.

The value is zero for Notify Only Expression record types. Notify Only Expression records represent Expressions that do not have an action to activate a Syscon or OpEnv. These Expressions are not associated with a State.

Status SMALLINT 2 The current status of the Syscon or OpEnv. The following values apply:

• 0 = Inactive (false)

• 1 = Active (true).

• 2 = Active and Enforced.

Field Name Data TypeLength (Bytes) Description

Page 318: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsEVENT STATUS

318 Workload Management API: PM/API and Open API

The date/time associated with each item (Event, Expression, State) shows when the status that is represented occurred.

Note: The “State” column in the examples below refers to the “Expression Status” field.

EvtID Status Date/Time ExpID State Date/Time RecType Id Status 110 1 8:00AM 1/2/06 220 1 8:00AM 1/2/06 0 300 1 120 0 8:15AM 1/2/06 220 1 8:15AM 1/2/06 0 300 1 130 1 8:00AM 1/2/06 320 1 8:00AM 1/2/06 1 400 1 140 1 8:15AM 1/2/06 320 1 8:15AM 1/2/06 1 400 1

This statement shows two records representing a Single expression (220) that is defined with two Events (110 and 120). In this example, 110 is true and 120 is false. The original expression must be referenced by the user to determine why these event values resulted in the Expression being true. That is, these events are part of a logical expression whose structure is not being reported here. Another expression (320) is shown that is made up of two events (130 and 140). This expression is responsible for the OpEnv of 400 being in enforced.

EvtID Status Date/Time ExpID State Date/Time RecType Id Status 0 0 8:00AM 1/2/06 0 0 8:00AM 1/2/06 0 100 1 0 0 8:15AM 1/2/06 0 0 8:15AM 1/2/06 1 200 1

This record has both event and expression IDs of zero. This is the case for both the NORMAL SysCon and the ALWAYS OpEnv which have no expressions associated with them. The Date/Time fields are not valid since they are not associated with an Event or Expression but are only shown as placeholders.

Due To Duration INTEGER 2 Indicator of whether the corresponding SysCon is being considered as TRUE or is TRUE.

If the value is set to 1, then the SysCon is Active (true) if the corresponding SysCon is being considered as TRUE due to minimum duration (MinDuration) value being in affect.

If the value is set to zero, then the SysCon is Inactive (false) if the Syscon is TRUE based on the defined expressions.

Note: This field is valid only when SysCon is the Record Type specified.

Active Date DATE 4 The date when the status of the Record Type was last changed. This is the date when the SysCon or OpEnv Status was set Active (true) or Inactive (false).

Active Time FLOAT 8 The time representing when the status of the Record Type was last changed. This is the time when the SysCon or OpEnv Status was set Active (true) or Inactive (false).

Field Name Data TypeLength (Bytes) Description

Page 319: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsEVENT STATUS

Workload Management API: PM/API and Open API 319

For the CURRENT request, the first Active (true) expression for a SysCon/OpEnv is returned. Within this Active (true) expression, all events, both Active (true) and Inactive (false), are reported. The interface reports the events in a consistent order for a given expression.

For the ALL request, the order of reporting is that all SysCons are returned, followed by all OpEnvs, then all Expressions not associated with a SysCon or OpEnv State. These are referred to as Notify Only Expressions. Within a SysCon or OpEnv, all expressions for that State are reported before reporting the next SysCon or OpEnv. There is no order defined for the expressions reported under a SysCon/OpEnv but the interface ensures that expressions are returned in a consistent order.

The following example shows the reporting of three SysCons (300, 310 and 400), three OpEnvs (500, 530, and 540), and one Notify Only Expression (329) made up of one event (199). This Notify Only Expression does not have an ID associated with the Record Type (2). Although not shown in the example, only one SysCon and one OpEnv reported will have the enforced value returned (a Status of 2). You must independently use the Teradata Dynamic Workload Management State table to make the association to a State using the returned SysCon and OpEnv.

Note: The “State” column in the example below refers to the “Expression Status” field.

EvtID Status Date/Time ExpID State Date/Time RecType Id Status 110 1 8:00AM 1/2/06 220 0 8:00AM 1/2/06 0 300 0 120 0 8:15AM 1/2/06 220 1 8:15AM 1/2/06 0 310 1130 1 8:00AM 1/2/06 223 1 8:00AM 1/2/06 0 400 1 140 1 8:15AM 1/2/06 223 1 8:15AM 1/2/06 0 400 1 150 1 8:00AM 1/2/06 244 0 8:00AM 1/2/06 1 500 1 160 0 8:15AM 1/2/06 220 1 8:15AM 1/2/06 1 500 1 170 1 8:00AM 1/2/06 320 1 8:00AM 1/2/06 1 540 1 180 1 8:15AM 1/2/06 320 1 8:15AM 1/2/06 1 530 1 199 1 8:15AM 1/2/06 329 1 8:15AM 1/2/06 2 0 0

Statement Type: 3

The third statement type, if requested, provides a fully enumerated list of all objects that make up the system state. Some of these objects may not be represented in any expressions in the state definition. There are no duplications of objects in this statement type and there is no correlation made between objects.

Since this information does not change frequently this mapping information only needs to be requested when a new configuration is made active by the administrator.

Field Name Data Type Length Description

Object Type SMALLINT 2 The type of object specified. The following values apply:

• 0 = Event

• 1 = Expression

• 2 = SysCon

• 3 = OpEnv

• 4 = State

Object Id INTEGER, NOT NULL

4 The internal object ID for the object type.

Page 320: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsEVENT STATUS

320 Workload Management API: PM/API and Open API

The following example shows the relationship between the Event Id (110) in Statement Type 2 and the Object Name (AMPDownEvent) in Statement Type 3.

The data returned looks similar to this:

Object type = 0Object Id = 110 Object name = AMPDownEventObject status = 0Precedence/Severity= Date = 04/04/07Time = 02:30:06

The following is the order of objects returned for Statement Type 3:

1 All the rows for the Events

2 A row for a SysCon and all Expressions that are part of that Syscon

3 A row for the next SysCon and its subordinate Expressions until all SysCons are reported

4 A row for a OpEnv and all Expressions that are part of that OpEnv

5 A row for the next OpEnv and its subordinate Expressions until all OpEnvs are reported

6 All the rows for the States

7 All the rows for the Notify Only Expressions

Object Name CHAR 30 The name of the object.

Object Status SMALLINT 2 The current status of the object. The following values apply:

• 0 = Inactive (false)

• 1 = Active (true)

Precedence/Severity INTEGER 4 Indicator of the Precedence or Severity of the SysCon or OpEnv object types only.

Note: This field does not apply if this is an Event.

The following values apply:

• SysCon = Indicates the Severity of the associated SysCon.

• OpEnv = Indicates the Precedence of the associated OpEnv.

Date DATE 4 The date of the current object status (see Object Status).

Time FLOAT 8 The time of the current object status (see Object Status).

Field Name Data Type Length Description

Page 321: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsPERFGROUPS

Workload Management API: PM/API and Open API 321

PERFGROUPS

PurposeReturns information about the Resource Partitions (RPs) and Performance Groups (PGs) active in the system GDO file.

Input Data

The mon_ver_id element specifies the MONITOR software version ID. This can be version 6 or 7.

mon_ver_id is a SMALLINT data type and has a length of 2 bytes.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Usage Notes

A Resource Partition is a subset of database request-processing resources. The default Resource Partition represents 100% of the system resources. Each Resource Partition contains a number of Performance Groups that have access to the resources available to the Resource Partition. You can define additional Resource Partitions and populate them with Performance Groups.

A Performance Group is a collection users that have access to the resources of the Resource Partition to which they belong. You can assign users to Performance Groups using a MODIFY USER statement. When users log on they can enter the Performance Group as part of the account string. If a user is not assigned to a Performance Group or does not enter one as part of the account string at logon, the system uses the default Performance Group for the session.

There are two types of Resource Partitions and Performance Groups:

• Those set up using the Priority Scheduler function in the schmon utility

• Those that are part of a Teradata Dynamic Workload Management workload definition

Only one of these types can be active at any time.

To learn more about Resource Partitions and Performance Groups, see the section on Priority Scheduler in Utilities and in Teradata Dynamic Workload Manager User Guide.

The PERFGROUPS request returns the set of Resource Partitions and Performance Groups that are currently active.

• When Category 3 is not enabled in Teradata DWM, the returned set of Resource Partitions or Performance Groups are those defined by the schmon utility.

• When Category 3 is enabled in Teradata DWM, the returned set of Resource Partitions or Performance Groups are those defined by Teradata Dynamic Workload Management.

Page 322: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsPERFGROUPS

322 Workload Management API: PM/API and Open API

Parcels

The Resource Partition Record parcel contains the Resource Partition Name field. This field returns the name of the Resource Partition. The names are padded with blanks to fill the entire field.

Resource Partition Name is a CHAR data type and has a length of 16 bytes.

The following table describes the format of the Performance Group Record parcel.

Parcel Sequence

Parcel Flavor Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = 5

ActivityType = 133 (PCLTWMPERFGROUPSSTMT)

DataInfo 71 6 to 3400 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (Record mode)

• 6 to 32004 (Indicator mode)

Depending on the request (Data or IndicData), data is returned in Record or Indicator mode. One record is returned for each RP slot in the system GDO. The unused slots are padded with blanks. The format of this Resource Partition Record parcel is described below.

EndStatement 11 6 StatementNo = 1

Success 8 18 to 273 StatementNo = 2

ActivityCount = 40

ActivityType = 133 (PCLTWMPERFGROUPSSTMT)

DataInfo 71 6 to 3400 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (Record mode)

• 6 to 32004 (Indicator mode)

Depending on the request (Data or IndicData), data is returned in Record or Indicator mode. One record is returned for each Performance Group slot in the system GDO. The unused slots are padded with blanks. The format of this Performance Group Record parcel is described below.

EndStatement 11 6 StatementNo = 2

EndRequest 12 4 None

Page 323: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsPERFGROUPS

Workload Management API: PM/API and Open API 323

Sample Input

The following example illustrates how the parcels for a PERFGROUPS request built by look when sent to the Teradata Database server when the mon_ver_id value is not checked. In this example, the size of the response buffer is set at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

The following examples show typical data sets returned in character text format for the PERGROUPS request.

• Example 1 shows a representative set of user-defined (using schmon) Priority Scheduler settings that are used by the system when Category 3 is disabled in Teradata DWM.

• Example 2 shows a representative set of Priority Scheduler settings created in Teradata DWM that are used by the system when Category 3 is enabled.

The PERGROUPS request you submit may return information in a different format.

Note: The original system Performance Groups are saved while the Teradata DWM settings are used and are reactivated if Category 3 is disabled.

Example 1Submitting request TDWM PERFGROUPS; ...

Resource Partition items: 5

Resource Partition Name : Default Resource Partition Name : RP1 Resource Partition Name : standard

Field Name Data TypeLength(Bytes) Description

Performance Group Name

CHAR 16 The name of the Performance Groups. The names are padded with blanks to fill the entire field.

Note: The unused Performance Groups have names which are all blanks.

Resource Partition Index

SMALLINT 2 An index that associates this Performance Group back to one of the Resource Partitions named in a previous Resource Partition record.

Flavor Length Body

Num Name Bytes Field Value

0001 Req 17 Request PERFGROUPS

0004 Resp 6 BufferSize 32731

Page 324: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsPERFGROUPS

324 Workload Management API: PM/API and Open API

Resource Partition Name : Resource Partition Name :

Performance Group items: 40

RP#: 0, PG-Name: L RP#: 0, PG-Name: M RP#: 0, PG-Name: H RP#: 0, PG-Name: R RP#: 1, PG-Name: M1 RP#: 1, PG-Name: H1 RP#: 1, PG-Name: L1 RP#: 1, PG-Name: R1 RP#: 2, PG-Name: PGWL5 RP#: 2, PG-Name: PGWL10 PG#: 0, PG-Name: . . .

Example 2Submitting request TDWM PERFGROUPS; ...Resource Partition items: 5

Resource Partition Name : DEFAULT Resource Partition Name : TACTICAL Resource Partition Name : STANDARD Resource Partition Name : Resource Partition Name :

Performance Group items: 40

RP#: 0, PG-Name: L RP#: 0, PG-Name: M RP#: 0, PG-Name: H RP#: 0, PG-Name: R RP#: 2, PG-Name: PGWL3 RP#: 2, PG-Name: PGWL5 RP#: 2, PG-Name: PGWL4 RP#: 2, PG-Name: PGWL2 RP#: 2, PG-Name: PGWL1 RP#: 0, PG-Name: UNUSED9 RP#: 0. PG-Name: . . .

Warning and Error Messages

If the PERFGROUPS request cannot be processed by Teradata Dynamic Workload Management, the follow error message may be returned in a Failure parcel:

3318 Response message size is too small.

For more detailed information on warning and error messages, see Messages.

Page 325: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM DELAY REQUEST CHANGE

Workload Management API: PM/API and Open API 325

TDWM DELAY REQUEST CHANGE

PurposeReleases or aborts a specific request or session on the Teradata Dynamic Workload Management delay queue.

Input Data

Element Data TypeLength(Bytes) Description

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 6 or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Request Flag SMALLINT 2 Indicator of whether or not the request or session was aborted or released. The following values apply:

• 0 = Request is aborted

• 1 = Request is released

• 2 = Session is aborted

• 3 = Session is released

Host ID SMALLINT 2 The ID of the host number upon which the session containing the delayed request was established.

Reserved SMALLINT 2 The mod-4 alignment padding.

Session Number INTEGER 4 The number of the session in which the delayed request was submitted. A unique session number is assigned by the host (or client) at logon.

Request Number INTEGER 4 The active request number.

Note: This field is not used if Request Flag is either 2 or 3.

Workload Class Id INTEGER 4 The workload class ID associated with the delayed request.

If the request is from the context delay queue (where there is no workload class ID), then the field value is zero.

Note: This field is not used if Request Flag is either 2 or 3.

Page 326: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM DELAY REQUEST CHANGE

326 Workload Management API: PM/API and Open API

Usage Notes

A user must have ABORTSESSION and MONSESSION privileges to execute the TDWM DELAY REQUEST CHANGE request.

The TDWM DELAY REQUEST CHANGE request allows requests or sessions to be processed out of the normal first-in-first-out (FIFO) order.

Note: Before you submit a TDWM DELAY REQUEST CHANGE request you need to run a TDWM STATISTICS or MONITOR SESSION request to obtain information about the delayed query that requires change. Use the output of the request to identify the Host Id, Session Number, Request Number, and Workload Class Id parameters required as part of the TDWM DELAY REQUEST CHANGE input.

If the identified request or session is not found in the Teradata Dynamic Workload Management delay queue, an error is returned. For information on this error message, see “Warning and Error Messages” on page 344. This condition is expected since requests or sessions are normally released from the delay queue whereas the information in the TDWM STATISICS request could be outdated.

Parcels

Parcel Sequence

Parcel Flavor Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo=1

ActivityCount=0

ActivityType= 155 (PCLTWMDELRQSTCHGSTMT)

EndStatement 11 6 StatementNo = 2-byte integer=1

EndRequest 12 4 None

Page 327: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM DELAY REQUEST CHANGE

Workload Management API: PM/API and Open API 327

Sample Input

The following example shows how the parcels for a TDWM DELAY REQUEST CHANGE request, built by CLIv2, appear when sent to the Teradata Database server.

Note: In this example, the size of the response buffer in the example is set at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

The TDWM DELAY REQUEST CHANGE request returns values approximately as shown below when Category 3 is enabled in Teradata DWM and the following input data is specified:

• Request Flag = 0

• Host Id =1

• Request Number = 5

• Session Number = 1000

• Workload Class Id = 10

The TDWM DELAY REQUEST CHANGE request commonly returns values in text character format. Your application program may return the values in a different format or display.

Success parcel: StatementNo: 1 ActivityCount: 1 ActivityType: 155 FieldCount: 1DataInfo parcel: FieldCount: 1EndStatement.EndRequest.

Warning and Error Messages

If the DELAY REQUEST CHANGE request cannot be processed by Teradata Dynamic Workload Management, one of the following error messages may be returned in the Failure parcel.

Flavor Length Body

Num Name Bytes Field Value

0001 Req 16 Request TDWM DELAY REQUEST CHANGE

0003 Data 24 mon_ver_id

Request Flag

Host Id

Request Number

Session Number

Workload Class Id

7

0

1

5

1000

10

0004 Resp 6 BufferSize 32731

Page 328: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM DELAY REQUEST CHANGE

328 Workload Management API: PM/API and Open API

For more detailed information on warning and error messages, see Messages.

Message Number Description

3305 The request cannot be found for this session.

Remedy: Correct the error and resubmit the request.

• If the request is no longer listed in the delay queue, Teradata Dynamic Workload Management has released it as part of normal FIFO processing of a delayed query.

• If the request is still listed in the delay queue, you may have included incorrect information for one of the input parameters. Review the input, correct the error, and resubmit the request.

3306 The specified request or session cannot be released or aborted.

• For a request, this could be a request for Replication Services which is controlled internally.

• For a release session operation, this session probably still exceeds an internal limit; therefore, it should not be released to run.

Remedy: Correct the error and resubmit the request.

3326 The specified session cannot be found.

Remedy: Correct the error and resubmit the request.

3327 A utility session in the delay queue has been aborted by the Administrator or Operations Staff.

Remedy: None.

Page 329: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM LIST WD

Workload Management API: PM/API and Open API 329

TDWM LIST WD

PurposeReturns the names of the workload classes.

Input Data

Usage Notes

A user must have ABORTSESSION and MONSESSION privileges to execute the TDWM LIST WD request.

The TDWM LIST WD request returns the workload definition (WD) information from the internal cache being used by Teradata Dynamic Workload Management. Category 3 must be enabled in Teradata DWM to use this request, as it is only applicable to Category 3. WDs are returned in the order defined for evaluation.

Parcels

Element Data TypeLength(Bytes) Description

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 6 or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

enabled_only SMALLINT 2 The workload class names returned based on whether or not they are enabled. The following values apply:

• 0 = Enabled or disabled

• 1 = Enabled only

Parcel Sequence Parcel Flavor Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = 1 record for each workload definition being used by the Teradata Dynamic Workload Manager (Teradata DWM) at the time. There can a maximum of 40.

ActivityType = 161 (PCLTWMLISTWDSTMT)

DataInfo 71 6 to 32004 Optional: This parcel is present if request was IndicData parcel.

Page 330: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM LIST WD

330 Workload Management API: PM/API and Open API

The following table describes the format of the WD Information Record parcel.

Sample Input

The following example shows how the parcels for a TDWM LIST WD request, built by CLIv2, appear when sent to the Teradata Database server.

Note: In this example, the size of the response buffer in the example is set at the maximum (32,731 bytes), although you can set it to any size.

Record 10 • 5 to 32004 (Record mode)

• 6 to 32004 (Indicator mode)

Depending on the request (Data or IndicData), data is returned in Record or Indicator mode. There is one WD Information record returned for each WD satisfying the request. The format of this record is described below.

EndStatement 11 6 StatementNo = 1

EndRequest 12 4 None

Field Name Data Type Length (Bytes) Description

Configuration ID SMALLINT 2 The configuration ID of the current rule set.

Enabled Flag SMALLINT 2 An indicator of whether or not the workload class is currently enabled.

WLC ID INTEGER 4 The workload class ID associated with the specified request.

Name Length SMALLINT 2 The length of the workload class name.

WLC Name CHAR 30 The name of the workload class.

Note: Characters after the name length are not initialized.

Parcel Sequence Parcel Flavor Length (Bytes) Comments/Key Parcel Body Fields

Flavor Length Body

Num Name Bytes Field Value

0001 Req 16 Request TDWM LIST WD

0003 Data 4 mon_ver_id

enabled_only

7

1

0004 Resp 6 BufferSize 32731

Page 331: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM LIST WD

Workload Management API: PM/API and Open API 331

Sample Output

With an enabled_only value of 1, this example shows only the enabled WDs on the current system in character text format for the LIST WD request when Category 3 is enabled in Teradata DWM. Your application program may return these values in a different format.

Submitting request TDWM LIST WD; ...TDWM LIST WD successful.

Config ID : 1 Enable Flag : 1 WLC ID : 3 Name Len : 11WLC Name : WD-ConsoleH

Config ID : 1 Enable Flag : 1 WLC ID : 5 Name Len : 11 WLC Name : WD-ConsoleL

Config ID : 1 Enable Flag : 1 WLC ID : 4 Name Len : 11 WLC Name : WD-ConsoleM

Config ID : 1 Enable Flag : 1 WLC ID : 2 Name Len : 11 WLC Name : WD-ConsoleR

Config ID : 1 Enable Flag : 1 WLC ID : 1 Name Len : 10 WLC Name : WD-Default

Warning and Error Messages

If the TDWM LIST WD request cannot be processed by Teradata Dynamic Workload Management, one of the following error messages may be returned in a Failure parcel.

Message Number Description

3302 Teradata DWM information is not available.

The PMPC request submitted requires Teradata DWM be enabled for Category 3.

Remedy: Correct the error and resubmit the request.

3318 Response message size is too small.

Remedy: Increase the response message size and resubmit the request.

Page 332: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM LIST WD

332 Workload Management API: PM/API and Open API

For more detailed information on warning and error messages, see Messages.

Page 333: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM STATISTICS

Workload Management API: PM/API and Open API 333

TDWM STATISTICS

PurposeReturns statistics from the Workload Query Manager (WQM) component of Teradata Dynamic Workload Management.

Input Data

Usage Notes

A user must have ABORTSESSION and MONSESSION privileges to execute the TDWM STATISTICS request.

The WQM enforces the Teradata Dynamic Workload Management rules on the number of active sessions, queries, workload classes and load/archive utilities for specified conditions.

The TDWM STATISTICS request returns information in the various record formats depending on the Request Flag supplied as described in the following table.

The Request Flag in the input record determines the format of the data in the response records, and in some cases the type of information contained within each statement (for example, a query or session).

For more information about the WQM process, see Teradata Dynamic Workload Manager User Guide.

Element Data TypeLength(Bytes) Description

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 6 or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Request Flag SMALLINT 2 The type of statistics returned. The following values apply:

• 0 = Object query counts

• 1 = Object logon counts

• 2 = Object delayed queries

• 3 = Workload query counts

• 4 = Workload delayed queries

• 5= (Load and archive) utility counts

• 6 = Utility delayed sessions

Note: The first session of the load/archive utility is delayed, which effectively delays the whole utility job.

Page 334: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM STATISTICS

334 Workload Management API: PM/API and Open API

The following table specifies which format types are returned.

Note: These formats are defined later in this section.

Parcels

The TDWM STATISTICS request is a three statement request, with each statement generating a response. The three statement response returned from Teradata Database contains the following sequence of parcel types:

IF a Request Flag is...

THEN Format1Records Are Returned...

THEN Format2Records Are Returned...

THEN Format3Records Are Returned...

0 = object query counts X

1 = object logon counts X

2 = object delayed queries X

3 = workload query counts X

4 = workload delayed queries X

5 = load/archive utility counts X

6 = utility delayed sessions X

Parcel Sequence

Parcel Flavor Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1, 2, or 3

ActivityCount = Not applicable

ActivityType = 132 (PCLTDQMSTATSSTMT)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (Record mode)

• 6 to 32004 (Indicator mode)

Depending on the request (Data or IndicData), data is returned in Record or Indicator mode. This record contains information in StatementNo-1, StatementNo-2, or StatementNo-3 data format, depending on the Request Flag in the input data. There is one Record parcel for each item being tracked by the WQM. If there are no qualifying records, no Record parcel is sent.

EndStatement 11 6 StatementNo = 2-byte integer=1, 2 or 3

EndRequest 12 4 None

Page 335: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM STATISTICS

Workload Management API: PM/API and Open API 335

Statement Type: 1

The first statement type is a Record parcel format containing statistical information about the queries, sessions, and workload definitions being tracked by the WQM based on Teradata Dynamic Workload Management rules. The following table describes this Record format.

Field Name Data TypeLength (Bytes) Description

Record Type SMALLINT 2 The type of information contained in this record.

The following values apply:

• 1 = User

• 2 = Account

• 3 = Performance Group (PG)

• 4 = Account String (not used)

• 5 = Profile

• 6 = Client ID (not used)

• 7 = Network Address (not used)

• 8 = Application (not used)

• 9 = Rule Group

• 10 = Database

• 11 = Table

• 12 = Workload Definition (WD)

• 13 = Utility (not used)

• 14 = Macro

• 15 = Stored Procedure

• 16 = View

Rule or Workload Class ID

INTEGER 4 The ID of the Object Throttle Rule or Workload Class for this statistic.

If Request Flag is 0 or 1, then the ID of the Object Throttle Rule is returned.

If the Request Flag is 3, then the ID of the Workload Class is returned.

Object Name CHAR 32 For Request Flags 0 and 1, this is the name of the object based on its Record Type. When Record Type is set to 11, 14, 15, or 16 this field is the qualifying database name for the Table Name field.

For Request flag 3, this field is always empty.

Table Name CHAR 32 For Request Flags 0 and 1, this is the name of the table, macro, or stored procedure object when Record Type is set to 11, 14, 15, or 16.

For Request Flag 3, this field is always empty.

Active INTEGER 4 The number of requests currently active. This is the number of active queries or sessions depending on the information requested in the input record.

Page 336: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM STATISTICS

336 Workload Management API: PM/API and Open API

Example 1A

If a Request Flag of zero (object query counts) is requested, the following is an example of the records that are returned as part of the first statement type.

TYPE RULE/WLC ID OBJECT NAME TABLE NAME ACTIVE LIMIT DELAY RULE/WLC NAME----- ----------- ----------- ----------- ------ ------ ----- ------------- 1 1 LUMBER 2 2 1 test2 1 2 LUMBER 1 1 0 test4 11 3 LUMBER ORDERS 1 1 0 table test 14 4 LUMBER VENDMACRO 0 1 1 macro test

This example shows the following important information:

• Three of the four record entries have requests running (Active) and also have rules defined on the number of queries that they are allowed to have running simultaneously (Limit).

• Two records (test2 and macro test) have queries that are being delayed because they have exceeded their limit for simultaneously running queries.

• The “Rule/WLC ID” and “Rule/WLC Name” information is to be interpreted as the Rule name and ID because the Request Flag is set to zero.

Note: The last entry in the example above has an Active count of zero although there is one query delayed and the Limit is one. This is because this query was delayed because another rule also applied to it, and the other rule had already reached its limit.

Since the input requests query information (a Request Flag of zero), the numbers shown reflect the number of active queries for each object/rule combination. If logon information had been requested (a Request Flag of 1) in the input, the records would reflect the number of active sessions for each object/rule combination.

Note: The system will not collect statistics for objects that are not active. Record types will not appear in the output if there are no currently active objects of that type within the system.

Example 1B

If a Request Flag of 3 (workload query counts) is requested, the following example is typical of the records returned as part of the first statement type.

TYPE RULE/WLC ID OBJECT NAME TABLE NAME ACTIVE LIMIT DELAY RULE/ WLC NAME ---- ----------- ----------- --------------------- ----- ------ --------------

Limit INTEGER 4 The current minimum limit on this item. This is the limit on the number of queries or sessions depending on the information requested in the input record.

Delayed INTEGER 4 The number of requests currently delayed (queued) for this item.

Rule or Workload Class Name

CHAR 32 The name of the Object Throttle Rule or Workload Class for this statistic.

If Request Flag is 0 or 1, then the name of the Object Throttle Rule is returned.

If the Request Flag is 3, then the name of the Workload Class is returned.

Field Name Data TypeLength (Bytes) Description

Page 337: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM STATISTICS

Workload Management API: PM/API and Open API 337

12 0 -1 0 1 12 2 0 -1 0 WD-ConsoleR 12 3 0 -1 0 WD-ConsoleH 12 4 0 -1 0 WD-ConsoleM 12 5 0 -1 0 WD-ConsoleM 12 1 0 -1 0 WD-ConsoleL 12 6 2 2 5 test-wd

The “Rule/WLC ID” and “Rule/WLC Name” information is to be interpreted as the Workload Class ID and name because the Request Flag is set to 3.

The first entry shows a WLC ID of zero. In this particular case, the Delay column values represent the number of queries delayed by all object Throttle rules. Since this may represent multiple objects and rules, there is no object name and the Active and Limit fields are not valid. The entries with a Limit of -1 represent statistics for Workload Classes that do not have a throttle limit specified and, therefore, queries are not counted. The last entry contains statistics for a Workload Class that does have a throttle limit specified, and it has delayed five queries.

Statement Type: 2

The second statement type is a Record parcel format containing information about queries or sessions being delayed by Teradata Dynamic Workload Management due to an object, workload definition or utility throttle limit. There is one record for each request or session that is being delayed.

The following table describes this Record format.

Field Name Data TypeLength(Bytes) Description

User name CHAR 32 The user name provided at logon time. The names are padded with blanks to fill the entire field.

HostId SMALLINT 2 The host ID of the session number associated with the delayed request or session.

Session Number

INTEGER 4 The number associated with the held request or session.

Request Number

INTEGER 4 The request number associated with the delayed request or session.

This field is zero if Request Flag is 6.

Page 338: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM STATISTICS

338 Workload Management API: PM/API and Open API

Example 1

If a Request Flag of 2 (object delayed queries) is requested, the following Record parcels could be returned as part of the second statement type.

USER NAME HOST SESSION REQUEST RULE/WLC NAME RULE/WLC ID DELAY OV BL IFP#--------- ---- ------- ------- ------------- ----------- ----- -- -- ----- LUMBER 1 1014 3 test4 2 23 1 0 29716 LUMBER 1 1015 3 test2 1 23 1 0 29716

The “Rule/WLC ID” and “Rule/WLC Name” information is to be interpreted as the Rule name and ID because the Request Flag is set to 2.

Rule or Workload Class Name

CHAR 32 The name of the Object Throttle Rule or Workload Class for this statistic.

If Request Flag is 2 or 6, then the name of the Object Throttle Rule is returned.

If Request Flag is 4, then the name of the Workload Class is returned.

Rule or Workload Class ID

INTEGER 4 The ID of the Object Throttle Rule or Workload Class for this statistic.

If Request Flag is 2 or 6, then the ID of the Object Throttle Rule is returned.

If Request Flag is 4, then the ID of the Workload Class is returned.

Time Held INTEGER 4 The number of seconds that this request or session has been held by the WQM.

Overridable INTEGER 4 Indicator of whether or not the database administrator is allowed to abort or release the request.

Note: The replication and queue table requests are controlled internally by the database and cannot be altered by the administrator.

If Request Flag is 6, this field indicates if the delayed session can be released. A session cannot be released if it exceeds the internal AMP worker task limit or an internal utility limit.

A delayed session can always be aborted.

Blocking Count

INTEGER 4 The number of consecutive times that this session has been identified as blocking at least one other session.

This field is zero if Request Flag is 6.

IFP ID SMALLINT 4 The ID of the PE vproc which initiated this request.

Field Name Data TypeLength(Bytes) Description

Page 339: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM STATISTICS

Workload Management API: PM/API and Open API 339

Example 2

If a Request Flag of 4 (workload delayed queries) is requested, the following Record parcels could be returned as part of the second statement type.

USER NAME HOST SESSION REQUEST RULE/WLC NAME RULE/WLC ID DELAY OV BL IFP#---------- ---- ------- ------- ------------- ----------- ----- -- -- ----- LUMBER 1 1014 3 test-wd 6 6 1 0 29716 LUMBER 1 1015 3 test-wd 6 6 1 0 29716

The “Rule/WLC ID” and “Rule/WLC Name” information is to be interpreted as the Workload Class name and ID because the Request Flag is set to 4.

Statement Type: 3

The third statement type is a Record parcel format containing information on the utilities that are active in the system. The following table describes this record format.

Note: There is always one record for every utility type.

The following is an example of the records that are returned as part of third statement type:

Since a row is returned for each utility type, the Limit value can be either the system default value for the utility or a rule Throttle value.

Field Name Data TypeLength (Bytes) Description

Utility Type SMALLINT 2 The type of utility information contained in this record.

The following values apply:

• 0 = MultiLoad + FastLoad utility

• 1 = MultiLoad utility

• 2 = FastLoad utility

• 3 = FastExport utility

• 4 = ARC utility

Count SMALLINT 2 The number of utilities of this utility type that are active.

Limit SMALLINT 2 The current limit on the number of utilities of this type.

A value of -1 indicates there is no limit defined.

Type Active Limit0 4 5

1 1 30

2 3 30

3 2 5

Page 340: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM STATISTICS

340 Workload Management API: PM/API and Open API

Note: When a rule Throttle value is active, it overrides the default limit.

Warning and Error Messages

No error messages are returned for this request.

Page 341: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM SUMMARY

Workload Management API: PM/API and Open API 341

TDWM SUMMARY

PurposeCollects summary data for each workload definition (WD) defined in the database.

Input Data

The mon_ver_id element specifies the MONITOR software version ID. This can be version 6 or 7.

mon_ver_id is a SMALLINT data type and has a length of 2 bytes.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Usage Notes

A user must have ABORTSESSION and MONSESSION privileges to execute the TDWM SUMMARY request.

This interface allows the Teradata Manager application to receive Teradata Dynamic Workload Management summary information from the database for all queries completed in the summary interval for the workload definition (WD).

There is one record per WD active in the system. The data returned depends upon the data requested through the Request Flag. The record could contain counts of the number of queries that were classified into the WD in the collection period and the number of queries that completed in the collection period along with query statistics.

TDWM Summary returns information for all queries completed in the summary interval for the workload definition.

Parcels

The TDWM SUMMARY request is treated internally as a two statement request, with each statement generating a response. The two statement response returned from Teradata Database contains the following sequence of parcel types:

Parcel Sequence

Parcel Flavor Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = 1

ActivityType = 156 (PCLTWMSUMMARYSTMT)

Page 342: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM SUMMARY

342 Workload Management API: PM/API and Open API

Statement Type: 1

The response to the first statement results in a Record parcel containing the SampleSec field. SampleSec is the duration of the sample period, in seconds. This value represents the collection rate.

Statement Type: 2

The response to the second statement (Request Flag is 0 or 2) results in a Record parcel that consists of summary information for an active WD in the system collected in the last collection period. There is one record for each WD.

The following table describes the format of the Summary Data Record parcel.

DataInfo 71 6 to 32004 Optional: This parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (Record mode)

• 6 to 32004 (Indicator mode)

Depending on the request (Data or IndicData), data is returned in Record or Indicator mode.

This is the only record returned.

EndStatement 11 6 StatementNo = 2-byte integer

Success 8 18 to 273 StatementNo = 2

ActivityCount = number of record parcels returned

ActivityType = 134 (PCLTDWMSUMSTMT)

DataInfo 71 6 to 32004 Optional: This parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on the request (Data or IndicData), data is returned in Record or Indicator mode. There is one Summary Data record returned for each active WD. The format of this record is described below.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Field Name Data TypeLength(Bytes) Description

WD ID INTEGER 4 The workload definition ID to which the request should be assigned.

Arrivals INTEGER 4 The number of queries classified and started under this WD.

Parcel Sequence

Parcel Flavor Length (Bytes) Comments/Key Parcel Body Fields

Page 343: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM SUMMARY

Workload Management API: PM/API and Open API 343

Sample Input

The following example shows how the parcels for a TDWM SUMMARY request, built by CLIv2, appear when sent to the Teradata Database server.

Completions INTEGER 4 The number of queries assigned to this WD that completed.

Minimum Response Time

FLOAT 8 The minimum response time of any query.

Maximum Response Time

FLOAT 8 The maximum response time for any query.

Average Response Time

FLOAT 8 The average response time for this WD based on the total response time of all completions divided by number of completions.

Minimum CPU Time

FLOAT 8 The minimum CPU time used by any query.

Maximum CPU Time

FLOAT 8 The maximum CPU time used by any query.

Average CPU Time FLOAT 8 The average CPU time for this WD based on the total of CPU times of all completions divided by the number of completions.

Delayed Count INTEGER 4 The number of queries that were delayed in this WD.

Average Delay Time FLOAT 8 The average delay time for all queries assigned to this WD.

Exception Count INTEGER 4 The number of queries with exceptions in this WD.

Met SLG Count INTEGER 4 The number of queries assigned to this WD that met the Service Level Goals (SLGs).

Active Query Count INTEGER 4 The number of active queries assigned to this WD.

Active Delayed Count

INTEGER 4 The number of currently delayed queries in this WD.

Error Count INTEGER 4 The number of queries that had an error in this WD.

Abort Count INTEGER 4 The number of queries that were aborted in this WD.

Other Count INTEGER 4 This field is not currently used.

Field Name Data TypeLength(Bytes) Description

Page 344: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM SUMMARY

344 Workload Management API: PM/API and Open API

Note: In this example, the size of the response buffer in the example is set at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

The following example shows TDWM Summary data in character text format returned by the TDWM SUMMARY request. Your application program may return this data in a different format or display.

Note: Teradata Dynamic Workload Management Category 3 must be enabled to submit a SUMMARY request.

TDWM Summary data reports WD statistics over a given period. As shown in this snapshot of the WD activity, queries have been classified into WDs 1 and 3 and not WDs 2, 4, and 5.

TDWM Summary Request successful.

Sample Seconds: 60TDWM Summary - # of WDIds: 5

WLCID Arrivals Complete WereDlyd Exceptns Met SLG CurrActv CurrDlyd Min Resp Max Resp Avg Resp Min CPU Max CPU Avg CPU AvgDelay ----- -------- -------- -------- -------- -------- -------- -------- 3 11 11 0 0 11 1 0 0.0 1126.0 436.0 0.0 1633.0 510.0 0.0 5 0 0 0 0 0 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 4 0 0 0 0 0 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2 0 0 0 0 0 0 0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1 9 8 0 0 8 0 0 0.0 428.0 107.0 0.0 10.0 0.0 0.0

Warning and Error Messages

If this request cannot be processed by Teradata Dynamic Workload Management, the following error message may be returned in a Failure parcel:

3318 Response message size is too small.

For more detailed information on warning and error messages, see Messages.

Flavor Length Body

Num Name Bytes Field Value

0001 Req 16 Request TDWM SUMMARY

0003 Data 96 mon_ver_id 7

0004 Resp 6 BufferSize 32731

Page 345: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM WD ASSIGNMENT

Workload Management API: PM/API and Open API 345

TDWM WD ASSIGNMENT

PurposeChanges the workload a session or request is assigned to.

Input Data

Usage Notes

A user must have ABORTSESSION and MONSESSION privileges to execute the TDWM WD ASSIGNMENT request.

This request is comparable to changing the session priority by the way of the SQL SET SESSION ACCOUNT statement when Category 3 (Workloads) is disabled in Teradata DWM.

Element Data TypeLength (Bytes) Description

mon_ver_id SMALLINT 2 The MONITOR software version ID. This can be version 6 or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

host_id SMALLINT 2 The host upon which the session was established. The host ID cannot exceed 1023. A host ID of zero identifies the database operator console.

session_no INTEGER 4 The number for the session associated with this record. This value is assigned by the host (or client) at logon.

Together with a given Host ID, a session number uniquely identifies a session on the Teradata Database system.

PE_vproc_no SMALLINT 2 The PE vproc number where the session runs.

scope SMALLINT 2 The scope of the change defined. The following values apply:

• 0 = Current request

• 1 = Session

For examples of the scope field, see “Usage Notes” on page 345.

WLC_id INTEGER 4 The workload definition ID to which the request should be assigned.

Page 346: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM WD ASSIGNMENT

346 Workload Management API: PM/API and Open API

Use TDWM WD ASSIGNMENT to change the assigned WD for an individual request or session in cases where the rules imposed by the current WD prevent it from running as needed.

Use the MONITOR SESSION request to determine host_id, session_no, PE_vproc_no, scope, and WLC_id for the TDWM WD ASSIGNMENT input.

Note: Category 3 must be enabled in Teradata DWM to use this request.

The following table shows how the scope determines the effects of the TDWM WD ASSIGNMENT.

Parcels

Sample Input

The following example shows how the parcels for a TDWM WD ASSIGNMENT request, built by CLIv2, appear when sent to the Teradata Database server.

Note: In this example, the size of the response buffer in the example is set at the maximum (32,731 bytes), although you can set it to any size.

IF... THEN...

scope = 0 (current request) and there is no active request.

this request has no effect.

scope = 0 (current request) and there is an active request.

the current active request is moved into the specified WD. The “change workload” exception if specified is ignored for this request.

scope = 1 (session) and there is no active request

all subsequent requests on this session are assigned into the specified WD. If specified, the “change workload” exception is ignored for all requests.

scope = 1 (session) and there is an active request

the current active request, and all subsequent requests on the session, move into the specified WD. If specified, the “change workload” exception is ignored for all requests.

Parcel Sequence

Parcel Flavor Length (Bytes) Comments/Key Parcel Body Fields

Success 8 18 to 273 StatementNo = 1

ActivityCount = 0

ActivityType = 159 (PCLTWMWDASSIGNMENTSTMT)

EndStatement 11 6 StatementNo = 1

EndRequest 12 4 None

Page 347: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM WD ASSIGNMENT

Workload Management API: PM/API and Open API 347

Sample Output

The TDWM WD ASSIGNMENT request returns values approximately as shown below when Category 3 is enabled in Teradata DWM and the following input data is specified:

• host_id = 1

• session_no = 1000

• PE_vproc_no =16383

• scope = 1

• WLC_id = 3

The TDWM WD ASSIGNMENT request commonly returns values in text character format. Your application program may return the values in a different format or display.

Success parcel: StatementNo: 1 ActivityCount: 1 ActivityType: 159 FieldCount: 1DataInfo parcel: FieldCount: 1EndStatement.EndRequest.

Warning and Error Messages

If this request cannot be processed by Teradata Dynamic Workload Management, one of the following error messages may be returned in a Failure parcel.

Flavor Length Body

Num Name Bytes Field Value

0001 Req 16 Request TDWM WD ASSIGNMENT

0003 Data 8 mon_ver_id

host_id

session_no

PE_vproc_no

scope

WLC_id

7

1

1000

16383

1

3

0004 Resp 6 BufferSize 32731

Message Number Description

3256 No such session is currently logged on.

The session number specified in the request is not logged on to the given PE.

Remedy: Correct the error and resubmit the request.

Page 348: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWM WD ASSIGNMENT

348 Workload Management API: PM/API and Open API

For more detailed information on warning and error messages, see Messages.

3299 The PE Vproc number is invalid.

The PE Vproc number specified in the request is not a valid PE Vproc number or the PE Vproc is offline.

Remedy: Correct the error and resubmit the request.

3300 The scope is invalid.

The scope specified is invalid.

Remedy: Correct the error and resubmit the request.

3301 The target WD is invalid or inactive.

The WLC ID specified as an input parameter is invalid or inactive.

Remedy: Correct the error and resubmit the request.

3302 Teradata DWM information is not available.

The PMPC request submitted requires Teradata DWM be enabled for Category 3.

Remedy: Correct the error and resubmit the request.

3303 This is a load utility session.

Teradata Dynamic Workload Management WD ASSIGNMENT with REQUEST scope is not allowed on a utility session.

Remedy: Correct the error and resubmit the request.

3318 Response message size is too small.

Remedy: Increase the response message size and resubmit the request.

Message Number Description

Page 349: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsUSER EVENT CONTROL

Workload Management API: PM/API and Open API 349

USER EVENT CONTROL

PurposeActivates and deactivates a user event.

Input Data

Usage Notes

A user must have ABORTSESSION and MONSESSION privileges to execute the USER EVENT CONTROL request.

User Events are defined externally only by the name and the attribute of being either active or inactive. User Events also have an optional duration time that determines the length of time the Activate event persists. The event times out at the end of the duration time unless it is de-activated or re-activated. A Duration value of zero indicates the Activate (a Request Type value

Element Data TypeLength(Bytes) Description

mon_ver_id SMALLINT,NOT NULL

2 The MONITOR software version ID. This can be version 6 or 7.

For a general explanation of monitor version choices, see “MONITOR VERSION” on page 156.

Request Type SMALLINT,NOT NULL

2 The type of request specified. The following values apply:

• 0 = Deactivate event identified in Event Name

• 1 = Activate event identified in Event Name

Event Name CHAR,NOT NULL

32 The name of the user event. The event name is a maximum of 30 characters and must be padded with blanks. It is also case sensitive.

Duration INTEGER,NOT NULL

2 The time, in minutes, that this user event remains active. This field is valid for active requests only.

A value of zero means the event will remain true.

Note: The evaluation of all events, including user events, is based on the System Event Timer defined in Teradata DWM. If the Duration value is not a multiple of the System Event timer, then it is rounded to the next System Event timer value.

Page 350: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsUSER EVENT CONTROL

350 Workload Management API: PM/API and Open API

of 1) is persistent and lasts until explicitly made inactive by another User Event call. User Events persist across a TPA restart or system failure.

User Event names are global, or system wide and, therefore, you must make sure that no conflicting usages of User Event Control request calls occur.

Parcels

The following table lists information about the parcels for the USER EVENT CONTROL request.

The response to the USER EVENT CONTROL request results in a single Record parcel containing the result of the request.

Parcel Sequence Flavor Field Length Comments and Key Parcel Body Fields

Success 8 18 to 273 StatementNo=1

ActivityCount = 1

ActivityType = PCLUSEREVENTCONTROLSTMT (169)

DataInfo 71 6 to 32004 Optional: this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004(record mode)

• 6 to 32004(Indicator mode)

Depending on the request (Data or IndicData) data is returned in Record or Indicator mode. This is the only record returned.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

Field Name Data TypeLength(Bytes) Description

User-Defined Event Status

INTEGER,NOT NULL

2 The current status of the user-defined event. The following values apply:

• 0 = Inactive

• 1 = Active

Previous User-Defined Event Status

INTEGER,NOT NULL

2 The previous status of the user-defined event. The following values apply:

• 0 = Previously inactive

• 1 = Previously active

• 2 = Previously not defined

Page 351: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsUSER EVENT CONTROL

Workload Management API: PM/API and Open API 351

The USER EVENT CONTROL request can be used to activate or inactivate a single, specific User Event.

The response indicates if the operation was successful. For successful operations, the result (Previous User-Defined Event Status) shows the previous value of this User Event. This allows the user to know if the User Event was previously active or not. For example, a successful operation, can return any of the following results:

Note: This table only describes some of the possible response combinations, there are others.

Warning and Error Messages

The following table lists the possible error messages for an unsuccessful operation.

For more detailed information on warning and error messages, see Messages.

The result.... indicates...

1,0 the current User Event is Active and it was previously Inactive.

1,0 the current User Event is Inactive and it was previously Active.

1,2 the current User Event is Active and it was previously not defined.

Message Number Description

3302 Teradata DWM information is not available.

The PMPC request submitted requires Teradata DWM be enabled for Category 3.

Remedy: Correct the error and resubmit the request.

3323 The Teradata DWM event is not defined.

The event that was supplied in this request is not defined in the current rule set.

Remedy: Review logged error and resolve before attempting to resubmit the request.

3324 More data exists than was returned.

This is a warning that there were more records to be returned than would fit into the response buffer.

Remedy: Increase the size of the response buffer if all records are desired.

Page 352: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsSQL Interfaces

352 Workload Management API: PM/API and Open API

SQL Interfaces

This section describes the Teradata Dynamic Workload Management SQL interfaces that are used to manage the workload and update the stored components (such as, workload definitions and related data) in the tdwm database. These SQL interfaces consist of UDFs and external stored procedures that you can invoke from any application.

The Teradata Dynamic Workload Management UDFs and external stored procedures are created in Teradata Manager Database Setup along with Teradata Dynamic Workload Management tables (see “Requirements for Using the API” on page 31).

These SQL interfaces provide similar functionality to the Teradata Dynamic Workload Management CLIv2 interfaces.

Page 353: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMAbortDelayedRequest

Workload Management API: PM/API and Open API 353

TDWMAbortDelayedRequest

PurposeAborts a request or utility session on the Teradata Dynamic Workload Management delay queue.

Definition

REPLACE FUNCTION TDWMAbortDelayedRequest (HostId SMALLINT, SessionNo INTEGER, RequestNo INTEGER, WDId INTEGER

)RETURNS INTEGER...;

Input Parameters

Usage Notes

The TDWMAbortDelayedRequest function provides similar functionality to a TDWM DELAY REQUEST CHANGE request. For more information, see “TDWM DELAY REQUEST CHANGE” on page 325.

Return Value

This function returns a zero if it is successful.

Example

This example shows how to abort a delayed request on SessionNo 1011.

SELECT TDWMAbortDelayedRequest(HostId, SessionNo, RequestNo, 0) FROM TABLE (TDWMGetDelayedQueries('O')) AS t1

Input Parameter Description

HostId The host ID for the session.

SessionNo The number of the session.

RequestNo The request number of the task.

If the value is zero, the utility session will be aborted.

WDId The workload definition ID associated with the request in the delay queue being examined.

Page 354: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMAbortDelayedRequest

354 Workload Management API: PM/API and Open API

WHERE SessionNo=1011;

*** Query completed. One row found. One column returned. *** Total elapsed time was 3 seconds.

TDWMAbortDelayedRequest(HostId,SessionNo,RequestNo,0)----------------------------------------------------- 0

Assuming the request on SessionNo 1011 was delayed, it will be aborted as follows:

sel databasename from dbc.databasesv;

*** Starting at Tue Apr 26 15:22:42 2005

*** Failure 3151 TWM Workload violation: Delay Request Change Abort Statement# 1, Info =0

Page 355: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMApply

Workload Management API: PM/API and Open API 355

TDWMApply

PurposeApplies changes to one or more Teradata Dynamic Workload Management categories.

Definition

REPLACE PROCEDURE TDWMApply (IN RuleSetId INTEGER, IN FilterCat VARCHAR(1), IN ThrottleCat VARCHAR(1), IN WorkloadCat VARCHAR(1) ,

IN EventCat VARCHAR(1))

...;

Input Parameters

Usage Notes

Caution: Do not issue TDWMApply while holding locks on any Teradata Dynamic Workload Management tables. This will cause a self-deadlock condition because Teradata Database must read the Teradata Dynamic Workload Management tables to perform this apply.

Using the TDWMApply procedure, you can only apply changes to the active rule set.

Input Parameter Description

RuleSetID The ID of the rule set to apply. This must be the current rule set.

FilterCat The request for the Filter rules category. The following values apply:

• Y = Apply changes to the category

• N = Skip this category

ThrottleCat The request for the Object Limits category. The following values apply:

• Y = Apply changes to the category

• N = Skip this category

WorkloadCat The request for the Workload Classes category. The following values apply:

• Y = Apply changes to the category

• N = Skip this category

EventCat The request for the Event category. The following values apply:

• Y = Apply changes to the category

• N = Skip this category

Page 356: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMApply

356 Workload Management API: PM/API and Open API

This procedure activates all rules in the database for the category being applied.

Example

CALL TDWMApply (200, 'Y', 'N', 'N', 'N');

Page 357: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMAssignWD

Workload Management API: PM/API and Open API 357

TDWMAssignWD

PurposeChanges the workload a session or request is assigned to.

Definition

REPLACE FUNCTION TDWMAssignWD (HostId SMALLINT, SessionNo INTEGER, VprocNo INTEGER, Scope VARCHAR(1), WDId INTEGER

)RETURNS INTEGER...;

Input Parameters

Usage Notes

If Category 3 is disabled in Teradata DWM and if the database cannot find a valid host ID and session number combination, an error message is returned.

The TDWMAssignWD function provides similar functionality to a TDWM WD ASSIGNMENT request. For more information about this interface, see “TDWM WD ASSIGNMENT” on page 345.

Return Value

This function returns a zero if it is successful.

Input Parameter Description

HostId The ID of the host upon which the session was issued. HostId cannot exceed 1023. A hostid of zero identifies the database operator console.

SessionNo The session number. SessionNo combined with HostId produces a unique session ID.

VprocNo The PE Vproc number where the session runs.

Scope The scope of the change defined. The following values apply:

• R = Change the workload of the current request

• S = Change the workload of the session

WDId The workload definition ID to which the request should be assigned.

Page 358: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMAssignWD

358 Workload Management API: PM/API and Open API

Example

SELECT TDWMAssignWD(Hostid, sessionNo, runvprocno, 'S', 7)FROM TABLE (MonitorSession(1,'*',0)) AS t1where username='user14';

*** Query completed. 5 rows found. One column returned. *** Total elapsed time was 2 seconds.

TDWMAssignWD(HostId,SessionNo,RunVprocNo,'S',7)---------------------------------------------------- 0 0 0 0 0

Page 359: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMEventControl

Workload Management API: PM/API and Open API 359

TDWMEventControl

PurposeActivates or deactivates a user-defined event.

Definition

REPLACE PROCEDURE TDWMEventControl (IN EventName VARCHAR(30), IN Operation VARCHAR(1), IN Duration INTEGER, OUT NewStatus VARCHAR(8), OUT PriorStatus VARCHAR(8)

)...;

Input Parameters

Usage Notes

The user-defined event specified must be an existing event in the active rule set and can include the following actions:

• Notifications (for example, send alerts, run programs, or post to a queue table)

• Activate a system condition (SysCon) or operational environment (OpEnv). The highest priority for system conditions and operational environments determines the rule state values that the system will enforce. Rule attributes that can be changed based on the rule state include:

• Rule enable flag

• Rule session, query, and utility throttle limits

• Workload throttle limits

• Priority Scheduler Facility weights

Input Parameter Description

EventName The name of the event specified.

Operation The status of the event. The following values apply:

• A = Active

• I = Inactive

Duration The time, in minutes, after the event expires.

A value of zero indicates no expiration time.

Page 360: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMEventControl

360 Workload Management API: PM/API and Open API

When a SysCon or OpEnv is activated, Teradata Dynamic Workload Management will switch the attributes for the rule state if it is the highest priority active state. If not, it will be placed on the active state list. If it becomes the highest priority active state, then Teradata Dynamic Workload Management will switch to the rule state attributes.

For more information on SysCon, OpEnv, or Teradata Dynamic Workload Management in general, see Teradata Dynamic Workload Manager User Guide.

The TDWMEventControl procedure provides similar functionality to a USER EVENT CONTROL request. For more information about this interface, see “USER EVENT CONTROL” on page 349.

Output Parameters

Example

CALL TDWMEventControl('NodeDownEvent', 'A', 0, NewStatus, PriorStatus);

Column Name Description

NewStatus The status of the event after the procedure call.

PriorStatus The status of the event before the procedure call.

Page 361: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMEventMapping

Workload Management API: PM/API and Open API 361

TDWMEventMapping

PurposeLists all objects that make up the system state.

Definition

REPLACE FUNCTION TDWMEventMappingRETURNS TABLE

(ObjectType VARCHAR(10) CHARACTER SET LATIN, ObjectId INTEGER, ObjectName VARCHAR(30), ObjectStatus VARCHAR(8) CHARACTER SET LATIN, Precedence INTEGER,

EventKind VARCHAR(12) CHARACTER SET LATIN, StatusDate INTEGER, StatusTime FLOAT

)...;

Usage Notes

The TDWMEventMapping function provides similar functionality to an EVENT STATUS request. For more information about this interface, see “EVENT STATUS” on page 313.

Result Rows

Column Name Description

ObjectType The type of object, for example: an Event, Expression, SysCon, OpEnv, and a State.

ObjectId The internal object ID number.

ObjectName The name of the object.

ObjectStatus The status of the object. The following values apply:

• 0 = Inactive (false)

• 1 = Active (true)

Precedence An indicator of the Precedence or Severity of the SysCon or OpEnv object types only. The following values apply:

• SysCon = Indicates the Severity of the associated SysCon.

• OpEnv = Indicates the Precedence of the associated OpEnv.

EventKind The type of an event.

StatusDate The date that the object status occurred.

Page 362: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMEventMapping

362 Workload Management API: PM/API and Open API

Example

SELECT ObjectName, ObjectType, ObjectId, ObjectActive FROM TABLE (TDWMEventMapping()) AS t1 where objecttype='syscon';

*** Query completed. 3 rows found. 4 columns returned. *** Total elapsed time was 1 second.

ObjectName ObjectType ObjectId ObjectActive------------------------------ ---------- ----------- ------------Extra SysCon1 SYSCON 225 IDegraded SysCon SYSCON 250 INormal SYSCON 200 A

StatusTime The time that the object status occurred.

Column Name Description

Page 363: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMEventStatus

Workload Management API: PM/API and Open API 363

TDWMEventStatus

PurposeReturns the currently defined events.

Definition

REPLACE FUNCTION TDWMEventStatus( RequestType VARCHAR(1)) RETURNS TABLE (EventId INTEGER, EventStatus CHAR(1) CHARACTER SET LATIN, EventActiveDate INTEGER, EventActiveTime FLOAT, ExpressionId INTEGER, ExpressionStatus CHAR(1) CHARACTER SET LATIN, ExpActiveDate INTEGER, ExpActiveTime FLOAT, RecordType VARCHAR(8) CHARACTER SET LATIN, RecordId INTEGER, RecordStatus CHAR(1) CHARACTER SET LATIN, DueToDuration CHAR(1) CHARACTER SET LATIN, StateActiveDate INTEGER, StateActiveTime FLOAT

)...;

Input Parameter

The RequestType parameter specifies the type of events returned. The following values apply:

• A = All events

• C = Current state events

Usage Notes

The TDWMEventStatus function provides similar functionality to an EVENT STATUS request. For more information about this interface, see “EVENT STATUS” on page 313.

Page 364: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMEventStatus

364 Workload Management API: PM/API and Open API

Result Rows

Column Name Description

EventId The internal ID of the Event. A value of zero indicates there is no event associated with this record entry and there are no events associated with the Normal SysCon, the Always OpEnv and a State.

Events are reported in the order they appear within the associated expression. Only events included in the associated expression are included.

EventStatus The current status of the event. The value is either Inactive (false) or Active (true).

EventActiveDate The date when EventStatus was last changed. This is the date when the EventStatus was set to Inactive (false) or Active (true).

EventActiveTime The time EventStatus was last changed. This is the time when EventStatus is set to Inactive (false) or Active (true)

ExpressionId Internal ID of the Expression. A value of zero indicates there is no expression associated with this record entry.

There are no expressions associated with the Normal SysCon, the Always OpEnv, and a State.

For the CURRENT state request, the first TRUE expression associated with the associated State is included. When there are multiple true expressions for a state only the first one processed is reported. The order of processing is consistent within a rule set and, therefore, the same True expression is reported on every request.

ExpressionStatus The current status of the Expression. The following values apply:

• 0 = Inactive (false)

• 1 = Active (true)

ExpActiveDate The date when ExpressionStatus last changed.

ExpActiveTime The time Expression Status was last changed. This is the time when Expression Status was set to either Active (true) or Inactive (false).

RecordType The type of record, for example: a SysCon, OpEnv, or Notify Only Expression.

RecordId The internal ID of the SysCon or OpEnv depending on the type of record specified in the RecordType field.

A value of zero indicates the Notify Only Expression record type.

Page 365: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMEventStatus

Workload Management API: PM/API and Open API 365

Example

SELECT * FROM TABLE (TDWMEventStatus('c')) AS t1;

*** Query completed. 3 rows found. 14 columns returned. *** Total elapsed time was 1 second.

EventId 0 EventStatus I EventActiveDate 0 EventActiveTime 0.00000000000000E 000 ExpressionId 0ExpressionStatus I ExpActiveDate 0 ExpActiveTime 0.00000000000000E 000 RecordType SYSCON RecordId 1 RecordStatus A DueToDuration N ActiveDate 1070518 ActiveTime 8.39380000000000E 004 EventId 0 EventStatus I EventActiveDate 0 EventActiveTime 0.00000000000000E 000 ExpressionId 0ExpressionStatus I ExpActiveDate 0 ExpActiveTime 0.00000000000000E 000 RecordType OPENV RecordId 1 RecordStatus A DueToDuration N ActiveDate 1070518 ActiveTime 8.39380000000000E 004

RecordStatus The current status of the SysCon or OpEnv record. The following values apply:

• Y = Active

• N = Inactive

DueToDuration An indicator of whether the corresponding Syscon is being considered as TRUE or is TRUE.

The following values apply:

• 0 = Inactive (false) if the SysCon is TRUE based on the defined expressions.

• 1 = Active (true) if the corresponding SysCon is being considered as TRUE due to the MinDuration value being in affect.

Note: This field is valid only when SysCon is the specified RecordType.

StateActiveDate The date when RecordStatus was last changed.

StateActiveTime The time when RecordStatus was last changed.

Column Name Description

Page 366: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMEventStatus

366 Workload Management API: PM/API and Open API

EventId 0 EventStatus I EventActiveDate 0 EventActiveTime 0.00000000000000E 000 ExpressionId 0ExpressionStatus I ExpActiveDate 0 ExpActiveTime 0.00000000000000E 000 RecordType STATE RecordId 1 RecordStatus A DueToDuration N ActiveDate 1070517 ActiveTime 1.00006000000000E 005

Page 367: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMGetDelayedQueries

Workload Management API: PM/API and Open API 367

TDWMGetDelayedQueries

PurposeReturns the object delay queue and the workload delay queue.

Definition

REPLACE FUNCTION TDWMGetDelayedQueries (RequestType VARCHAR(1) CHARACTER SET LATIN

) RETURNS TABLE (Username VARCHAR(30) CHARACTER SET LATIN, HostId SMALLINT, SessionNo INTEGER, RequestNo INTEGER, WDName VARCHAR(30) CHARACTER SET LATIN, WDId INTEGER, TimeHeld INTEGER, OverRidable CHAR CHARACTER SET LATIN, BlockingCnt INTEGER );

Input Parameter

The RequestType parameter specifies the type of delay queue returned. The following values apply:

• 0 = Returns the object delay queue

• W = Returns the workload delay queue

• A = Returns all delayed queues

Usage Notes

This table function is only supported in Constant Mode.

Page 368: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMGetDelayedQueries

368 Workload Management API: PM/API and Open API

Result Rows

Example 1

This example shows how to get the object delay queue.

*** Query completed. One row found. 9 columns returned. *** Total elapsed time was 1 second.

Username LUMBER HostId 1 SessionNo 1010 RequestNo 3 WDName test2 WDId 1 TimeHeld 6676OverRidable YBlockingCnt 0

Column Name Description

Username The user name of the session. This is the name specified when the user is created; it is used to log on to a session. Within Teradata Database, user name is almost equivalent to database name.

HostId The host ID of the session number associated with the delayed request.

SessionNo The session number associated with the held request.

RequestNo The request number associated with the delayed request.

WDName The name of the Workload (Class) Definition (WD) or the Object Throttle Rule that caused the query to be delayed.

WDId The ID of the Workload (Class) Definition (WD) or the Object Throttle Rule that caused the query to be delayed.

TimeHeld The number of seconds that this request or session has been held.

OverRidable The request or session allowed to be aborted or released by the administrator. A session cannot be released if it exceeds the internal AMP worker task limit. A delayed session can always be aborted.

The following values apply:

• Y = Yes, this request or session is overridable.

• N= No, this request or session is not overridable.

Note: The replication and queue table requests are controlled internally by the database and cannot be altered by the administrator.

If Request Flag is 6, this field indicates if the delayed session can be released. A session cannot be released if it exceeds the internal AMP worker task limit or an internal utility limit.

A delayed session can always be aborted.

BlockingCnt A count of the number of consecutive times that this request has been identified as blocking at least one other session.

The value is zero if Request Flag is 6.

Page 369: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMGetDelayedQueries

Workload Management API: PM/API and Open API 369

Example 2

This example shows how to get the workload delay queue.

*** Query completed. 2 rows found. 9 columns returned. *** Total elapsed time was 1 second.

Username LUMBER HostId 1 SessionNo 1008 RequestNo 3 WDName test-wd WDId 6 TimeHeld 7131OverRidable YBlockingCnt 0

Username LUMBER HostId 1 SessionNo 1009 RequestNo 3 WDName test-wd WDId 6 TimeHeld 7114OverRidable YBlockingCnt 0

Example 3

This example shows how to get all the delay queues.

*** Query completed. 3 rows found. 9 columns returned. *** Total elapsed time was 1 second.

Username HostId SessionNo RequestNo WDName WDId TimeHeld OverRidable-------- ------ --------- --------- ------ ---- -------- ---------LUMBER 1 1010 3 test2 1 7717 YLUMBER 1 1008 3 test 6 7748 YLUMBER 1 1009 3 test 6 7731 Y

Page 370: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMGetDelayedUtilities

370 Workload Management API: PM/API and Open API

TDWMGetDelayedUtilities

PurposeReturns the utility delay queue.

Definition

REPLACE FUNCTION TDWMGetDelayedUtilities () RETURNS TABLE (Username VARCHAR(30), HostId SMALLINT, SessionNo INTEGER, TimeHeld INTEGER, OverRidable VARCHAR(3), RuleId INTEGER )...;

Result Rows

Column Name Description

Username The user name of the session. This is the name specified when the user is created; it is used to log on to a session. Within Teradata Database, user name is almost equivalent to database name.

HostId The host ID of the session number associated with the delayed utility.

SessionNo The session number associated with the held utility.

TimeHeld The number of seconds that this request has been held.

OverRidable The request or session allowed to be aborted or released by the administrator. A session cannot be released if it exceeds the internal AMP worker task limit. A delayed session can always be aborted.

The following values apply:

• Y = Yes, this request or session is overridable.

• N= No, this request or session is not overridable.

Note: The replication and queue table requests are controlled internally by the database and cannot be altered by the administrator.

If Request Flag is 6, this field indicates if the delayed session can be released. A session cannot be released if it exceeds the internal AMP worker task limit or an internal utility limit.

A delayed session can always be aborted.

RuleID The ID of the rule that caused this query to be delayed.

Page 371: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMGetDelayedUtilities

Workload Management API: PM/API and Open API 371

Example

SELECT * FROM TABLE (TDWMGetDelayedUtilities()) AS t1;

*** Query completed. 4 rows found. 6 columns returned. *** Total elapsed time was 1 second.

Username HostId SessionNo TimeHeld OverRidable RuleId---------- ------ --------- --------- ----------- ------USER1 1 2709 16 0 1USER1 1 2710 12 0 2USER1 1 2711 9 0 3DBC 1 2712 5 0 4

Page 372: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMInquire

372 Workload Management API: PM/API and Open API

TDWMInquire

PurposeReturns the status of each category (that is, whether it is active or not).

Definition

REPLACE FUNCTION TDWMInquire() RETURNS TABLE (RuleSetId INTEGER, FILTER_CATEGORY VARCHAR(10) CHARACTER SET LATIN, THROTTLE_CATEGORY VARCHAR(10) CHARACTER SET LATIN,

WORKLOAD_CATEGORY VARCHAR(10) CHARACTER SET LATIN,VENT_CATEGORY VARCHAR(10) CHARACTER SET LATIN)

...;

Result Rows

ExampleSELECT * FROM TABLE (TDWMinquire()) AS t1;

*** Query completed. One row found. 5 columns returned. *** Total elapsed time was 5 seconds.

RuleSetId Filter_Category Throttle_Category Workload_Category Event_Category--------- --------------- ----------------- ----------------- -------------- 9060 Inactive Inactive Active Active

Column Name Description

RuleSetId The ID of the rule set to apply. This must be the current rule set.

Filter_Category The current status of the Filter rule category. The value is either Active or Inactive.

Throttle_Category The current status of the Throttle rule category. The value is either Active or Inactive.

Workload_Category The current status of the Workload Definition rule category. The value is either Active or Inactive.

Event_Category The current status of the Event category. The value is either Active or Inactive.

Page 373: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMListWDs

Workload Management API: PM/API and Open API 373

TDWMListWDs

PurposeReturns a list of the workload definitions.

Definition

REPLACE FUNCTION TDWMListWDs (EnabledOnly VARCHAR(1)) RETURNS TABLE (RuleSetId INTEGER, EnabledFlag VARCHAR(10), WDId INTEGER, WDName VARCHAR(30)

)...;

Input Parameter

The EnabledOnly parameter determines the type of workload definitions returned. The following

values apply:

• N = All disabled and enabled

• Y = Enabled only

Usage Notes

This table function is only supported in Constant Mode.

The TDWMListWDs function provides similar functionality to a TDWM LIST WD request. For more information about this interface, see “TDWM LIST WD” on page 329.

Result Rows

Column Name Description

RuleSetId The rule set in which the workload definition is located.

EnabledFlag An indicator of whether or not the workload definitions specified are enabled or disabled.

WDId The workload definition ID to which the request should be assigned.

WDName The name of the workload definition.

Page 374: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMListWDs

374 Workload Management API: PM/API and Open API

Example

SELECT * FROM TABLE (TDWMListWDs('Y')) AS t1;

*** Query completed. 40 rows found. 4 columns returned. *** Total elapsed time was 2 seconds.

RuleSetId EnabledFlag WDId WDName----------- ----------- ----------- ------------------------------ 9889 Enabled 201 WD1 9889 Enabled 202 WD2 9889 Enabled 203 WD3 9889 Enabled 204 WD4 9889 Enabled 205 WD5 9889 Enabled 206 WD6 9889 Enabled 207 WD7 9889 Enabled 208 WD8 9889 Enabled 209 WD9 9889 Enabled 210 WD10

Page 375: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMLoadUtilStatistics

Workload Management API: PM/API and Open API 375

TDWMLoadUtilStatistics

PurposeReturns the statistics on the load utilities that are available in the system.

Definition

REPLACE FUNCTION TDWMLoadUtilStatistics() RETURNS TABLE (UtilityType VARCHAR(10), UtilityCount SMALLINT, UtilityLimit SMALLINT )...;

Result Rows

Note: There is one record for every utility.

Example

SELECT * FROM TABLE (TDWMLoadUtilSTATISTICS()) AS t1;

*** Query completed. 4 rows found. 3 columns returned. *** Total elapsed time was 3 seconds.

UtilityType UtilityCount UtilityLimit----------- ------------ ------------MultiLoad 0 30FastLoad 0 30FastExport 0 60ARC 0 350

Column Name Description

UtilityType The type of utility. The follow values apply:

• 0 = MultiLoad + FastLoad utility

• 1 = MultiLoad utility

• 2 = FastLoad utility

• 3 = FastExport utility

• 4 = ARC utility

UtilityCount The number of utilities of this type that are active.

UtilityLimit The current limit on the number of utilities of this type.

Page 376: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMObjectAssn

376 Workload Management API: PM/API and Open API

TDWMObjectAssn

PurposeAdds or removes an object association from rules.

Definition

REPLACE PROCEDURE TDWMObjectAssn (IN RuleSetId INTEGER, IN RuleName VARCHAR(30), IN TDWMLock VARCHAR(1), IN Operation VARCHAR(1), IN ObjectType VARCHAR(10), IN ObjectName VARCHAR(128), IN DBName VARCHAR(30), IN QuerybandValue VARCHAR(256),

IN Description VARCHAR(80))

...;

Input Parameters

Input Parameter Description

RuleSetId The ID of the rule set in which the rule is found.

RuleName The name of the rule specified.

TDWMLock The type of request performed on the TDWMLock table. The following values apply:

• W = Wait for the TDMWLock

• A = Abort if the TDWMLock table is locked

• S = Perform the update without locking the TDWMLock table

Note: Teradata DWM places an exclusive lock on the TDWMLock table at startup.

Operation Indicator of whether or not the object is associated to the rule. The following values apply:

• A = Associate object to rule

• R = Remove object association

Page 377: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMObjectAssn

Workload Management API: PM/API and Open API 377

Example

call tdwmobjectassn(2,'example1','s','a','user','joeeg',null,null);

*** Procedure has been executed. *** Total elapsed time was 1 second.

call tdwmobjectassn(2,'example2','s','r','user','joeeg',null,null);

*** Procedure has been executed. *** Total elapsed time was 1 second.call tdwmobjectassn(2,'example3','s','a','table','test','tdwm',null);

*** Procedure has been executed. *** Total elapsed time was 1 second.

ObjectType The type of object specified. The following values apply:

• USER = User

• ACCT = Account

• PROFIL = Profile

• DB = Database

• TABLE = Table

• MACRO = Macro

• SPROC = Stored Procedure

• ACCTSTR = Account String

• CLNAME = Client Name

• CLADDR = Client Address

• APPLIC = Application

• QRYBND = Query band name-value pair

• VIEW = View

• PERFG = Performance Group

ObjectName The qualified object name.

QuerybandValue The query band value specified if this is a query band object.

Description The description of the association.

Note: Only used when Operation is set to A (that is, Associate object to rule).

Input Parameter Description

Page 378: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMReleaseDelayedRequest

378 Workload Management API: PM/API and Open API

TDWMReleaseDelayedRequest

PurposeReleases a request or utility session in the Teradata Dynamic Workload Management delay queue.

Definition

REPLACE FUNCTION TDWMReleaseDelayedRequest (HostId SMALLINT, SessionNo INTEGER, RequestNo INTEGER, WDId INTEGER

)RETURNS INTEGER...;

Input Parameters

Usage Notes

The TDWMReleaseDelayedRequest function provides similar functionality to a TDWM DELAY REQUEST CHANGE request. For more information about this interface, see “TDWM DELAY REQUEST CHANGE” on page 325.

Return Value

This function returns a zero if it is successful.

Example 1: Releasing a Delayed Request

SELECT TDWMReleaseDelayedRequest(HostId, SessionNo, RequestNo, 0) FROM TABLE (TDWMGetDelayedQueries('O')) AS t1 WHERE SessionNo=4531;

Input Parameter Description

HostId The host ID for the session.

SessionNo The number of the session.

RequestNo The request number of the task.

If the value is zero, then the utility session will be released.

WDId The workload definition ID associated with the request in the delay queue being acted on.

Page 379: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMReleaseDelayedRequest

Workload Management API: PM/API and Open API 379

*** Query completed. One row found. One column returned. *** Total elapsed time was 1 second.

TDWMReleaseDelayedRequest(HostId,SessionNo,RequestNo,0)------------------------------------------------------- 0

Example 2 (Releasing Multiple Delayed Requests)

SELECT TDWMAbortDelayedRequest(HostId, SessionNo, RequestNo, 0) FROM TABLE (TDWMGetDelayedQueries('O')) AS t1 WHERE t1.Username='TwmUser33';

*** Query completed. One row found. One column returned. *** Total elapsed time was 1 second.

TDWMAbortDelayedRequest(HostId,SessionNo,RequestNo,0)----------------------------------------------------- 0

Page 380: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMRuleControl

380 Workload Management API: PM/API and Open API

TDWMRuleControl

PurposeUpdates the EnabledFlag of the rule and the EnabledFlag in the base state for the rule in the tdwm database.

Definition

REPLACE PROCEDURE TDWMRuleControl(IN RuleSetId INTEGER,IN RuleName VARCHAR(30),IN Operation VARCHAR,IN TDWMLock VARCHAR

)...;

Input Parameters

Usage Notes

The TDWMRuleControl procedure must be used with rules defined only with the base state as this is the only state value that the procedure changes.

Example

CALL TDWMRuleControl(1, 'throttle1', 'D', 'W');

Input Parameter Description

RuleSetId The ID of the rule set in which the rule is found.

RuleName The name of the rule specified.

Operation The request to enable or disable the rule. The following values apply:

• E = Enable the rule

• D = Disable the rule

TDWMLock The type of request performed on the TDWMLock table. The following values apply:

• W = Wait for the TDWMLock

• A = Abort if the TDWMLock table is locked

• S = Perform the update without locking the TDWMLock table

Note: Teradata DWM places an exclusive lock on the TDWMLock table at startup.

Page 381: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMSetLimits

Workload Management API: PM/API and Open API 381

TDWMSetLimits

PurposeUpdates the throttle limits of a rule in the tdwm database.

Definition

REPLACE PROCEDURE TDWMSetLimits (IN RuleSetId INTEGER, IN RuleName VARCHAR(30), IN TDWMLock VARCHAR(1), IN SessionLimit INTEGER,

IN QueryLimit INTEGER,IN UtilityLimit INTEGER

)...;

Input Parameters

Example

CALL TDWMSetLimits(1, 'throttle1', 'A', NULL, 10, NULL);

Input Parameters Description

RuleSetId The rule set in which the rule is found.

RuleName The name of the rule specified.

TDWMLock The type of request performed on the TDWMLock table. The following values apply:

• W = Wait for the TDMWLock

• A = Abort if the TDWMLock table is locked

• S = Perform the update without locking the TDWMLock table

Note: Teradata DWM places an exclusive lock on the TDWMLock table at startup.

SessionLimit The maximum number of concurrent sessions. A NULL value indicates that the field is not changed.

QueryLimit The maximum number of concurrent queries. A NULL value indicates that the field is not changed.

UtilityLimit The maximum number of concurrent utilities. A NULL value indicates that the field is not changed.

Page 382: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMSummary

382 Workload Management API: PM/API and Open API

TDWMSummary

PurposeReturns the summary data fields.

Definition

REPLACE FUNCTION TDWMSummary() RETURNS TABLE(WDId INTEGER, Arrivals INTEGER, Completions INTEGER, MinRespTime FLOAT, MaxRespTime FLOAT, AvgRespTime FLOAT, MinCPUTime FLOAT, MaxCPUTime FLOAT, AvgRespTime FLOAT, MinCPUTime FLOAT, MaxCPUTime FLOAT, AvgCPUTime FLOAT, DelayedCnt INTEGER, AvgDelayTime FLOAT, DelayedCnt INTEGER, AvgDelayeTime FLOAT, ExceptionCnt INTEGER, MetSLGCnt INTEGER, ActiveQueryCnt INTEGER, ActiveDelayedCnt INTEGER, ErrorCnt INTEGER, AbortCnt INTEGER)...;

Usage Notes

The TDWMSummary function provides similar functionality to a TDWM Summary request. For more information about this interface, see “TDWM SUMMARY” on page 341.

TDWMSummary returns information for all queries completed in the summary interval for the workload definition.

Page 383: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMSummary

Workload Management API: PM/API and Open API 383

Result Rows

Example

SELECT WDId, Arrivals, MetSLGCnt, ActiveReqs FROM TABLE (TDWMSummary()) AS t2 WHERE arrivals <>0;

*** Query completed. 13 rows found. 4 columns returned. *** Total elapsed time was 1 second.

WDId Arrivals MetSLGCnt ActiveReqs----------- ----------- ----------- ----------- 213 8 8 0 217 1 0 0 221 3 3 0 240 109 91 1

Column Name Description

WDId The workload definition ID to which the request should be assigned.

Arrivals The number of queries classified and started under the workload ID in the last period.

Completions Number of queries assigned to the WD that completed in the last period.

MinRespTime The minimum response time of any query.

MaxRespTime The maximum response time of any query.

AvgRespTime The average response time for this workload based on the total response time of all completions divided by number of completions.

MinCPUTime The minimum CPU time used by any query.

MaxCPUTime The maximum CPU time used by any query.

AvgCPUTime The average response time for this workload based on the total response time of all completions divided by the number of completions.

DelayedCnt The number of queries that have been delayed in this workload.

AvgDelayTime The average delay time of all the queries that have been delayed in this workload.

ExceptionCnt The number of queries with exceptions in this workload.

MetSLGCnt The number of queries that met SLG requirements.

ActiveQueryCnt The number of active queries in this workload.

ActiveQueryCnt The number of queries currently delayed in this workload.

ErrorCnt The number of queries with errors in this workload definition.

AbortCnt The number of queries that were aborted in this workload definition.

Page 384: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMSummaryRate

384 Workload Management API: PM/API and Open API

TDWMSummaryRate

PurposeReturns the sample rate.

Definition

REPLACE FUNCTION TDWMSummaryRate ()RETURNS SMALLINT...;

Usage Notes

Use the SetSessionRate function to set the sample rate for updating session-level statistics within memory.

The TDWMSummaryRate function provides similar functionality to a TDWM Summary request. For more information about this interface, see “TDWM SUMMARY” on page 341.

Return Value

This function returns the duration of the sample period in seconds. This value represents the collection rate.

Example

SELECT TDWMSummaryRate();

*** Query completed. One row found. One column returned. *** Total elapsed time was 3 seconds.

TDWMSummaryRate()----------------- 60

Page 385: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMThrottleStatistics

Workload Management API: PM/API and Open API 385

TDWMThrottleStatistics

PurposeReturns statistics for throttled database objects or throttled workload classes.

Definition

REPLACE FUNCTION TDWMThrottleStatistics (RequestType VARCHAR(1) CHARACTER SET LATIN

) RETURNS TABLE (ObjectType VARCHAR(17) CHARACTER SET LATIN, WDId INTEGER,

WDName VARCHAR(30) CHARACTER SET LATIN, ObjectName VARCHAR(30) CHARACTER SET LATIN,

Subname VARCHAR(30) CHARACTER SET LATIN, Active INTEGER, ThrottleLimit INTEGER, Delayed INTEGER,

)...;

Input Parameter

The RequestType parameter specifies the type of statistics returned for throttled database objects or throttled workload classes. The following values apply:

• Q = Query Statistics for throttled database objects.

• S = Session Statistics for throttled database objects.

• W = Workload Statistics for throttled workload classes.

Usage Notes

The TDWMThrottleStatistics function provides similar functionality to a TDWM STATISTICS request. For more information, see “TDWM STATISTICS” on page 333.

Page 386: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMThrottleStatistics

386 Workload Management API: PM/API and Open API

Result Rows

Column Name Description

ObjectType The type of object associated with this statistic. The following values apply:

• User

• Account

• Performance Group

• Account String

• Profile

• Client

• Network Address

• Application

• Database

• Table

• Macro

• Stored Procedure

• Workload

• Utility

WDId The ID of the Object Throttle Rule or Workload (Class) Definition (WD) associated with this statistic.

If RequestType is Q or S, then the ID of the Object Throttle rule is returned.

If RequestType is W, then the ID of the WD is returned.

WDName The name of the Object Throttle Rule or Workload (Class) Definition (WD) associated with this statistic.

If RequestType is Q or S, then the name of the Object Throttle Rule is returned.

If RequestType is W, then the name of the WD is returned.

ObjectName If RequestType is Q or S, then this is the name of the object based on its ObjectType. When ObjectType is Table, Macro, or SProc, this field is the qualifying database name for the Subname field.

If RequestType is W, this field is always empty.

Subname If RequestType is Q or S, then this is the name of the table, macro, or stored procedure; or object if ObjectType is Table, Macro, or SProc.

If RequestType is W, this field is always empty.

Active The number of requests currently active for this object. This is, the number of active queries or sessions depending on the information requested in the input record.

Page 387: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMThrottleStatistics

Workload Management API: PM/API and Open API 387

Example 1: Requesting Query Throttle Statistics

*** Query completed. 4 rows found. 8 columns returned. *** Total elapsed time was 1 second.

ObjectType WDId WDName ObjectName Subname Active ThrottleLimit Delayed---------- ---- ---------- ---------- ---------- ------ ------------- -------User 1 test2 LUMBER 2 2 1User 2 test4 LUMBER 1 1 0Table 3 table test LUMBER ORDERS 1 1 0Macro 4 macro test LUMBER VENDMACRO 0 1 1

Example 2: Requesting Session Throttle Statistics

*** Query completed. 2 rows found. 8 columns returned. *** Total elapsed time was 1 second.

ObjectType WDId WDName ObjectName Subname Active ThrottleLimit Delayed---------- ---- ---------- ---------- ---------- ------ ------------- -------User 1 test2 LUMBER 2 4 0User 2 test4 LUMBER 2 2 0

Example 3: Requesting Workload Throttle Statistics

*** Query completed. 2 rows found. 8 columns returned. *** Total elapsed time was 1 second.

ObjectType WDId WDName ObjectName Subname Active ThrottleLimit Delayed---------- ---- ---------- ---------- ---------- ------ ------------- -------Workload 0 -1 0 1Workload 2 WD-ConsoleR 0 -1 0Workload 3 WD-ConsoleH 0 -1 0Workload 4 WD-ConsoleM 0 -1 0Workload 5 WD-ConsoleL 0 -1 0Workload 1 WD-Default 0 -1 0Workload 6 test-wd 0 0 2

ThrottleLimit The current Teradata Dynamic Workload Management limit on the object.

This is the limit on the number of queries or session depending on the information requested in the input record.

A value of -1 indicates that no throttle limit is defined.

Note: Active and delayed sessions are not valid when the ThrottleLimit value is -1.

Delayed The number of requests on the delay queue at this time for this object.

Column Name Description

Page 388: Workload management api

Chapter 4: Teradata Dynamic Workload Management APIsTDWMThrottleStatistics

388 Workload Management API: PM/API and Open API

Page 389: Workload management api

Workload Management API: PM/API and Open API 389

CHAPTER 5 Query Band APIs

This chapter discusses how to retrieve a query band.

A query band can be retrieved through two types of APIs: a CLIv2 interface called MONITOR QUERYBAND and an SQL interface consisting of a MonitorQueryBand function, a GetQueryBand function, and a GetQueryBandSP external stored procedure.

To learn more about the different types of interfaces, see:

• “CLIv2 Interface” on page 390

• “SQL Interfaces” on page 395

Before using the query band APIs, you may want to familiarize yourself with the following topics:

• “What PM/API Is” on page 13

• “What the Open API Is” on page 14

• “Query Banding Features” on page 22

• “Query Band API Examples” on page 26

Page 390: Workload management api

Chapter 5: Query Band APIsCLIv2 Interface

390 Workload Management API: PM/API and Open API

CLIv2 Interface

This section describes the MONITOR QUERYBAND CLIv2 interface

MONITOR QUERYBAND is the only query band CLIv2 interface currently available. This request provides similar functionality to the MonitorQueryBand function. For information on the MONITOR QUERYBAND request, see the topic that follows.

Page 391: Workload management api

Chapter 5: Query Band APIsMONITOR QUERYBAND

Workload Management API: PM/API and Open API 391

MONITOR QUERYBAND

PurposeReturns the concatenated transaction and session query band for the specified session.

Input Data

The input data for MONITOR QUERYBAND is listed in the following table.

Usage Notes

If you encounter a problematic query that is using a large amount of system resources, use the associated query band to identify the source application issuing the request.

The MONITOR QUERYBAND request cannot be used on internal sessions or sessions that are logged onto the MONITOR partition. The query band is not stored for these types of sessions and is only stored for SQL partitions.

Element Data TypeLength (Bytes) Description

HostId SMALLINT 2 The logical ID of a host (or client) with sessions logged on. A host_id cannot exceed a value of 1023.

A value of zero identifies the system console ID of the host on which the sessions are running.

SessionNo INTEGER 4 The number of the session. session_no combined with host_id represents a unique session ID.

RunPEVprocNo SMALLINT 2 The PE vproc number where the session runs. This is typically obtained from the RunVprocNo data field of the MONITOR SESSION response (see “Group I Data Fields” on page 124). If this field is specified with a NULL value or zero, then all PEs will be searched for the session, causing significant overhead.

Page 392: Workload management api

Chapter 5: Query Band APIsMONITOR QUERYBAND

392 Workload Management API: PM/API and Open API

Parcels

The MONITOR QUERYBAND request is treated internally as a one statement request that generates one response. The statement response returned from Teradata Database contains the following sequence of parcel types:

The response to the statement results in a Record parcel that contains the concatenated transaction and session query band text as follows:

=T>transaction query band =S> session query band

Sample Input

The following example shows how the parcels for a MONITOR QUERYBAND request, built by CLIv2, appear when sent to the Teradata Database server.

Parcel Sequence

Parcel Flavor Length (Bytes) Comments and Key Parcel Body Fields

Success 8 18 to 273 Statement No = 1

ActivityCount = 1

ActivityType = 168 (PCLMONQUERYBANDSTMT)

DataInfo 71 6 to 32004 Optional; this parcel is present if request was IndicData parcel.

Record 10 • 5 to 32004 (record mode)

• 6 to 32004 (indicator mode)

Depending on request (Data or IndicData), data is in record or indicator mode. This record contains the query band text.

EndStatement 11 6 StatementNo = 2-byte integer

EndRequest 12 4 None

IF there… THEN the text will contain…

is only a transaction query band =T>transaction query band

is only a session query band =S>session query band

are no query bands NULL. The return string will be zero bytes or NULL in indicator mode.

Page 393: Workload management api

Chapter 5: Query Band APIsMONITOR QUERYBAND

Workload Management API: PM/API and Open API 393

Note: In this example, the size of the response buffer in the example is set at the maximum (32,731 bytes), although you can set it to any size.

Sample Output

The following example shows a concatenated query band string that is returned for the current transaction and session.

=T> job=x1; =S> org=Finance;report=Fin123;

Warning and Error Messages

The following table describes the error messages that may be returned by the MONITOR QUERYBAND request.

Flavor Length Body

Num Name Bytes Field Value

0001 Req 16 Request MONITOR QUERYBAND

0003 Data 12 host_id

session_no

RunPEVprocNo

1

1002

16383

0004 Resp 6 BufferSize 32731

Message Number Description

3116 Response buffer size is insufficient to hold one record.

Remedy: Increase the response buffer size to the size returned in the Info field of the ERROR parcel and submit a CONTINUE request containing a single RESP or KEEPRESP parcel that specifies the new response buffer size.

See the Teradata Call-Level Interface Version 2 Reference for Channel-Attached Systems or Teradata Call-Level Interface Version 2 Reference for Network-Attached Systems for instructions on how to change the response buffer size.

3256 No such Session is currently logged on.

The Session ID specified in the request is not logged on to the given PE.

Remedy: Correct the error and resubmit the request.

3523 Monitor Access Denied: User has no Monitor Privileges.

User does not have the necessary privileges for this request or the owner of the requested view or macro does not have the proper privileges to underlying tables.

Remedy: Obtain the necessary privileges.

3671 Invalid host ID specified.

Remedy: Correct the statement and resubmit the request.

Page 394: Workload management api

Chapter 5: Query Band APIsMONITOR QUERYBAND

394 Workload Management API: PM/API and Open API

For a discussion of common warning messages that may appear in response to MONITOR QUERYBAND and other requests, see “Common Warning and Error Messages” on page 50.

For more detailed information on messages, see Messages.

Related Topics

For information on setting the query band for a session or transaction, see SET QUERY_BAND in SQL Data Definition Language.

Page 395: Workload management api

Chapter 5: Query Band APIsSQL Interfaces

Workload Management API: PM/API and Open API 395

SQL Interfaces

This section describes the SQL interfaces for retrieving a query band and parsing the query band string for name and value pairs. The SQL interfaces consist of UDFs and external stored procedures that you can invoke from any application.

Query band external stored procedures run on the PE and can retrieve query bands directly from memory. Query band functions run on the AMPs and require message passing to retrieve the query band. The external stored procedures provide better performance than query band functions.

Page 396: Workload management api

Chapter 5: Query Band APIsGetQueryBand

396 Workload Management API: PM/API and Open API

GetQueryBand

PurposeReturns the concatenated query band string for the current transaction and session.

Definition

REPLACE FUNCTION GetQueryBand()RETURNS VARCHAR (4106),...;

Usage Notes

The GetQueryBand function can be used in a SELECT statement and can be an input parameter for a table function.

This function is created in the SYSLIB database by the DEM DIP script. EXECUTE privileges are granted to PUBLIC by default. For more information, see “Requirements for Using the API” on page 31.

Return Value

The GetQueryBand function returns the concatenated transaction and session queryband.

Example

SEL GetQueryBand();

*** Query completed. One row found. One column returned. *** Total elapsed time was 1 second.

GetQueryBand()-------------------------------------------------------------------=S> a=1;b=2;c=3;d=4;

Related Topics

For information on setting the query band for a session or transaction, see SET QUERY_BAND in SQL Data Definition Language.

Page 397: Workload management api

Chapter 5: Query Band APIsGetQueryBandPairs

Workload Management API: PM/API and Open API 397

GetQueryBandPairs

PurposeReturns the name and value pairs in the query band.

Definition

REPLACE FUNCTION GetQueryBandPairs(SearchType SMALLINT) RETURNS TABLE (QBName VARCHAR(129),

QBValue VARCHAR(257) )

...;

REPLACE FUNCTION GetQueryBandPairs (QueryBandIn VARCHAR(4106), SearchType SMALLINT

) RETURNS TABLE (QBName VARCHAR(129), QBValue VARCHAR(257)

)...;

Input Parameters

Result Rows

Input Parameter Description

QueryBandIn A query band string.

SearchType 0 = Return the name-value pairs in both transaction and session query bands are returned. If the same name occurs in both the transaction and the session query bands, the value for the transaction query band is returned.

1 = Return only the name-value pairs in the transaction query band.

2 = Return only the name-value pairs in the session query band.

Column Name Description

QBName The name of the query band.

QBValue The value of the query band.

Page 398: Workload management api

Chapter 5: Query Band APIsGetQueryBandPairs

398 Workload Management API: PM/API and Open API

Usage Notes

GetQueryBandPairs are two overloaded table functions. One requires the query band string to be passed in; the other uses internal calls to retrieve the query band.

Both functions are created in the SYSLIB database by the DEM DIP script. EXECUTE privileges are granted to PUBLIC by default. For more information, see “Requirements for Using the API” on page 31.

Example 1

The following example shows how to call the GetQueryBandPairs function.

SELECT * FROM TABLE(GetQueryBandPairs(0)) AS t1;

*** Query completed. 3 rows found. 2 columns returned. *** Total elapsed time was 1 second.

QBName QBValue-------------- ---------------ORG FINANCEJOB ENDOFMONTHJOBID 193858

Example 2

The following example shows how to call the GetQueryBandPairs function using the MonitorQueryBand function as input.

SELECT * FROM TABLE(GetQueryBandPairs(MonitorQueryBand(1, 103, 16383), 0)) AS t1;

*** Query completed. 3 rows found. 2 columns returned. *** Total elapsed time was 1 second.

QBName QBValue-------------- ---------------ORG FINANCEJOB ENDOFMONTHJOBID 193858

Page 399: Workload management api

Chapter 5: Query Band APIsGetQueryBandSP

Workload Management API: PM/API and Open API 399

GetQueryBandSP

PurposeReturns the concatenated query band for the current transaction and session.

Definition

REPLACE PROCEDURE GetQueryBandSP(OUT queryband VARCHAR(4106))

...;

Usage Notes

The GetQueryBandSP procedure retrieves the query band directly from memory, so it performs better than the GetQueryBand UDF.

This procedure is created in the SYSLIB database by the DEM DIP script. EXECUTE privileges are granted to PUBLIC by default. For more information, see “Requirements for Using the API” on page 31.

Output Parameter

The query band output parameter contains the concatenated transaction and session query bands.

Example

CALL GetQueryBandSP(qb);

*** Procedure has been executed. *** Total elapsed time was 1 second.

queryband-----------------------------------------------------------------=T> aa=123;bb=yxs;cc=mmmmm; =S> a=1;b=2;c=3;d=4;

Related Topics

For information on setting the query band for a session or transaction, see SET QUERY_BAND in SQL Data Definition Language.

Page 400: Workload management api

Chapter 5: Query Band APIsGetQueryBandValue

400 Workload Management API: PM/API and Open API

GetQueryBandValue

PurposeReturns the value of the specified name in the current query band.

Definition

REPLACE FUNCTION GetQueryBandValue( QueryBandIn VARCHAR(4105), SearchType SMALLINT, QBName VARCHAR(128))...;REPLACE FUNCTION GetQueryBandValue( SearchType SMALLINT, QBName VARCHAR(128))...;

Input Parameters

Output Parameter

Both GetQueryBandValue functions return the value for the specified name in the query band. If no match is found for QBName, an empty string is returned.

Input Parameter Description

QueryBandIn A query band string.

SearchType 0 = Return the value of the first name-value pair where name is specified by the QBName input argument. If the query band contains name-value pairs for the transaction and session, the function searches the transaction name-value pairs first.

1= Search the transaction name-value pairs in the query band and return the value that corresponds to the name specified by the QBName input argument.

2 = Search the session name-value pairs in the query band and return the value that corresponds to the name specified by the QBName input argument.

QBName The name in the query band pair to search for.

Page 401: Workload management api

Chapter 5: Query Band APIsGetQueryBandValue

Workload Management API: PM/API and Open API 401

Usage Notes

The GetQueryBandValue functions are two overloaded functions. One requires the query band string to be passed in; the other uses internal calls to retrieve the query band.

Both functions are created in the SYSLIB database by the DEM DIP script. EXECUTE privileges are granted to PUBLIC by default. For more information, see “Requirements for Using the API” on page 31.

Example 1

SEL GetQueryBandValue(0,'aa');

*** Query completed. One row found. One column returned. *** Total elapsed time was 1 second.

GetQueryBandValue(0,'aa')--------------------------------------111

Example 2

SEL t1.queryid, t1.queryband(FORMAT 'X(20)') FROM dbc.dbqlogtbl t1 WHERE GetQueryBandValue(t1.queryband, 0, 'aa') = '123';

*** Query completed. 5 rows found. 2 columns returned. *** Total elapsed time was 1 second.

QueryID QueryBand-------------- -------------------- 32,703 =T> aa=123;bb=yxs;cc 32,706 =T> aa=123;bb=yxs;cc 32,707 =T> aa=123;bb=yxs;cc 32,709 =T> aa=123;bb=yxs;cc 32,710 =T> aa=123;bb=yxs;cc

Page 402: Workload management api

Chapter 5: Query Band APIsGetQueryBandValueSP

402 Workload Management API: PM/API and Open API

GetQueryBandValueSP

Purpose

Returns the value of the specified name in the current query band.

Definition

REPLACE PROCEDURE GetQueryBandValueSP(IN SearchType SMALLINT,IN QBName VARCHAR(129) ,OUT QBValue VARCHAR(256) )

...;

Input Parameters

Output Parameter

The QBValue output parameter contains the value of the specified name in the query band. If no match is found for QBName, the QBValue output parameter is an empty string.

Example

CALL GetQueryBandValueSP(1,'aa',qbval);

*** Procedure has been executed. *** Total elapsed time was 1 second.

QBValue-------------------------------------111

Input Parameter Description

SearchType 0 = Return the value of the first name-value pair where name is specified by the QBName input argument. If the query band contains name-value pairs for the transaction and session, the function searches the transaction name-value pairs first.

1= Search the transaction name-value pairs in the query band and return the value that corresponds to the name specified by the QBName input argument.

2 = Search the session name-value pairs in the query band and return the value that corresponds to the name specified by the QBName input argument.

QBName The name in the query band pair to search for.

Page 403: Workload management api

Chapter 5: Query Band APIsMonitorQueryBand

Workload Management API: PM/API and Open API 403

MonitorQueryBand

PurposeReturns the concatenated query band for the specified session.

Definition

REPLACE FUNCTION MonitorQueryBand (HostId SMALLINT, SessionNo INTEGER, RunPEVprocNo SMALLINT) RETURNS VARCHAR(4106)

)...;

Input Parameters

Usage Notes

The privileges to use this function are not granted by default. The database administrator must explicitly grant the privilege to users that require it.

The MonitorQueryBand function provides similar functionality to a MONITOR QUERYBAND request. For more information about this interface, see “MONITOR QUERYBAND” on page 391.

Return Value

If successful, the function returns the concatenated query band string as VARCHAR. If there is no concatenated query band, the function returns an empty string.

Example

SELECT MonitorQueryBand (1, 1003, 16382);

Input Parameter Description

HostId The logical ID of a host.

SessionNo The number of the session to get the query band for.

RunPEVprocNo The PE vproc number where the session runs. This is obtained from the RunVprocNo field of a MONITOR SESSION response (see “Group I Data Fields” on page 124).

Page 404: Workload management api

Chapter 5: Query Band APIsMonitorQueryBand

404 Workload Management API: PM/API and Open API

* * * Query completed. One row found. One column returned.* * * Total elapsed time was 5 seconds.

MonitorQueryBand (1, 1003, 16382)---------------------------------=T= job=x1; =S= org=Finance; report=Fin123;

Related Topics

For information on setting the query band for a session or transaction, see SET QUERY_BAND in SQL Data Definition Language.

Page 405: Workload management api

Workload Management API: PM/API and Open API 405

APPENDIX A Sample PM/API Application

This appendix provides a sample PM/API application based on a sample CLI program. A PM/API application is no more than a CLI application. The only difference between a regular SQL CLI application and a PM/API application is:

• PM/API logs on to a Monitor partition

• SQL logs onto DBC/SQL partition

Sample Application

The following is sample of a CLI program.

/**********************************************************************//* This is a sample PM/API application. *//* 1) Prompts for a logon string *//* 2) Connects to a Teradata RDBMS and establishes a MONITOR session *//* 3) Prompts for input parameter for MONITOR SESSION; PM/API command *//* 4) Submits MONITOR SESSION; *//* 5) Retrieves the response, formats and prints the response parcels *//* 6) Above 3 - 5 are repeated until Q is entered in #3. *//* 7) Disconnets. *//**********************************************************************/

#include <stdio.h> #include <string.h>#include <stdlib.h>

#include "samplepmpc.h"

// Global variablesstruct DBCAREA dbc; /* see dbcarea.h for definition of structure */

char cnta[4];

int IndicatorMode;

unsigned short TargetVersion = 6;char RespMode = 'R';

static int IndicFieldCount = 0;static char CurrRequestText[32];

#define MON_SESS_REQ 1

// List of field names for Monitor Session Record 2char *MonSesRec2fieldnamelist[]= { "HostId", "LogonProcId",

Page 406: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

406 Workload Management API: PM/API and Open API

"RunProcId", "SessionNo", "UserName", "UserAccount", "UserId", "LSN", "LogonTime", "LogonDate", "PartName", "Priority", "IFPState", "IFPCPUSec", "XactCount", "ReqCount", "ReqCacheHits", "AMPState", "AMPCPUSec", "AMPIO", "DeltaAMPSpool", "Blk1HostId", "Blk1SessNo", "Blk1UserId", "Blk1LMode", "Blk1OType", "Blk1ObjDBId", "Blk1ObjTId", "Blk1Status", "Blk2HostId", "Blk2SessNo", "Blk2UserId", "Blk2LMode", "Blk2OType", "Blk2ObjDBId", "Blk2ObjTId", "Blk2Status", "Blk3HostId", "Blk3SessNo", "Blk3UserId", "Blk3LMode", "Blk3OType", "Blk3ObjDBId", "Blk3ObjTId", "Blk3Status", "MoreBlockers", "LogonSource", "TempSpaceUsage", "HotAmp1CPU", "HotAmp2CPU", "HotAmp3CPU", "HotAmp1IO ", "HotAmp2IO ", "HotAmp3IO ", "HotAmp1CPUId", "HotAmp2CPUId", "HotAmp3CPUId", "HotAmp1IOId", "HotAmp2IOId", "HotAmp3IOId", "LowAmp1CPU",

Page 407: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

Workload Management API: PM/API and Open API 407

"LowAmp2CPU", "LowAmp3CPU", "LowAmp1IO ", "LowAmp2IO ", "LowAmp3IO ", "LowAmp1CPUId", "LowAmp2CPUId", "LowAmp3CPUId", "LowAmp1IOId", "LowAmp2IOId", "LowAmp3IOId", "AmpCount", "AvgAmpCPUSec", "AvgAmpIOCnt", "ReqStartTime", "ReqStartDate", "ReqCPU", "ReqIO", "RequestNo", "WlcId", "DontReclassifyFlag",};

/* This routine displays the presence bits along with the field name. */static void PrintPresenceBits(char *ptr,int fieldcount,char **fieldnamelist){ char *tempptr=ptr; char temp = *ptr; int i=0; int bitOn; char buf[200]; int endlist=0;

printf("\nPresence Bits:\n"); while (i < fieldcount) { bitOn = (temp & (char)0x80);

if (!endlist) { if (!fieldnamelist || (fieldnamelist && strlen(fieldnamelist[i]) == 0)) endlist = 1; };

if (endlist) { sprintf(buf,"Field%03d",i+1); } else strcpy(buf,fieldnamelist[i]);

if (bitOn) printf("[%02d] %30s \tis \tNULL\n",i,buf); else printf("[%02d] %30s \tis \tNOT NULL\n",i,buf);

i++; if ((i % 8) == 0)

Page 408: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

408 Workload Management API: PM/API and Open API

{ tempptr++; temp = *tempptr; } else temp = temp << 1; } printf("\n");}

/***************************************************************//* WRITE_ERROR -- Prints error message that is located in *//* the response buffer--Error or Failure Parcel *//***************************************************************/static void Write_error(char *parcel){ int i; Error_Fail_t *Error_Fail; Error_Fail = ((struct ERROR_FAIL_Type *) (parcel)); printf("DBS Error code: %d : ",Error_Fail->Code); for(i=0;i < (int)Error_Fail->Length;i++) printf("%c",Error_Fail->Msg[i]); printf("\n");} /**end write_error**/

/* MONITOR SESSION formatting routines */ static void PrtSes1(char *dataptr){ short *SampleRate;

SampleRate = (short *) (dataptr); printf("Sample rate: %d seconds\n\n", *SampleRate);

}

static void PrtSes2(char *dataptr, int version){ MonSesRec2_t *MonSesRec2; MonSesRecV3_t *MonSesRecV3; MonSesRecV4_t *MonSesRecV4; MonSesRecV5_t *MonSesRecV5;

MonSesRec2 = (MonSesRec2_t *) (dataptr);

if (version >= MONVERSION3) { MonSesRecV3 = (MonSesRecV3_t *)(((char *) (&MonSesRec2->LogonSource)) + MonSesRec2->LogonSourceLen); }

if (version >=MONVERSION4) { MonSesRecV4 = (MonSesRecV4_t *) (MonSesRecV3 +1); }

if (version >=MONVERSION5) { MonSesRecV5 = (MonSesRecV5_t *) (MonSesRecV4 +1); }

Page 409: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

Workload Management API: PM/API and Open API 409

printf("HostId: %8d ", MonSesRec2->HostId); printf("SessionNo: %d\n", MonSesRec2->SessionNo); printf("LogonPENo: %5d ", MonSesRec2->LogonProcId); printf("RunVprocNo: %5d\n", MonSesRec2->RunProcId); printf("PartName: %.16s", MonSesRec2->PartName); printf("PEState: %.18s\n\n", MonSesRec2->PEState);

printf("LogonDate: %04d/%02d/%02d ", (int) MonSesRec2->LogonDate / 10000 + 1900, (int) MonSesRec2->LogonDate / 100 % 100, (int) MonSesRec2->LogonDate % 100); printf("LogonTime: %02d:%02d:%05.2f\n", (int) MonSesRec2->LogonTime / 10000, (int) MonSesRec2->LogonTime / 100 % 100, (int) MonSesRec2->LogonTime % 100 + MonSesRec2->LogonTime - (int) MonSesRec2->LogonTime); printf("UserID: %d ", MonSesRec2->UserID); printf("LSN: %d\n", MonSesRec2->LSN); printf("UserName: %.30s\n", MonSesRec2->UserName); printf("UserAccount: %.30s\n\n", MonSesRec2->UserAccount);

printf("PECPUSec: %10.2f ", MonSesRec2->PECPUSec); printf("XactCount: %13.2f\n", MonSesRec2->XactCount); printf("ReqCount: %10.1f ", MonSesRec2->ReqCount); printf("ReqCacheHits: %10.1f\n\n", MonSesRec2->ReqCacheHits);

printf("AMPState: %.18s\n", MonSesRec2->AMPState); printf("AMPCPUSec: %9.2f ", MonSesRec2->AMPCPUSec); printf("AMPIO: %7.2f\n", MonSesRec2->AMPIO); printf("Request_AMPSpool: %4.1f\n\n", MonSesRec2->Delta_AMPSpool);

printf("Blk_1_HostId: %6d ", MonSesRec2->Blk_1_HostId); printf("Blk_2_HostId: %6d ", MonSesRec2->Blk_2_HostId); printf("Blk_3_HostId: %6d\n", MonSesRec2->Blk_3_HostId);

printf("Blk_1_SessNo: %6d ", MonSesRec2->Blk_1_SessNo); printf("Blk_2_SessNo: %6d ", MonSesRec2->Blk_2_SessNo); printf("Blk_3_SessNo: %6d\n", MonSesRec2->Blk_3_SessNo);

printf("Blk_1_UserID: %6d ", MonSesRec2->Blk_1_UserID); printf("Blk_2_UserID: %6d ", MonSesRec2->Blk_2_UserID); printf("Blk_3_UserID: %6d\n", MonSesRec2->Blk_3_UserID);

printf("Blk_1_LMode: %c ", MonSesRec2->Blk_1_LMode); printf("Blk_2_LMode: %c ", MonSesRec2->Blk_2_LMode); printf("Blk_3_LMode: %c\n", MonSesRec2->Blk_3_LMode);

printf("Blk_1_OType: %c ", MonSesRec2->Blk_1_OType); printf("Blk_2_OType: %c ", MonSesRec2->Blk_2_OType); printf("Blk_3_OType: %c\n", MonSesRec2->Blk_3_OType);

printf("Blk_1_ObjDBId: %5d ", MonSesRec2->Blk_1_ObjDBId); printf("Blk_2_ObjDBId: %5d ", MonSesRec2->Blk_2_ObjDBId); printf("Blk_3_ObjDBId: %5d\n", MonSesRec2->Blk_3_ObjDBId);

printf("Blk_1_ObjTId: %6d ", MonSesRec2->Blk_1_ObjTId); printf("Blk_2_ObjTId: %6d ", MonSesRec2->Blk_2_ObjTId);

Page 410: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

410 Workload Management API: PM/API and Open API

printf("Blk_3_ObjTId: %6d\n", MonSesRec2->Blk_3_ObjTId); printf("Blk_1_Status: %c ", MonSesRec2->Blk_1_Status); printf("Blk_2_Status: %c ", MonSesRec2->Blk_2_Status); printf("Blk_3_Status: %c\n", MonSesRec2->Blk_3_Status); printf("MoreBlockers: %c\n\n", MonSesRec2->MoreBlockers); MonSesRec2->LogonSource[MonSesRec2->LogonSourceLen] = '\0'; printf("LogonSource: %.128s\n\n", MonSesRec2->LogonSource);

/* MonVerId 3 fields */ if (version < MONVERSION3) return;

printf("HotAmp1CPU: %9.2f ", MonSesRecV3->HotAmp1CPU); printf("HotAmp2CPU: %9.2f ", MonSesRecV3->HotAmp2CPU); printf("HotAmp3CPU: %9.2f\n", MonSesRecV3->HotAmp3CPU);

printf("HotAmp1CPUId: %7d ", MonSesRecV3->HotAmp1CPUId); printf("HotAmp2CPUId: %7d ", MonSesRecV3->HotAmp2CPUId); printf("HotAmp3CPUId: %7d\n\n", MonSesRecV3->HotAmp3CPUId);

printf("HotAmp1IO: %10.2f ", MonSesRecV3->HotAmp1IO); printf("HotAmp2IO: %10.2f ", MonSesRecV3->HotAmp2IO); printf("HotAmp3IO: %10.2f\n", MonSesRecV3->HotAmp3IO);

printf("HotAmp1IOId: %8d ", MonSesRecV3->HotAmp1IOId); printf("HotAmp2IOId: %8d ", MonSesRecV3->HotAmp2IOId); printf("HotAmp3IOId: %8d\n\n", MonSesRecV3->HotAmp3IOId);

printf("LowAmp1CPU: %9.2f ", MonSesRecV3->LowAmp1CPU); printf("LowAmp2CPU: %9.2f ", MonSesRecV3->LowAmp2CPU); printf("LowAmp3CPU: %9.2f\n", MonSesRecV3->LowAmp3CPU);

printf("LowAmp1CPUId: %7d ", MonSesRecV3->LowAmp1CPUId); printf("LowAmp2CPUId: %7d ", MonSesRecV3->LowAmp2CPUId); printf("LowAmp3CPUId: %7d\n\n", MonSesRecV3->LowAmp3CPUId);

printf("LowAmp1IO: %10.2f ", MonSesRecV3->LowAmp1IO); printf("LowAmp2IO: %10.2f ", MonSesRecV3->LowAmp2IO); printf("LowAmp3IO: %10.2f\n", MonSesRecV3->LowAmp3IO);

printf("LowAmp1IOId: %8d ", MonSesRecV3->LowAmp1IOId); printf("LowAmp2IOId: %8d ", MonSesRecV3->LowAmp2IOId); printf("LowAmp3IOId: %8d\n\n", MonSesRecV3->LowAmp3IOId);

printf("AvgAmpCPUSec:%8.2f ", MonSesRecV3->AvgAmpCPUSec); printf("AvgAmpIOCnt: %8.2f\n", MonSesRecV3->AvgAmpIOCnt); printf("AmpCount: %11d\n\n", MonSesRecV3->AmpCount);

printf("TempSpaceUsg: %7.2f\n\n", MonSesRecV3->TempSpaceUsage);

if (version <MONVERSION4) return;

/* MonVerId 4 fields */ printf("ReqStartTime: %04d/%02d/%02d ", (int) MonSesRecV4->ReqStartDate / 10000 + 1900, (int) MonSesRecV4->ReqStartDate / 100 % 100,

Page 411: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

Workload Management API: PM/API and Open API 411

(int) MonSesRecV4->ReqStartDate % 100); printf("%02d:%02d:%05.2f", (int) MonSesRecV4->ReqStartTime / 10000, (int) MonSesRecV4->ReqStartTime / 100 % 100, (int) MonSesRecV4->ReqStartTime % 100 + MonSesRecV4->ReqStartTime - (int) MonSesRecV4->ReqStartTime);

printf(" ReqCPU: %10.2f", MonSesRecV4->ReqCPU); printf(" ReqIO: %10.2f\n", MonSesRecV4->ReqIO);

if (version <MONVERSION5) return;

/* MonVerId 5 fields */printf("ReqNo:%d WlcId: %d DontReclassifyFlag: %d\n",

MonSesRecV5->ReqNo, MonSesRecV5->WlcId,MonSesRecV5->DontReclassifyFlag);

}

static void CheckSuccess(int ActivityType, int ActivityCount, int StatementNo){ switch (ActivityType) { case PCLSTMTNULL: printf("Null statement successful. \n\n"); break;

} return;}

static void CheckData(int ActivtyType, int StatementNo){ DataInfo_t * DataInfo; int i;

DataInfo = (DataInfo_t *) (dbc.fet_data_ptr); printf("\nCheckData called for Indicator mode data info parcel.\n"); printf("Field Count: %d \n", DataInfo->field_count);

IndicFieldCount = DataInfo->field_count; if (DataInfo->field_count > MAXFIELDS) DataInfo->field_count = MAXFIELDS;

for (i = 0; i < DataInfo->field_count; i++) { printf("Field %d: Type = %d Size = %d\n", i + 1, DataInfo->FieldData[i].FType, DataInfo->FieldData[i].FSize); }

return;}

Page 412: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

412 Workload Management API: PM/API and Open API

static void CheckRecord(int ActivtyType, int StatementNo, int ActivityCount){ switch (ActivtyType) { case PCLMONSESS: if (StatementNo == 1) PrtSes1(dbc.fet_data_ptr); else if (StatementNo == 2) { int IndLen=0;

if (IndicatorMode) { switch (TargetVersion) { case MONVERSION3: case MONVERSION4: IndLen = 10; break; case MONVERSION5: case MONVERSION6: default: IndLen = 11; break; }

PrintPresenceBits(dbc.fet_data_ptr,IndicFieldCount,MonSesRec2fieldnamelist); dbc.fet_data_ptr = (char *)dbc.fet_data_ptr + IndLen; }

PrtSes2(dbc.fet_data_ptr,TargetVersion); printf("\n"); printf("----------------------------------------------------\n\n"); } break;

default: printf("\nFound a funny parcel number: %d\n",ActivtyType); break; }}

/***************************************************************//* SET_OPTIONS -- sets cli options (record,field,indicator *//* mode; etc..) *//* Sets size of buffers (request and response) *//***************************************************************/set_options(){ dbc.change_opts = 'Y'; dbc.resp_mode = 'R'; dbc.use_presence_bits = 'Y'; dbc.keep_resp = 'N'; dbc.wait_across_crash = 'N'; dbc.tell_about_crash = 'Y'; dbc.loc_mode = 'Y'; dbc.var_len_req = 'N';

Page 413: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

Workload Management API: PM/API and Open API 413

dbc.var_len_fetch = 'N'; dbc.save_resp_buf = 'N'; dbc.two_resp_bufs = 'N'; dbc.ret_time = 'N'; dbc.parcel_mode = 'Y'; dbc.wait_for_resp = 'Y'; dbc.req_proc_opt = 'E';

dbc.req_buf_len = 256; dbc.resp_buf_len = 32000;

return(0);} /**end set_options**/

/***************************************************************//* EXITOUT -- If connected logs off session. Cleans up *//* any used memory. *//***************************************************************/void exitout(int status){ Int32 result;

if (status == CONNECTED) { printf ("Logging off.\n"); dbc.func = DBFDSC; DBCHCL (&result,cnta,&dbc); if (result != EM_OK) printf("disconnect failed -- %s\n", dbc.msg_text); }

DBCHCLN(&result,cnta); if (result != EM_OK) printf("cleanup failed -- %s\n", dbc.msg_text);

exit(0);} /**end exitout**/

/***************************************************************//* INITIALIZE_DBCAREA -- Sets default options (clispb.dat) in *//* dbcarea by calling DBCHINI() *//***************************************************************/initialize_dbcarea(){ Int32 result;

dbc.total_len = sizeof(struct DBCAREA); DBCHINI(&result,cnta,&dbc); if (result != EM_OK) { /* if we can't initialize, we can't go on, so exit */ printf("init failed -- %s\n", dbc.msg_text); exitout(NOT_CONNECTED); } return(0);} /**end initialize_dbcarea**/

/***************************************************************/

Page 414: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

414 Workload Management API: PM/API and Open API

/* LOGON_TO_DBC -- Connects session and logs on to DBC *//* Fetches result of connection to check if *//* successful *//***************************************************************/logon_to_dbc(char * logonstr){ struct CliCONNECTType connectstr; Int32 result, i; char TempString[30];

for (i = 0; i < 30; i++) TempString[i] = ' ';

for (i = 0; i < 30; i++) { if (logonstr[i] == '/') { TempString[i] = '\0'; break; } TempString[i] = logonstr[i]; } printf("Logging on to %s ...\n", TempString);

dbc.logon_ptr = logonstr; dbc.logon_len = strlen(logonstr); dbc.func = DBFCON; dbc.run_ptr = (char *) &connectstr; strncpy(connectstr.PartitionName, "MONITOR ", 16); connectstr.Function = 0; dbc.run_len = sizeof(struct CliCONNECTType);

DBCHCL(&result,cnta,&dbc); if (result != EM_OK) /*if connect fails exit*/ { printf("connect failed -- %s\n",dbc.msg_text); exitout(NOT_CONNECTED); }

printf("Logon successful.\n"); return(0);} /**end logon_to_dbc**/

/***************************************************************//* CLOSE_REQUEST -- Terminates and cleans up specified request *//***************************************************************/close_request(Int32 req_id, Int32 sess_id){ Int32 result;

dbc.i_sess_id = sess_id; dbc.i_req_id = req_id; dbc.func=DBFERQ;

DBCHCL(&result,cnta,&dbc);

if (result !=EM_OK) {

Page 415: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

Workload Management API: PM/API and Open API 415

printf("end request failed -- %s\n", dbc.msg_text); exitout(CONNECTED); } return(0);} /**end close_request**/

/***************************************************************//* OPEN_REQUEST -- Sends request to DBC *//***************************************************************/open_request (int InReqType, void *UsingPtr){ Int32 result; char CurrRequestText[32]; /* set up for a new request */

dbc.func = DBFIRQ; dbc.using_data_ptr = (char *) UsingPtr; switch (InReqType) { case MON_SESS_REQ: strcpy(CurrRequestText,"MONITOR SESSION;"); dbc.using_data_len = sizeof(monsess_t); break; default: printf("Internal error\n"); exitout(CONNECTED); }

dbc.req_ptr = &CurrRequestText[0]; dbc.req_len = strlen (CurrRequestText);

printf ("\nSubmitting request %s ...\n", dbc.req_ptr); /* Submit request */ DBCHCL (&result,cnta,&dbc); if (result != EM_OK) { printf ("result = %d \n", result); printf ("initiate request failed -- %s \n", dbc.msg_text); exitout(CONNECTED); }

return(EM_OK);} /**end open_request**/

int fetch_request(Int32 request, Int32 session){ int status; int StatementNo = 0; int ActivityType = 0; int ActivityCount = 0; Int32 result; int ReturnCode;

Page 416: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

416 Workload Management API: PM/API and Open API

dbc.i_sess_id = session; dbc.i_req_id = request; dbc.func = DBFFET; status = OK; ReturnCode = OK;

/* fetch one parcel at a time until all parcels are used up */ /* or an error occurs */

while (status == OK) { DBCHCL(&result,cnta,&dbc); if (result == REQEXHAUST) status = STOP; else if (result != EM_OK) status = NOT_OK; else { switch ((Int16) (dbc.fet_parcel_flavor)) { case PCLSUCCESS : /*Success Parcel */ { struct PclSUCCESSType succ; memcpy(&succ,dbc.fet_data_ptr-4,4); memcpy(&succ,dbc.fet_data_ptr-4,succ.Length+4); StatementNo = succ.StatementNo; ActivityCount = *(int *)(&succ.ActivityCount[0]); ActivityType = succ.ActivityType; if ( succ.WarningLength > 0 ) printf("%s \n", succ.WarningMsg);

CheckSuccess(ActivityType, ActivityCount, StatementNo); } break;

case PclDATAINFO : CheckData(ActivityType, StatementNo); break; case PclRECORD : /*Returned data */ CheckRecord(ActivityType, StatementNo, ActivityCount); break; case PclFAILURE : /*Failure parcel*/ case PclERROR : /*Error parcel */ status = STOP; Write_error(dbc.fet_data_ptr); ReturnCode = PclERROR; break; } /*switch*/ } } /*while*/

if (status == NOT_OK) { printf("fetch failed -- %s \n", dbc.msg_text); exitout(CONNECTED); } /*if*/

return(ReturnCode);} /**end fetch_request**/

Page 417: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

Workload Management API: PM/API and Open API 417

static Boolean MonSession(){ monsess_t MonSess; int i; char InString[MAXNAME];

/* Initializations */ MonSess.monheader.version = TargetVersion; MonSess.monheader.indicbyte = '\0'; for (i = 0; i < MAXNAME; i++) monsess.user[i] = ' ';

printf("Enter logical hostid (* for all hosts) or Q)uit: "); gets(InString); if (!strcmp(InString, "*") || (strlen(InString) == 0)) MonSess.hostid = (Int16) 65535; else if (!strcmp(InString, "Q") || !strcmp(InString, "q")) return (TRUE); else MonSess.hostid = atoi(InString);

printf("Enter user name (* for all users): "); gets(InString); if (!strcmp(InString, "*") || (strlen(InString) == 0)) { for (i = 0; i < MAXNAME; i++) { if (InString[i] == '\0') break; MonSess.user[i] = InString[i]; } }

printf("Enter session number (* for all sessions): "); gets(InString); if (!strcmp(InString, "*") || (strlen(InString) == 0)) MonSess.session = 0; else MonSess.session = atoi(InString);

if (RespMode == 'I' || RespMode == 'i') { dbc.resp_mode = 'I'; IndicatorMode = TRUE; } else { dbc.resp_mode = 'R'; IndicatorMode = FALSE; }

open_request( MON_SESS_REQ,&MonSess); fetch_request(dbc.o_req_id, dbc.o_sess_id); close_request(dbc.o_req_id, dbc.o_sess_id);

return (FALSE);

Page 418: Workload management api

Appendix A: Sample PM/API ApplicationSample Application

418 Workload Management API: PM/API and Open API

}

main (int argc, char **argv){ char LogonString[MAXLOGONSIZE]; Boolean stop = FALSE;

initialize_dbcarea(); set_options(); //6: Teradata 12.x; 5: Teradata 6.x 4: Teradata 5.x TargetVersion = 6;

// 'R' no presence bits returned; 'I' presence bits returned RespMode = 'I'; IndicatorMode = TRUE;

printf ("TargetVersion(argv1) = %d, RespMode(argv2) = %c \n\n", TargetVersion, RespMode);

/* Establish session */ printf ("Enter logon string (tdpid/user,password): "); gets (LogonString); if (strlen(LogonString) == 0) { printf ("NULL logon string not accepted.\n"); return (1); } logon_to_dbc(LogonString); if (fetch_request(dbc.o_req_id,dbc.o_sess_id) != OK) exitout(NOT_CONNECTED); close_request(dbc.o_req_id,dbc.o_sess_id);

while (stop == FALSE) stop = MonSession();

/* Logoff and cleanup */ exitout(CONNECTED); return 0;} /**end main**/

Page 419: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

Workload Management API: PM/API and Open API 419

Header File for Sample PMPC Application

This section defines the contents for all parcel flavors. Each parcel is defined in the Notes section under the definition of each parcel.

#ifndef PMPC_H#define PMPC_H

/* These are standard CLI include files */#include "coptypes.h"#include "coperr.h"#include "dbcarea.h"#include "parcel.h"

/*****************************************************************//* Purpose To define the data type for kinds of activities returned in the Ok and Success parcels. */

typedef unsigned short pclstmt_t;

/* Purpose To express the kind of activity within Ok and Success parcels. */

#define PCLSTMTNUL (0)#define PCLRETSTMT (1)#define PCLINSSTMT (2)#define PCLUPDSTMT (3) /* UPDATE */#define PCLUPDRETSTMT (4) /* UPDATE ... RETRIEVING */#define PCLDELSTMT (5)#define PCLCTSTMT (6)#define PCLMODTABSTMT (7)#define PCLCVSTMT (8)#define PCLCMSTMT (9)#define PCLDROPTABSTMT (10)#define PCLDROPVIEWSTMT (11)#define PCLDROPMACSTMT (12)#define PCLDROPINDSTMT (13)#define PCLRENTABSTMTT (14)#define PCLRENVIEWSTMT (15)#define PCLRENMACSTMT (16)#define PCLCREINDSTMT (17)#define PCLCDSTMTT (18)#define PCLCREUSERSTMT (19)#define PCLGRANTSTMT (20)#define PCLREVOKESTMT (21)#define PCLGIVESTMT (22)#define PCLDROPDBSTMT (23)#define PCLMODDBSTMT (24)#define PCLDATABASESTMT (25)#define PCLBTSTMT (26)#define PCLETSTMT (27)#define PCLABORTSTMT (28)#define PCLNULLSTMT (29)#define PCLEXECSTMT (30)#define PCLCMNTSETSTMT (31) /* COMMENT set statement */#define PCLCMNTGETSTMT (32) /* COMMENT returning statement */#define PCLECHOSTMT (33)

Page 420: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

420 Workload Management API: PM/API and Open API

#define PCLREPVIEWSTMT (34)#define PCLREPMACSTMT (35)#define PCLCHECKPTSTMT (36)#define PCLDELJRNLSTMT (37)#define PCLROLLBACKSTMT (38)#define PCLRELLOCKSTMT (39)#define PCLHUTCONFIGSTMT (40)#define PCLVCHECKPTSTMT (41)#define PCLDUMPJRNLSTMT (42)#define PCLDUMPDBSTMT (43)#define PCLRESTORESTMT (44)#define PCLROLLFORWSTMT (45)#define PCLDELDBSTMT (46)#define PCLCLEARDUMPST (47)#define PCLSAVEDUMPSTMT (48)#define PCLSHOWSTMT (49)#define PCLHELPSTMT (50)#define PCLBEGINLOADSTMT (51)#define PCLCHKPTLOADSTMT (52)#define PCLENDLOADSTMT (53)#define PCLLINSTMT (54)#define PCLGRANTLOGONSTMT (55)#define PCLREVOKELOGONSTMT (56)#define PCLBEGACCLOGSTMT (57)#define PCLENDACCLOGSTMT (58)#define PCLCOLLSTATSTMT (59)#define PCLDROPSTATSTMT (60)#define PCLSESSETSTMT (61)#define PCLBEGEDITSTMT (62)#define PCLEDITSTMT (63)#define PCLEXECEDITSTM (64)#define PCLENDEDITSTMT (65)#define PCLRELEDITSTMT (66)#define PCLEDITDELSTMT (67)#define PCLEDITINSSTMT (68)#define PCLEDITUPDSTMT (69)#define PCLBEGDELMLSTMT (70)#define PCLDATASTATUS (71)#define PCLBEGEXPORTSTMT (74)#define PCLENDEXPORTSTMT (75)#define PCL2PCVOTEREQ (76) /* 2PC vote request. */#define PCL2PCVOTETERM (77) /* 2PC vote and terminate. */#define PCL2PCCMMT (78) /* 2PC commit request. */#define PCL2PCABRT (79) /* 2PC abort request. */#define PCL2PCFORGET (80) /* Vote request yes/done */#define PCLSETSESSR (83) /* Set Session Rate */#define PCLMONSESS (84) /* Monitor Session */#define PCLIDENTIFY (85) /* Identify */#define PCLABTSESS (86) /* Abort Session */#define PCLSETRESSR (87) /* Set Resource Rate */#define PCLREVALIDATERISTMT (89) #define PCLCOMMITSTMT (90) #define PCLMONVCONFIG (91) /* Monitor Virtual Config */#define PCLMONPCONFIG (92) /* Monitor Physical Config */#define PCLMONVSUMMARY (93) /* Monitor Virtual Summary */#define PCLMONPSUMMARY (94) /* Monitor Physical Summary */#define PCLMONVRES (95) /* Monitor Virtual Resource */#define PCLMONPRES (96) /* Monitor Physical Resource */#define PCLCTRIGSTMT (97) /* Create Trigger Statement */

Page 421: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

Workload Management API: PM/API and Open API 421

#define PCLDTRIGSTMT (98) /* Drop Trigger Statement */#define PCLRENTRIGSTMT (99) /* Rename Trigger Statement */#define PCLREPTRIGSTMT (100) /* Rename Trigger Statement */#define PCLALTTRIGSTMT (101) /* Alter Trigger Statement */#define PCLRDLSTMT (102) /* Replication statement */ #define PCLDROPPROCSTMT (103) /* DROP PROCEDURE SQL */#define PCLCREATEPROCSTMT (104) /* CREATE PROCEDURE SQL */#define PCLCALLSTMT (105) /* CALL SQL */#define PCLRENPROCSTMT (106) /* RENAME PROCEDURE SQL */#define PCLREPPROCSTMT (107) /* REPLACE PROCEDURE SQL */#define PCLSETACCT (108) /* Set Session Account */#define PCLHULSTMT (109) /* Arcmain Lock Request */ #define PCLMONSQL (110) /* MONITOR SQL */ #define PCLMONVER (111) /* Monitor Version */ #define PCLBEGINDBQLSTMT (112) /* Begin DBQL */ #define PCLENDDBQLSTMT (113) /* End DBQL */ #define PCLCREROLESTMT (114) /* Create Role SQL */#define PCLDRPROLESTMT (115) /* Drop Role SQL */#define PCLGRANTROLESTMT (116) /* Grant Role SQL */#define PCLREVOKEROLESTMT (117) /* Revoke Role SQL */#define PCLCREPROFILESTMT (118) /* Create Profile SQL */#define PCLMODPROFILESTMT (119) /* Modify Profile SQL */#define PCLDRPPROFILESTMT (120) /* Drop Profile SQL */#define PCLSETROLESTMT (121) /* Set Role SQL */#define PCLCREUDFSTMT (122) /* Create UDF stmt */#define PCLRPLCUDFSTMT (123) /* Replace UDF stmt */#define PCLDROPUDFSTMT (124) /* Drop UDF stmt */#define PCLALTERUDFSTMT (125) /* Alter UDF stmt */#define PCLRENUDFSTMT (126) /* Rename UDF stmt */#define PCLMRGMIXEDSTMT (127) /* Mixture of upd & ins */ #define PCLMRGUPDSTMT (128) /* Upds and no ins */ #define PCLMRGINSSTMT (129) /* Ins and no upds */ #define PCLALTERPROCSTMT (130) /* ALTER PROCEDURE SQL */#define PCLTWMSTATSSTMT (132) /* TDQM Statistics */#define PCLTWMPERFGROUPSSTMT (133) /* TDQM get Perf Groups */#define PCLCREUDTSTMT (134) /* Create UDT stmt */#define PCLDROPUDTSTMT (135) /* Drop UDT stmt */#define PCLALTERUDTSTMT (136) /* Alter UDT stmt */#define PCLRPLCUDTSTMT (137) /* Replace UDT stmt */#define PCLCREUDMSTMT (138) /* Create UDM stmt */#define PCLALTERUDMSTMT (139) /* Alter UDM stmt */#define PCLRPLCUDMSTMT (140) /* Replace UDM stmt */#define PCLCRECASTSTMT (141) /* Create Cast stmt */#define PCLRPLCCASTSTMT (142) /* Replace Cast stmt */#define PCLDROPCASTSTMT (143) /* Drop Cast stmt */#define PCLCREORDSTMT (144) /* Create Ordering stmt */#define PCLRPLCORDSTMT (145) /* Replace Ordering stmt */#define PCLDROPORDSTMT (146) /* Drop Ordering stmt */#define PCLCREXFORMSTMT (147) /* Create Transform stmt */ #define PCLRPLCXFORMSTMT (148) /* Replace Transform stmt */#define PCLDROPXFORMSTMT (149) /* Drop Transform stmt */#define PCLCREAUTHSTMT (150) /* Create Auth stmt */#define PCLDRPAUTHSTMT (151) /* Drop Auth Stmt */#define PCLCREREPGRPSTMT (152) /* Create Replication Group */#define PCLALTREPGRPSTMT (153) /* Alter Replication Group */#define PCLDRPREPGRPSTMT (154) /* Drop Replication Group */#define PCLTWMDELRQSTCHGSTM (155) /* TDQM Delay Request Change */#define PCLTWMSUMMARYSTMT (156) /* TDQM get Summary */

Page 422: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

422 Workload Management API: PM/API and Open API

#define PCLTWMDYNBUILDSTMT (160) /* TDWM Dynamic Build */#define PCLTWMLISTWDSTMT (161) /* TDWM LIST WD */ #define PCLSETSESISOLVLSTMT (162) /* Set Session Isolation Level */#define PCLINITIDXANALYSIS (163) /* Initiate Index Analysis */#define PCLRPLCAUTHSTMT (164) /* Replace Auth stmt */#define PCLSETQBANDSTMT (165) /* Set QUERY_BAND stmt */#define PCLLOGARCONSTMT (166) /* LOGGING ONLINE ARCHIVE ON */#define PCLLOGARCOFFSTMT (167) /* LOGGING ONLINE ARCHIVE OFF */#define PCLMONQUERYBANDSTMT (168) /* MONITOR QUERYBAND */#define PCLLOGARCONSTMT (166) /* LOGGING ONLINE ARCHIVE ON */#define PCLLOGARCOFFSTMT (167) /* LOGGING ONLINE ARCHIVE OFF */#define PCLCRECORRSTMT (169)#define PCLREPCORRSTMT (170)#define PCLDRPCORRSTMT (171)#define PCLALTCORRSTMT (172)#define PCLUSEREVENTCONTROLSTMT (173) /* USER EVENT CONTROL */ #define PCLEVENTSTATUSSTMT (174) /* EVENT STATUS */ #define PCLMONAWTRES (175) /* MONITOR AWT RESOURCE */ #define PCLSPDYNRESULTSET (176) /* SP Dynamic Result Set */

#define MONVERSION3 3#define MONVERSION4 4

#define MONVERSION MONVERSION4

#define CONNECTED 0#define NOT_CONNECTED 1#define OK 0#define STOP 1#define NOT_OK -1#define MAXLOGONSIZE 100#define MAXCOMMANDSIZE 50#define MAXNAME 30#define SYSMAXRECSIZE 64000

#define ABORTSESTXT "ABORT SESSION;"#define SETSESSACCTTXT "SET SESSION ACCOUNT;"#define MONSESSTXT "MONITOR SESSION;"#define MONSQLTXT "MONITOR SQL;"#define TDWMPERFGROUPSTXT "TDWM PERFGROUPS;"#define TDWMSTATISTICSTXT "TDWM STATISTICS;"#define MONVERTXT "MONITOR VERSION;"#define SETSESSTXT "SET SESSION RATE;"#define SETRESTXT "SET RESOURCE RATE;"#define MONPHYSUMTXT "MONITOR PHYSICAL SUMMARY;"#define MONVIRSUMTXT "MONITOR VIRTUAL SUMMARY;"#define MONVIRRESTXT "MONITOR VIRTUAL RESOURCE;"#define MONPHYRESTXT "MONITOR PHYSICAL RESOURCE;"#define MONVIRCONTXT "MONITOR VIRTUAL CONFIG;"#define MONPHYCONTXT "MONITOR PHYSICAL CONFIG;"#define IDENTSESTXT "IDENTIFY SESSION;"#define IDENTDBTXT "IDENTIFY DATABASE;"#define IDENTTABLETXT "IDENTIFY TABLE;"#define IDENTUSERTXT "IDENTIFY USER;"#define HELPTXT "HELP;"

Page 423: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

Workload Management API: PM/API and Open API 423

typedef short SysInt32[2];typedef double fltreal64_t;typedef unsigned short tosprocnum_t;typedef short Integer;

typedef enum Request_t { ABORTSESSREQ, SETSESSACCTREQ, MONSESSREQ, MONSQLREQ, TDWMPERFGROUPSREQ, TDWMSTATISTICSREQ, MONVERREQ, MONPHYSUM, MONVIRSUM, MONVIRRES, MONPHYRES, MONVIRCON, MONPHYCON, SETSESSREQ, SETRESREQ, IDENTSESREQ, IDENTDBREQ, IDENTTABLEREQ, IDENTUSERREQ} Request_t;

#pragma pack(1)

/* Input parcel structure for PMPC requests */typedef struct{ char indicbyte; Int16 version;} monheader_t;typedef struct{ monheader_t monheader; Int16 hostid; Int32 session; char user[30]; char listsess; char logoffsess; char override;} abortsess_t;

typedef struct{ monheader_t monheader; Int16 hostid; Int32 session; char acct[30]; char entiresess;} setsessacct_t;

Page 424: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

424 Workload Management API: PM/API and Open API

typedef struct{ monheader_t monheader; Int16 hostid; Int32 session; char user[30];} monsess_t;

typedef struct{ monheader_t monheader; Int16 hostid; Int32 session;} monsql_t;

typedef struct{ monheader_t monheader; Int16 samplerate; char LocalChange; char VirtualChange;} setrate_t;

typedef struct{ Int16 hostid; Int32 sessionno;} identses_t;

typedef struct{ monheader_t monheader; union { Int32 objid; identses_t identses; } UU;} identify_t;

/* Output record parcel structures */typedef struct{ Int16 HostId; /* Logical Host Identifier */ char UserName[30]; /* User (database) Name of this session */ SysInt32 SessionNo; /* Session Number of session */ char AbortStatus; /* Status of aborted session */} MonAbtSes_t;

typedef struct {

Int16 HostId; /* Logical Host Identifier */Int16 LogonProcId; /* Processor number session logged on to */Int16 RunProcId; /* Procnum the session initiates requests to */Int32 SessionNo; /* Session Number of session */ char UserName[30]; /* User (database) Name of this session */char UserAccount[30]; /* Acct name that this User logged in with */Int32 UserID; /* User (database) Identifier for this session */Int32 LSN; /* Logon Sequence Number */double LogonTime; /* Logon Time for this session */

Page 425: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

Workload Management API: PM/API and Open API 425

Int32 LogonDate; /* Logon Date */char PartName[16]; /* Session Partition Name this session is associated with */char Priority[2]; /* DBC run priority (Low, Medium, High, Rush) */char PEState[18]; /* Current state of this session in the PE */double PECPUSec; /* Current elapsed cpu usage in PE for sess */double XactCount; /* Number of transactions processed by a DBC SQL session */double ReqCount; /* Number of requests processed by a session */double ReqCacheHits; /* Number of Request Cache uses inDBC/SQL sess */char AMPState[18]; /* Current state of associated session in AMP processors */double AMPCPUSec; /* Current elapsed cpu usage in AMP ( TOTAL ) */double AMPIO; /* Current Total Logical I/O count for associated session */double Delta_AMPSpool; /* Total Spool space change for the associated session */Int16 Blk_1_HostId; /* Logical HostId of a session causing block */Int32 Blk_1_SessNo; /* Session Number of a session causing block */Int32 Blk_1_UserID; /* User Identifier of a Host Utility Job causing block */char Blk_1_LMode; /* Mode (Severity) of lock involved in causing a block */char Blk_1_OType; /* Type (Database/Table/Row Hash) of object being locked */Int32 Blk_1_ObjDBId; /* DB Identifier of object being locked */Int32 Blk_1_ObjTId; /* TBID (If applicable) of object being locked */char Blk_1_Status;Int16 Blk_2_HostId;Int32 Blk_2_SessNo;Int32 Blk_2_UserID;char Blk_2_LMode;char Blk_2_OType;Int32 Blk_2_ObjDBId;Int32 Blk_2_ObjTId;char Blk_2_Status;Int16 Blk_3_HostId;Int32 Blk_3_SessNo;Int32 Blk_3_UserID;char Blk_3_LMode;char Blk_3_OType;Int32 Blk_3_ObjDBId;Int32 Blk_3_ObjTId;char Blk_3_Status;char MoreBlockers; /* Indicates there are more lock conflicts */Int16 LogonSourceLen; /* Logon source length (Variable Length) */char LogonSource[128];/* Logon source info (Variable Length) */

} MonSesRec2_t;

typedef struct {

double TempSpaceUsage; /* Temporary Space usage for the associated session */ fltreal64_t HotAmp1CPU;fltreal64_t HotAmp2CPU;fltreal64_t HotAmp3CPU;fltreal64_t HotAmp1IO;fltreal64_t HotAmp2IO;fltreal64_t HotAmp3IO;Word HotAmp1CPUId;Word HotAmp2CPUId; Word HotAmp3CPUId;Word HotAmp1IOId;Word HotAmp2IOId; Word HotAmp3IOId;fltreal64_t LowAmp1CPU;fltreal64_t LowAmp2CPU;fltreal64_t LowAmp3CPU;

Page 426: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

426 Workload Management API: PM/API and Open API

fltreal64_t LowAmp1IO;fltreal64_t LowAmp2IO;fltreal64_t LowAmp3IO;Word LowAmp1CPUId;Word LowAmp2CPUId; Word LowAmp3CPUId;Word LowAmp1IOId;Word LowAmp2IOId; Word LowAmp3IOId;Word AmpCount; fltreal64_t AvgAmpCPUSec;fltreal64_t AvgAmpIOCnt;

} MonSesRecV3_t;

typedef struct {

double ReqStartTime;Int32 ReqStartDate; fltreal64_t ReqCPU;fltreal64_t ReqIO;

} MonSesRecV4_t;

typedef struct

{ Int32 ReqNo; Int32 WlcId; Int16 DontReclassifyFlag;

} MonSesRecV5_t; typedef struct{ fltreal64_t AvgCPU; fltreal64_t AvgDisk; fltreal64_t AvgDiskIO; fltreal64_t HighCPUUse; tosprocnum_t HighCPUProcId; fltreal64_t LowCPUUse; tosprocnum_t LowCPUProcId; fltreal64_t HighDisk; tosprocnum_t HighDiskProcId; fltreal64_t LowDisk; tosprocnum_t LowDiskProcId; fltreal64_t HighDiskIO; tosprocnum_t HighDiskIOProcId; fltreal64_t LowDiskIO; tosprocnum_t LowDiskIOProcId; fltreal64_t NetUse; char NetAUp; char NetBUp; Integer ResLogging; Integer ResMonitor; char Release[29]; char Version[32];} MonPhySum_t;

typedef struct { fltreal64_t AMPAvgCPU;

Page 427: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

Workload Management API: PM/API and Open API 427

fltreal64_t AMPAvgDisk; fltreal64_t AMPAvgDiskIO; fltreal64_t HiCPUAMPUse; tosprocnum_t HiCPUAMPNo; tosprocnum_t HiCPUAMPProc; fltreal64_t LoCPUAMPUse; tosprocnum_t LoCPUAMPNo; tosprocnum_t LoCPUAMPProc; fltreal64_t HiDiskAMP; tosprocnum_t HiDiskAMPNo; tosprocnum_t HiDiskAMPProc; fltreal64_t LoDiskAMP; tosprocnum_t LoDiskAMPNo; tosprocnum_t LoDiskAMPProc; fltreal64_t HiDiskAMPIO; tosprocnum_t HiDiskAMPIONo; tosprocnum_t HiDiskAMPIOProc; fltreal64_t LoDiskAMPIO; tosprocnum_t LoDiskAMPIONo; tosprocnum_t LoDiskAMPIOProc; fltreal64_t PEAvgCPU; fltreal64_t HiCPUPEUse; tosprocnum_t HiCPUPENo; tosprocnum_t HiCPUPEProc; fltreal64_t LoCPUPEUse; tosprocnum_t LoCPUPENo; tosprocnum_t LoCPUPEProc; fltreal64_t SessionCount; Integer SesMonitorSys; Integer SesMonitorLoc; Integer VprocLogging; Integer VprocMonitor; char Release[29]; char Version[32];} MonVirSum_t;

typedef struct { char NetAUp; char NetBUp; Int16 SampleRate;} MonVirRes1_t;

typedef struct { char NetAUp; char NetBUp; char SystemType[7];} MonConfig_t;

typedef struct{ Integer ProcId; Integer VProcNo; char VprocType[3]; Int16 HostId; char Status; Int16 DiskSlice;} MonVirConfig_t;

Page 428: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

428 Workload Management API: PM/API and Open API

typedef struct{ Integer ProcId; char Status; char CpuType[7]; Integer CpuCount; } MonPhyConfig_t;

typedef struct{ char VprocType[3]; Integer ProcId; Integer VProcNo;

Integer ClusterNo;fltreal64_t CPUUse;

char Status;Integer SessLogCount;Integer SessRunCount;fltreal64_t DiskUse;fltreal64_t CICUse;fltreal64_t DiskReads;fltreal64_t DiskWrites;fltreal64_t DiskOutReqAvg;fltreal64_t HostBlockReads;fltreal64_t HostBlockWrites;fltreal64_t MemAllocates;fltreal64_t MemAllocateKB;fltreal64_t PctService;fltreal64_t PctAMPWT;fltreal64_t PctParser;fltreal64_t PctDispatcher;fltreal64_t NetReads;fltreal64_t NetWrites;fltreal64_t NVMemAllocSegs;

} MonVirRes2_t;

typedef struct{ Integer ProcId; Integer AmpCount;

Integer PECount;fltreal64_t CPUUse;

fltreal64_t PercentKernel; fltreal64_t PercentService; fltreal64_t PercentUser; char Status; fltreal64_t NetAUse; fltreal64_t NetBUse;

fltreal64_t DiskUse;fltreal64_t CICUse;fltreal64_t DiskReads;fltreal64_t DiskWrites;fltreal64_t DiskOutReqAvg;fltreal64_t HostBlockReads;fltreal64_t HostBlockWrites;

fltreal64_t SwapReads; fltreal64_t SwapWrites; fltreal64_t SwapDrops;

Page 429: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

Workload Management API: PM/API and Open API 429

fltreal64_t MemAllocates;fltreal64_t MemAllocateKB;

fltreal64_t MemFailures; fltreal64_t MemAgings;

fltreal64_t NetReads;fltreal64_t NetWrites;

fltreal64_t NVMemAgings; fltreal64_t NVMemAllocate;

fltreal64_t NVMemAllocSegs;} MonPhyRes2_t;

typedef struct { Integer NumOfSteps; Integer CurStepBegNum; Integer CurStepEndNum;} MonSqlStepInfo_t;

typedef struct{ fltreal64_t EstRowCount; fltreal64_t ActRowCount; fltreal64_t EstElapTime; fltreal64_t ActElapTime;} MonSqlStepStats_t;

typedef struct{ char OldAcct[MAXNAME] ; Int16 ErrorCode;} SetSessAcct_t;

typedef struct ERROR_FAIL_Type { Word StatementNo; Word Info; Word Code; Word Length; char Msg[255];} Error_Fail_t;#define MAXFIELDS 100typedef struct InfoPairs{ short FType; short FSize;} InfoPairs;

typedef struct DataInfo_t{ short field_count; InfoPairs FieldData[MAXFIELDS]; } DataInfo_t;

#pragma pack()#endif

Page 430: Workload management api

Appendix A: Sample PM/API ApplicationHeader File for Sample PMPC Application

430 Workload Management API: PM/API and Open API

Page 431: Workload management api

Workload Management API: PM/API and Open API 431

APPENDIX B Combination PEState andAMPState Response

Values for MONITOR SESSION

This appendix lists all the possible combinations in Teradata Manager of the PEState and AMPState response values returned from a MONITOR SESSION request and the resulting effect of each combination on session states. For a detailed description of each of these response values, see “MONITOR SESSION” on page 116.

Sample MONITOR SESSION Responses

As described in the table below, the MONITOR SESSION request returns both the PEState (A) and AMPState (B) response values. A client performance monitoring application (C), like Teradata Manager, interprets the meaning of the PEState and AMPState combination, which is displayed as the session state in the client application.

You can view different session states in Teradata Manager. For instructions on filtering for the types of sessions you wish to view, see Teradata Manager User Guide.

Note: The session state is not returned by any PM/API CLIv2 interface. It is interpreted by the client application.

IF A is… AND B is… THEN C displays…

HOST RESTART any AMP state HOST RESTART

ABORTING ABORTING ABORTING

ABORTING ACTIVE ABORTING

ABORTING BLOCKED ABORTING

ABORTING IDLE ABORTING

ABORTING UNKNOWN ABORTING

PARSING WAIT ABORTING ABORTING

PARSING WAIT BLOCKED BLOCKED

PARSING WAIT ACTIVE PARSING

PARSING WAIT IDLE PARSING

PARSING WAIT UNKNOWN PARSING

Page 432: Workload management api

Appendix B: Combination PEState and AMPState Response Values for MONITOR SESSIONSample MONITOR SESSION Responses

432 Workload Management API: PM/API and Open API

PARSING ABORTING ABORTING

PARSING BLOCKED BLOCKED

PARSING ACTIVE PARSING

PARSING IDLE PARSING

PARSING UNKNOWN PARSING

DISPATCHING ABORTING ABORTING

DISPATCHING BLOCKED BLOCKED

DISPATCHING ACTIVE ACTIVE

DISPATCHING IDLE ACTIVE

DISPATCHING UNKNOWN ACTIVE

ELICIT CLIENT DATA ABORTING ABORTING

ELICIT CLIENT DATA BLOCKED BLOCKED

ELICIT CLIENT DATA ACTIVE ACTIVE

ELICIT CLIENT DATA IDLE ACTIVE

ELICIT CLIENT DATA UNKNOWN ACTIVE

RESPONSE ABORTING ABORTING

RESPONSE BLOCKED BLOCKED

RESPONSE ACTIVE RESPONSE

RESPONSE IDLE RESPONSE

RESPONSE UNKNOWN RESPONSE

ACTIVE ABORTING ABORTING

ACTIVE BLOCKED BLOCKED

ACTIVE ACTIVE ACTIVE

ACTIVE IDLE ACTIVE

ACTIVE UNKNOWN ACTIVE

IDLE: IN-DOUBT ABORTING UNKNOWN

IDLE: IN-DOUBT BLOCKED UNKNOWN

IDLE: IN-DOUBT ACTIVE UNKNOWN

IDLE: IN-DOUBT IDLE UNKNOWN

IDLE: IN-DOUBT UNKNOWN UNKNOWN

IDLE ABORTING IDLE

IF A is… AND B is… THEN C displays…

Page 433: Workload management api

Appendix B: Combination PEState and AMPState Response Values for MONITOR SESSIONSample MONITOR SESSION Responses

Workload Management API: PM/API and Open API 433

IDLE BLOCKED IDLE

IDLE ACTIVE IDLE

IDLE IDLE IDLE

IDLE UNKNOWN IDLE

DELAYED any AMP state DELAYED

SESDELAYED any AMP state SESDELAYED

QTDELAYED any AMP state QTDELAYED

BLOCKED IDLE BLOCKED

Note: A BLOCKED session state in monitor partition session means some background activity is in progress and the last request is on hold until this background activity is completed. Database locks are not directly involved in BLOCKED monitor partition sessions. One example of background activity that could place a request on hold is when the monitor partition session is aborted externally and the session is processing this asynchronous abort request that came in internally.

IF A is… AND B is… THEN C displays…

Page 434: Workload management api

Appendix B: Combination PEState and AMPState Response Values for MONITOR SESSIONSample MONITOR SESSION Responses

434 Workload Management API: PM/API and Open API

Page 435: Workload management api

Workload Management API: PM/API and Open API 435

Glossary

2PC Two-Phase Commit

AMP Access Module Processor

API Application Program Interface

ARC Teradata Archive/Recovery Utility

BTEQ Basic Teradata Query

CLI Call Level Interface

CLIv2 Call Level Interface, Version 2

DBW Database Window

DSS Decision Support System

FE Field Engineer

HSI Host System Interface

HUT Host Utility

HUTCNS Host Utility Console Subsystem

I/O Input/Output

LAN Local Area Network

LSN Logon Sequence Number

MPP Massively Parallel Processing

OLTP Online Transaction Processing

PDE Parallel Database Extensions

PE Parsing Engine

PMON Performance Monitor

PMPC Performance Monitor and Production Control

ResUsage Resource Usage

SLG Service Level Goals

SMF System Management Facility

SMP Symmetric Multi-Processing

Page 436: Workload management api

Glossary

436 Workload Management API: PM/API and Open API

TDP Teradata Director Program

Teradata ASM Teradata Active System Management

Teradata DWM Teradata Dynamic Workload Manager

TSR Tequel Start Request

vproc Virtual Processor

WQM Workload Query Manager

Page 437: Workload management api

Workload Management API: PM/API and Open API 437

Index

Symbols

AAbort Count response value 343abort processing, PM/APIs 37ABORT SESSION request, PM/API 41, 54

2PC 55and MONITOR PHYSICAL RESOURCE 106and MONITOR PHYSICAL SUMMARY 66and MONITOR SESSION 64BTEQ sessions, aborting 58DBC.SW_Event_Log table 57example 222input data 54, 62parcels 60privileges 56response values 61sample input 62sample output 62statement type 2 62utility jobs, aborting 59warning and error messages 63

AbortCnt result row 383Aborted sessions 64AbortListSessions function 220

definition 220input parameters 220result rows 221usage notes 221

AbortSession function 218definition 218examples 219input parameters 218return value 219usage notes 219

AbortStatus response value 61AbortStatus result row 222ActElapsedTime result row 281ActElapTime response value 151Active Date response value 318Active Delayed Count response value 343Active Query Count response value 343Active result row 386Active Time response value 318ActiveQueryCnt result row 383

ActRowCount response value 151ActRowCount result row 281ALTER TABLE statement, SQL 57AMPAvgCPU response value 190AMPAvgCPU result row 298AMPAvgDisk response value 190AMPAvgDisk result row 298AMPAvgDiskIO response value 191AMPAvgDiskIO result row 298AMPCount response value 92AmpCount result row 242, 248, 273AMPCPUSec response value 128AMPCPUSec result row 235, 267AMPIO response value 129AMPIO result row 235, 267AMPState response value 128AMPState result row 235, 266APIs

query band 389System PMPC 49Teradata Dynamic Workload Management 311

Application Programming Interfaces. See APIsApplication, PM/API sample 405Arrivals response value 342Arrivals result row 383Average CPU Time response value 343Average Delay Time response value 343Average Response Time response value 343AvgAmpCPUSec response value 137AvgAmpCPUSec result row 241, 273AvgAmpIOCnt response value 137AvgAmpIOCnt result row 242, 273AvgCPU response value 110AvgCPU result row 258AvgCPUTime result row 383AvgDelayTime result row 383AvgDisk response value 110AvgDisk result row 258AvgDiskIO response value 110AvgDiskIO result row 258AvgRespTime result row 383

BBlk_x_HostId response value 129Blk_x_LMode response value 131Blk_x_ObjDBId response value 132

Page 438: Workload management api

Index

438 Workload Management API: PM/API and Open API

Blk_x_ObjTId response value 133Blk_x_OType response value 132Blk_x_SessNo response value 130Blk_x_Status response value 133Blk_x_UserID response value 130BlkxHostId result row 236, 267BlkxLmode result row 237, 269BlkxObjDBID result row 238, 270BlkxObjTID result row 238, 270BlkxOtype result row 238, 269BlkxSessNo result row 236, 268BlkxStatus result row 239, 270BlkxUserId result row 237, 268Blocked sessions 64BlockingCnt result row 368BTEQ sessions, aborting 58buffer allocation 36

CCall-Level Interface version 2. See CLIv2CICUse result row 173, 252, 292Classification Mode response value 139CLIv2

overviewprocessing requestsrequirements 31

CLIv2 interfaces. See PM/API requestsClusterNo result row 288Completions response value 343Completions result row 383Confidence response value 151Confidence result row 281Config ID response value 314Config Name response value 314Configuration ID response value 330CPUCount response value 85CPUCount result row 246CPUType response value 85CPUType result row 246CPUUse response value 92CPUUse result row 170, 248, 289CurLev1StepNum response value 150CurLev2StepNum response value 150CurLvl1StepNo result row 279CurLvl2StepNo result row 279

DDate response value 315, 320Date result row 361DBC.Dbase table 69DBC.ResUsage table 199DBC.SessionTbl table 69, 205, 308DBC.Software_Event_LogV view 39, 57, 83, 160, 201, 210

205DBC.TVM table 69Delayed Count response value 343Delayed result row 387DelayedCnt result row 383disadvantages, using PM/APIs 14DiskOutReqAvg result row 175, 251, 292DiskReads response value 96DiskReads result row 173, 250, 291DiskSlice response value 162DiskSlice result row 286DiskUse response value 95DiskUse result row 172, 250, 290DiskWrites response value 97DiskWrites result row 174, 251, 291DontReclassifyFlag result row 242, 274Due To Duration response value 318DueToDuration result row 365dynamic data 41

EEnabled Flag response value 330EnabledFlag result row 373Error Count response value 343error messages 41, 50ErrorCnt result row 383EstElapsedTime result row 281EstElapTime response value 151EstRowCount response value 151EstRowCount result row 281event 19Event Active Time response value 316EVENT STATUS request, PM/API 313

input data 313parcels 313response values 314usage notes 313

Event_Category result row 372EventActiveDate response value 316EventActiveDate result row 364EventActiveTime result row 364EventId response value 315EventId result row 364EventKind result row 361EventStatus response value 315EventStatus result row 364examples, PMPC applications

idle session logoff 23resource supervisor 23

Exception Count response value 343ExceptionCnt result row 383ExpActiveDate result row 364ExpActiveTime result row 364

Page 439: Workload management api

Index

Workload Management API: PM/API and Open API 439

Expression Active Date response value 316Expression Active Time response value 316Expression Status response value 316ExpressionId response value 316ExpressionId result row 364ExpressionStatus result row 364external stored procedures

GetQueryBandSP 399GetQueryBandValue 400GetQueryBandValueSp 402TDWMApply 355TDWMEventControl 359TDWMObjectAssn 376TDWMRuleControl 380TDWMSetLimits 381

FFCVprocIdx result row 229filter 20Filter_Category result row 372Flow Control response value 78Flow Control x VprocId response value 79FlowControl result row 228

GGetQueryBand function 396

definition 396example 396return value 396usage notes 396

GetQueryBandPairs function 397definition 397examples 398input parameters 397result rows 397usage notes 398

GetQueryBandSP procedure 399definition 399example 399output parameter 399usage notes 399

GetQueryBandValue procedure 400definition 400examples 401input parameters 400output parameter 400usage notes 401

GetQueryBandValueSP procedure 402definition 402example 402input parameters 402output parameter 402

Global session monitoring rate 46

GRANT MONTOR command, SQL 40Group I data fields 124Group II data fields 134Group III data fields 138Group IV data fields 54, 75, 82, 88, 138, 139, 147, 159, 188,

199, 204, 405, 418

HHiCPUAMPNo response value 191HiCPUAMPNo result row 299HiCPUAMPProc response value 191HiCPUAMPProc result row 300HiCPUAMPUse response value 191HiCPUAMPUse result row 299HiCPUPENo response value 195HiCPUPENo result row 302HiCPUPEProc response value 195HiCPUPEProc result row 302HiCPUPEUse response value 195HiCPUPEUse result row 301HiDiskAMP response value 192HiDiskAMP result row 299HiDiskAMPIO response value 193HiDiskAMPIO result row 299HiDiskAMPIONo response value 194HiDiskAMPIONo result row 299HiDiskAMPIOProc response value 194HiDiskAMPIOProc result row 300HiDiskAMPNo response value 192HiDiskAMPNo result row 299HiDiskAMPProc response value 193HiDiskAMPProc result row 300High AMP 1 In-Use Count response value 78High AMP 1 VprocId response value 78High AMP 2 In-Use Count response value 78High AMP 2 VprocId response value 78High AMP 3 In-Use Count response value 78High AMP 3 VprocId response value 78High AMP 4 In-Use Count response value 78High AMP 4 VprocId response value 78High AMP 5 In-Use Count response value 78High AMP 5 VprocId response value 78HighAMP1InUseCount result row 228HighAMP1VprocId result row 228HighAMP2InUseCount result row 228HighAMP2VprocId result row 228HighAMP3InUseCount result row 228HighAMP3VprocId result row 228HighAMP4InUseCount result row 228HighAMP4VprocId result row 228HighAMP5InUseCount result row 228HighAMP5VprocId result row 228HighCPUProcId response value 110

Page 440: Workload management api

Index

440 Workload Management API: PM/API and Open API

HighCPUProcId result row 259HighCPUUse response value 110HighCPUUse result row 258HighDisk response value 111HighDisk result row 258HighDiskIO response value 112HighDiskIO result row 258HighDiskIOProcId response value 112HighDiskIOProcId result row 259HighDiskProcId response value 111HighDiskProcId result row 259HostBlockReads response value 98HostBlockWrites response value 99HostId response value 61, 124, 162HostId result row 221, 233, 264, 279, 281, 283, 285, 368, 370HostId/ClusterNo result row 170HotAmp1CPU response value 134HotAmp1CPU result row 239, 271HotAmp1CPUId response value 135HotAmp1CPUId result row 240, 271HotAMP1IO response value 135HotAmp1IO result row 240, 271HotAmp1IOId response value 135HotAmp1IOId result row 240, 272HotAmp2CPU response value 135HotAmp2CPU result row 239, 271HotAmp2CPUId response value 135HotAmp2CPUId result row 240, 271HotAMP2IO response value 135HotAmp2IO result row 240, 271HotAmp2IOId response value 136HotAmp2IOId result row 240, 272HotAmp3CPU response value 135HotAmp3CPU result row 240, 271HotAmp3CPUId response value 135HotAmp3CPUId result row 240, 271HotAMP3IO response value 135HotAmp3IO result row 240, 271HotAmp3IOId response value 136HotAmp3IOId result row 240, 272HstBlkRds result row 176, 253, 293HstBlkWrts result row 176, 253, 293

IId response value 317IDENTIFY request, PM/API 34, 67

and MONITOR SESSION 72IDENTIFY DATABASE 68IDENTIFY SESSION 68IDENTIFY TABLE 68IDENTIFY USER 69input data 67parcels 69

sample input 70sample output 71warning and error messages 72

IdentifyDatabase function 223definition 223example 223input parameter 223return value 223usage notes 223

IdentifySession function 224definition 224example 224input parameters 224return value 224

IdentifyTable function 225definition 225example 225input parameter 225return value 225usage notes 224, 225

IdentifyUser function 226definition 226example 226input parameter 226return value 226usage notes 226

Idle Session Logoff 24interfaces

CLIv2 49, 311, 389SQL 49, 311, 389

internal session, handling 121Interval 1 Count response value 77Interval 2 Count response value 77Interval 3 Count response value 78Interval 4 Count response value 78IntervalCount1 result row 228IntervalCount2 result row 228IntervalCount3 result row 228IntervalCount4 result row 228

Kkeywords/reserved words 40

Llocal session monitoring rate 46locks, monitoring 72LoCPUAMPNo response value 192LoCPUAMPNo result row 300LoCPUAMPProc response value 192LoCPUAMPProc result row 301LoCPUAMPUse response value 192LoCPUAMPUse result row 300LoCPUPENo response value 195

Page 441: Workload management api

Index

Workload Management API: PM/API and Open API 441

LoCPUPENo result row 302LoCPUPEProc response value 196LoCPUPEProc result row 302LoCPUPEUse response value 195LoCPUPEUse result row 302LoDiskAMP response value 193LoDiskAMP result row 300LoDiskAMPIO response value 194LoDiskAMPIO result row 300LoDiskAMPIONo response value 194LoDiskAMPIONo result row 301LoDiskAMPIOProc response value 194LoDiskAMPIOProc result row 301LoDiskAMPNo response value 193LoDiskAMPNo result row 301LoDiskAMPProc response value 193LoDiskAMPProc result row 301logging rate

physical resource 47setting 46virtual resource 47

LogonDate response value 125LogonPENo response value 124LogonPENo result row 233, 265LogonSource response value 134LogonSource result row 239, 271LogonTime response value 125LogonTime result row 233, 265Low AMP 1 In-Use Count response value 79Low AMP 1 VprocId response value 79Low AMP 2 In-Use Count response value 79Low AMP 2 VprocId response value 79Low AMP 3 In-Use Count, response value 79Low AMP 3 VprocId response value 79Low AMP 4 In-Use Count response value 79Low AMP 4 VprocId, response value 79Low AMP 5 In-Use Count, response value 79Low AMP 5 VprocId response value 79LowAmp1CPU response value 136LowAmp1CPU result row 240, 272LowAmp1CPUId response value 136LowAmp1CPUId result row 241, 272LowAMP1InUseCount result row 228LowAmp1IO response value 136LowAmp1IO result row 241, 272LowAmp1IOId response value 137LowAmp1IOId result row 241, 273LowAMP1VprocId result row 228LowAmp2CPU response value 136LowAmp2CPU result row 240, 272LowAmp2CPUId response value 137LowAmp2CPUId result row 241, 272LowAMP2InUseCount result row 229LowAmp2IO response value 136

LowAmp2IO result row 241, 272LowAmp2IOId response value 137LowAmp2IOId result row 241, 273LowAMP2VprocId result row 229LowAmp3CPU response value 136LowAmp3CPU result row 241, 272LowAmp3CPUId response value 137LowAmp3CPUId result row 241, 272LowAMP3InUseCount result row 229LowAmp3IO response value 136LowAmp3IO result row 241, 272LowAmp3IOId response value 137LowAmp3IOId result row 241, 273LowAMP3VprocId result row 229LowAMP4InUseCount result row 229LowAMP4VprocId result row 229LowAMP5InUseCount result row 229LowAMP5VprocId result row 229LowCPUProcId response value 111LowCPUProcId result row 259LowCPUUse response value 111LowCPUUse result row 259LowDisk response value 112LowDisk result row 259LowDiskIO response value 112LowDiskIO result row 259LowDiskIOProcId response value 113LowDiskIOProocId result row 260LowDiskProcId response value 112LowDiskProcId result row 259LSN response value 125LSN result row 234, 265

MMaxCPUTime result row 383Maximum CPU Time response value 343Maximum Response Time response value 343MaxRespTime result row 383MemAgings response value 102MemAgings result row 255MemAllocateKB result row 254MemAllocates result row 254MemFailures response value 102MemFailures result row 255messages, common warning and error 50Met SLG Count response value 343MetSLGCnt result row 383MinCPUTime result row 383Minimum CPU Time response value 343Minimum Response Time response value 343MinRespTime result row 383mode

indicator or record, response 35

Page 442: Workload management api

Index

442 Workload Management API: PM/API and Open API

indicator or record, setting 34MONITOR 88MONITOR AWT RESOURCE request, PM/API 75

input data 75output 80parcels 76response values 77statement types 77usage notes 75warning and error messages 81

MONITOR PHYSICAL CONFIG request, PM/API 82input data 82monitor privileges 82parcels 83privileges 82response values 84, 85sample input 85sample output 86usage notes 82warning and error messages 86

MONITOR PHYSICAL RESOURCE request, PM/API 87, 88and ABORT SESSION 65input data 88, 104monitor privileges 88parcels 90response values 91, 92sample input 104sample output 104usage notes 88versus ResUsage data 89warning and error messages 105, 393

MONITOR PHYSICAL SUMMARY request, PM/API 108and ABORT SESSION 66and MONITOR PHYSICAL CONFIG 86and SET RESOURCE RATE 106and SET SESSION RATE 106input data 108monitor privileges 108parcels 109privileges 108response values 110sample input 80, 114sample output 114usage notes 108warning and error messages 115

monitor privilegesABORTSESSION 189, 341MONRESOURCE 189MONSESSION 189, 341SETRESRATE 189SETSESSRATE 189

monitor processing 33MONITOR QUERYBAND request, PM/API 391

input data 391

parcels 392sample input 392sample output 393usage notes 391warning and error messages 393

MONITOR SESSION request, PM/API 116and ABORT SESSION 64and IDENTIFY 72, 118examples 140handling internal session blocks 121input data 116, 139monitor privileges 117parcels 122privileges 117processor down 120response parcel groups 54, 75, 82, 88, 124, 134, 138, 139,

147, 159, 188, 199, 204, 405, 418response values 124sample input 139sample output 139session data collection 119setting up a request 405unreported session partitions 120usage notes 117warning and error messages 144writing a Resource Supervisor 23writing an Idle Session Logoff 24

MONITOR SQL request, PM/API 147input data 147monitor privileges 148parcels 148response values 150sample input 151sample output 152usage notes 148warning and error messages 154

MONITOR VERSION request, PM/API 156input data 156monitor privileges 156parcels 157response value 157sample input 158sample output 158usage notes 156warning and error messages 158

MONITOR VIRTUAL CONFIG request, PM/API 159, 160input data 151, 159monitor privileges 159privileges 157, 159response values 161sample input 162sample output 152usage notes 159warning and error messages 164

Page 443: Workload management api

Index

Workload Management API: PM/API and Open API 443

MONITOR VIRTUAL RESOURCE request, PM/API 166and ABORT SESSION 66and SET RESOURCE RATE 42input data 166, 183monitor privileges 166parcels 168privileges 166response values 169sample input 183sample output 183usage notes 166warning and error messages 185

MONITOR VIRTUAL SUMMARY request, PM/API 188and SET RESOURCE RATE 106input data 188monitor privileges 188parcels 189response values 190sample input 197sample output 198usage notes 188warning and error messages 198

MonitorAWTResource function 227definition 227example 229result rows 228usage notes 227

monitoring rates 42global session 46local session 46node resource 200physical resource 46virtual resource 46

MonitorMySessions function 231definition 231example 244result rows 233

MonitorPhysicalConfig function 245definition 245example 246result rows 245usage notes 245

MonitorPhysicalResource function 247, 256definition 247result rows 248usage notes 247

MonitorPhysicalSummary function 257definition 257example 260result rows 258usage notes 257

MonitorQueryBand function 403definition 403example 403

input parameters 403return value 403usage notes 403

MonitorSession function 262definition 262example 275input parameters 263result rows 264usage notes 264

MonitorSessionRate function 276definition 276example 277input parameters 276return value 276usage notes 276

MonitorSQLCurrentStep function 278definition 278example 279input parameters 278result rows 279usage notes 278

MonitorSQLSteps function 280definition 280example 281input parameters 280result rows 281usage notes 280

MonitorSQLText function 283definition 283example 284input parameters 283result rows 283usage notes 283

MonitorVirtualConfig function 285definition 285example 286result rows 285usage notes 285

MonitorVirtualResource function 287definition 287result rows 288usage notes 287

MonitorVirtualSummary function 297definition 297example 303result rows 298usage notes 298

MoreBlockers result row 239, 270MSGWORKNEW work type 77MSGWORKONE work type 77

NName Length response value 330

Page 444: Workload management api

Index

444 Workload Management API: PM/API and Open API

NetAUp response value 84, 91, 113, 161, 169NetAUp result row 260NetAUse response value 94NetAUse result row 252NetBUp response value 84, 91, 113, 161, 169NetBUp result row 260NetBUse response value 94NetBUse result row 252NetReads result row 180, 252, 294NetUse response value 113NetUse result row 260NetWrites result row 181, 252, 294NewStatus result row 360node

collection rate 200logging rate 200ResUsage monitoring 17

NumOfSteps response value 150NumOfSteps result row 279NVMemAgings response value 103NVMemAgings result row 255NVMemAllocate response value 103NVMemAllocate result row 255NVMemAllocSegs result row 4, 182, 255, 295

OObject Id response value 319Object Name response value 320Object Status response value 320Object Type response value 319ObjectId result row 361ObjectName result row 361, 386ObjectStatus result row 361ObjectType result row 361, 386open API routines. See UDFs, external stored proceduresopen APIs 13

examples 14overview 14versus PM/APIs 15

open Application Programming Interfaces. See open APIsOpEnv 359operating environments. See OpEnvOther Count response value 343OverRidable result row 368, 370

Pparcels

ABORT SESSION 60data 34error 36EVENT STATUS 313failure 36IDENTIFY 69

IndicData 34IndicReq 33MONITOR AWT RESOURCE 76MONITOR PHYSICAL CONFIG 83MONITOR PHYSICAL RESOURCE 90MONITOR PHYSICAL SUMMARY 109MONITOR QUERYBAND 392MONITOR SESSION 122, 392MONITOR SQL 148MONITOR VERSION 157MONITOR VIRTUAL CONFIG request 160MONITOR VIRTUAL RESOURCE 168MONITOR VIRTUAL SUMMARY 189PERFGROUPS 322request 33response 35SET RESOURCE RATE 201SET SESSION ACCOUNT 205SET SESSION RATE request 214TDWM DELAY REQUEST CHANGE 326TDWM LIST WD 329TDWM STATISTICS 334TDWM SUMMARY 341TDWM WD ASSIGNMENT 346USER EVENT CONTROL 350

PartName response value 126PartName result row 233, 265PctAMPWT result row 179, 290PctDispatcher result row 180, 292PctParser result row 179, 292PctService result row 178, 289PEAvgCPU response value 195PEAvgCPU result row 301PECount response value 92PECount result row 248PECPUsec response value 127PECPUsec result row 234, 266PercntKernel response value 92PercntService response value 93PercntUser response value 93PERFGROUPS request, PM/API 321

examples 323input data 321parcels 322sample input 323sample output 323usage notes 321warning and error messages 324

Performance Group Name response value 323Performance Group. See PGPerformance Monitor Application Programming Interfaces.

See PM/APIsPerformance Monitor. See PMONPEState response value 126

Page 445: Workload management api

Index

Workload Management API: PM/API and Open API 445

PEstate result row 233, 265PG

description 321parcel format 322using Priority Scheduler 321

physical resource logging rate 47physical resource monitoring rate 17, 46PM/API requests

ABORT SESSION 41, 54, 145EVENT STATUS 313IDENTIFY 34, 67, 72IDENTIFY DATABASE 34IDENTIFY TABLE 34IDENTIFY USER 34MONITOR AWT RESOURCE 75MONITOR PHYSICAL CONFIG 82MONITOR PHYSICAL RESOURCE 88MONITOR PHYSICAL SUMMARY 108MONITOR QUERYBAND 391MONITOR SESSION 116, 145MONITOR SQL 147MONITOR VERSION 156MONITOR VIRTUAL CONFIG 159MONITOR VIRTUAL RESOURCE 166MONITOR VIRTUAL SUMMARY 188PERFGROUPS 321SET RESOURCE RATE 199SET SESSION ACCOUNT 204SET SESSION RATE 209TDWM DELAY REQUEST CHANGE 325TDWM LIST WD 329TDWM STATISTICS 333TDWM WD ASSIGNMENT 345USER EVENT CONTROL 349

PM/API sample application 405PM/APIs

abort processing 37and Teradata SQL 39applications, logging off 39applications, logging on 38buffer allocation 36creating requests 33dynamic data 41error messages 41keywords/reserved words 40logging rate 45monitoring rates 42overview 13processing aborts 37request buffer, allocation 36request processing 33resource usage data 42response buffer, allocation 36response processing 35, 36

sampling rate 45using, disadvantages of 14warning and error messages 39, 50

PMON, output 153PMPC. See System PMPCPrcntKernel result row 249PrcntService result row 249PrcntUser result row 249Precedence result row 361Precedence/Severity response value 320Previous User-Defined Event Status response value 350PriorStatus result row 360ProcId response value 85, 92, 162ProcId result row 170, 245, 248, 285, 288

QQBName result row 397QBValue result row 397query band

API examples 26CLIv2 interfaces 390retrieving 389session 392SQL interfaces 395transaction 392using SET QUERY_BAND 22

query bandingdescription 13features 22

Rrate, logging 46rates

local 210system-wide 210

Record Type response value 317RecordId result row 364RecordStatus result row 365RecordType result row 364Release response value 114, 197ReleaseNum result row 260, 303ReqCacheHits response value 128ReqCacheHits result row 234, 266ReqCount response value 127ReqCount result row 234, 266ReqCPU result row 242, 273ReqIO result row 242, 273ReqNo result row 242, 273ReqSpool result row 267ReqStartTime result row 242, 273Request Number response value 138request, creating 33

IndicReq parcel 33

Page 446: Workload management api

Index

446 Workload Management API: PM/API and Open API

USING Data String 33Request_AMPSpool response value 129RequestAmpCPU response value 138RequestAmpI/O response value 138RequestNo result row 368RequestStartDate response value 138RequestStartTime response value 138requirements

granting privileges 31using CLIv2 interfaces 31using SQL interfaces 31

Reserved2 response value 126ResLogging rate 17, 200, 306ResLogging response value 113ResLogging result row 260ResMonitor rate 17, 200, 306ResMonitor response value 113ResMonitor result row 260Resource Partition Index response value 323Resource Partition. See RP 321Resource Supervisor 23resource usage

physical, logging of 47virtual, logging of 47

response parcel groups 134response processing

error parcel 36Failure parcel 36parcel ordering 35

response valuesAbort Count 343AbortStatus 61ActElapTime 151Active Date 318Active Delayed Count 343Active Query Count 343Active Time 318ActRowCount 151AMPAvgCPU 190AMPAvgDisk 190AMPAvgDiskIO 191AmpCount 92AMPCPUSec 128AMPIO 129AMPState 128Arrivals 342Average CPU Time 343Average Delay Time 343Average Response Time 343AvgAmpCPUSec 137AvgAmpIOCnt 137AvgCPU 110AvgDisk 110AvgDiskIO 110

Blk_x_HostId 129Blk_x_LMode 131Blk_x_ObjDBId 132Blk_x_ObjTId 133Blk_x_OType 132Blk_x_SessNo 130Blk_x_Status 133Blk_x_UserID 130Classification Mode 139Completions 343Confidence 151Config ID 314Config Name 314Configuration ID 330CPUCount 85CPUType 85CPUUse 92CurLev1StepNum 150CurLev2StepNum 150Date 315, 320Delayed Count 343DiskReads 96DiskSlice 162DiskUse 95DiskWrites 97Due To Duration 318Enabled Flag 330Error Count 343EstElapTime 151EstRowCount 151Event Active Time 316EventActiveDate 316EventId 315EventStatus 315Exception Count 343Expression Active Date 316Expression Active Time 316Expression Status 316ExpressionId 316Flow Control 78Flow Control x VprocId 79HiCPUAMPNo 191HiCPUAMPProc 191HiCPUAMPUse 191HiCPUPENo 195HiCPUPEProc 195HiCPUPEUse 195HiDiskAMP 192HiDiskAMPIO 193HiDiskAMPIONo 194HiDiskAMPIOProc 194HiDiskAMPNo 192HiDiskAMPProc 193High AMP 1 In-Use Count 78

Page 447: Workload management api

Index

Workload Management API: PM/API and Open API 447

High AMP 1 VprocId 78High AMP 2 In-Use Count 78High AMP 2 VprocId 78High AMP 3 In-Use Count 78High AMP 3 VprocId 78High AMP 4 In-Use Count 78High AMP 4 VprocId 78High AMP 5 In-Use Count 78High AMP 5 VprocId 78HighCPUProcId 110HighCPUUse 110HighDisk 111HighDiskIO 112HighDiskIOProcId 112HighDiskProcId 111HostBlockReads 98HostBlockWrites 99HostId 61, 124, 162HotAmp1CPU 134HotAmp1CPUId 135HotAMP1IO 135HotAmp1IOId 135HotAmp2CPU 135HotAmp2CPUId 135HotAMP2IO 135HotAmp2IOId 136HotAmp3CPU 135HotAmp3CPUId 135HotAMP3IO 135HotAmp3IOId 136Id 317Interval 1 Count 77Interval 2 Count 77Interval 3 Count 78Interval 4 Count 78LoCPUAMPNo 192LoCPUAMPProc 192LoCPUAMPUse 192LoCPUPENo 195LoCPUPEProc 196LoCPUPEUse 195LoDiskAMP 193LoDiskAMPIO 194LoDiskAMPIONo 194LoDiskAMPIOProc 194LoDiskAMPNo 193LoDiskAMPProc 193LogonDate 125LogonPENo 124LogonSource 134LogonTime 125Low AMP 1 In-Use Count 79Low AMP 1 VprocId 79Low AMP 2 In-Use Count 79

Low AMP 2 VprocId 79Low AMP 3 In-Use Count 79Low AMP 3 VprocId 79Low AMP 4 In-Use Count 79Low AMP 4 VprocId 79Low AMP 5 In-Use Count 79Low AMP 5 VprocId 79LowAmp1CPU 136LowAmp1CPUId 136LowAmp1IO 136LowAmp1IOId 137LowAmp2CPU 136LowAmp2CPUId 137LowAmp2IO 136LowAmp2IOId 137LowAmp3CPU 136LowAmp3CPUId 137LowAmp3IO 136LowAmp3IOId 137LowCPUProcId 111LowCPUUse 111LowDisk 112LowDiskIO 112LowDiskIOProcId 113LowDiskProcId 112LSN 125Maximum CPU Time 343Maximum Response Time 343MemAgings 102MemFailures 102Met SLG Count 343Minimum CPU Time 343Minimum Response Time 343Name Length 330NetAUp 84, 91, 113, 161, 169NetAUse 94NetBUp 84, 91, 113, 161, 169NetBUse 94NetUse 113NumOfSteps 150NVMemAgings 103NVMemAllocate 103Object Id 319Object Name 320Object Status 320Object Type 319Other Count 343PartName 126PEAvgCPU 195PECount 92PECPUsec 127PercntKernel 92PercntService 93PercntUser 93

Page 448: Workload management api

Index

448 Workload Management API: PM/API and Open API

Performance Group Name 323PEState 126Precedence/Severity 320Previous User-Defined Event Status 350ProcId 85, 92, 162Record Type 317Release 114, 197ReqCacheHits 128ReqCount 127Request Number 138Request_AMPSpool 129RequestAmpCPU 138RequestAmpI/O 138RequestStartDate 138RequestStartTime 138Reserved2 126ResLogging 113ResMonitor 113Resource Partition Index 323RunVprocNo 124SampleSec 91, 169SesMonitorLoc 196SesMonitorSys 196SessionNo 61, 124Status 85, 94, 162, 317StepNum 150StepText 150, 151SwapDrops 100SwapReads 99SwapWrites 99SystemType 84, 161TempSpace 134Time 315, 320UpAMPCount 137UserAccount 125User-Defined Event Status 350UserId 125UserName 61, 124Version 114, 197VprocLogging 197VprocMonitor 197VProcNo 162VProcType 162WD ID 342WDId 138WLC ID 330WLC Name 330XActCount 127

result rowsAbortCnt 383AbortStatus 222ActElapsedTime 281Active 386ActiveQueryCnt 383

ActRowCount 281AMPAvgCPU 298AMPAvgDisk 298AMPAvgDiskIO 298AmpCount 242, 248, 273AMPCPUSec 235, 267AMPIO 235, 267AMPState 235, 266Arrivals 383AvgAmpCPUSec 241, 273AvgAmpIOCnt 242, 273AvgCPU 258AvgCPUTime 383AvgDelayTime 383AvgDisk 258AvgDiskIO 258AvgRespTime 383BlkxHostId 236, 267BlkxLmode 237, 269BlkxObjDBID 238, 270BlkxObjTID 238, 270BlkxOtype 238, 269BlkxSessNo 236, 268BlkxStatus 239, 270BlkxUserId 237, 268BlockingCnt 368CICUse 173, 252, 292ClusterNo 288Completions 383Confidence 281CPUCount 246CPUType 246CPUUse 170, 248, 289CurLvl1StepNo 279CurLvl2StepNo 279Date 361Delayed 387DelayedCnt 383DiskOutReqAvg 175, 251, 292DiskReads 173, 250, 291DiskSlice 286DiskUse 172, 250, 290DiskWrites 174, 251, 291DontReclassifyFlag 242, 274DueToDuration 365EnabledFlag 373ErrorCnt 383EstElapsedTime 281EstRowCount 281Event_Category 372EventActiveDate 364EventActiveTime 364EventId 364EventKind 361

Page 449: Workload management api

Index

Workload Management API: PM/API and Open API 449

EventStatus 364ExceptionCnt 383ExpActiveDate 364ExpActiveTime 364ExpressionId 364ExpressionStatus 364FCVprocIdx 229Filter_Category 372FlowControl 228HiCPUAMPNo 299HiCPUAMPProc 300HiCPUAMPUse 299HiCPUPENo 302HiCPUPEProc 302HiCPUPEUse 301HiDiskAMP 299HiDiskAMPIO 299HiDiskAMPIONo 299HiDiskAMPIOProc 300HiDiskAMPNo 299HiDiskAMPProc 300HighAMP1InUseCount 228HighAMP1VprocId 228HighAMP2InUseCount 228HighAMP2VprocId 228HighAMP3InUseCount 228HighAMP3VprocId 228HighAMP4InUseCount 228HighAMP4VprocId 228HighAMP5InUseCount 228HighAMP5VprocId 228HighCPUProcId 259HighCPUUse 258HighDisk 258HighDiskIO 258HighDiskIOProcId 259HighDiskProcId 259HostId 221, 233, 264, 279, 281, 283, 285, 368, 370HostId/ClusterNo 170HotAmp1CPU 239, 271HotAmp1CPUId 240, 271HotAmp1IO 240, 271HotAmp1IOId 240, 272HotAmp2CPU 239, 271HotAmp2CPUId 240, 271HotAmp2IO 240, 271HotAmp2IOId 240, 272HotAmp3CPU 240, 271HotAmp3CPUId 240, 271HotAmp3IO 240, 271HotAmp3IOId 240, 272HstBlkRds 176, 253, 293HstBlkWrts 176, 253, 293IntervalCount1 228

IntervalCount2 228IntervalCount3 228IntervalCount4 228LoCPUAMPNo 300LoCPUAMPProc 301LoCPUAMPUse 300LoCPUPENo 302LoCPUPEProc 302LoCPUPEUse 302LoDiskAMP 300LoDiskAMPIO 300LoDiskAMPIONo 301LoDiskAMPIOProc 301LoDiskAMPNo 301LoDiskAMPProc 301LogonPENo 233, 265LogonSource 239, 271LogonTime 233, 265LowAmp1CPU 240, 272LowAmp1CPUId 241, 272LowAMP1InUseCount 228LowAmp1IO 241, 272LowAmp1IOId 241, 273LowAMP1VprocId 228LowAmp2CPU 240, 272LowAmp2CPUId 241, 272LowAMP2InUseCount 229LowAmp2IO 241, 272LowAmp2IOId 241, 273LowAMP2VprocId 229LowAmp3CPU 241, 272LowAmp3CPUId 241, 272LowAMP3InUseCount 229LowAmp3IO 241, 272LowAmp3IOId 241, 273LowAMP3VprocId 229LowAMP4InUseCount 229LowAMP4VprocId 229LowAMP5InUseCount 229LowAMP5VprocId 229LowCPUProcId 259LowCPUUse 259LowDisk 259LowDiskIO 259LowDiskIOProocId 260LowDiskProcId 259LSN 234, 265MaxCPUTime 383MaxRespTime 383MemAgings 255MemAllocateKB 254MemAllocates 254MemFailures 255MetSLGCnt 383

Page 450: Workload management api

Index

450 Workload Management API: PM/API and Open API

MinCPUTime 383MinRespTime 383MoreBlockers 239, 270NetAUp 260NetAUse 252NetBUp 260NetBUse 252NetReads 180, 252, 294NetUse 260NetWrites 181, 252, 294NewStatus 360NumOfSteps 279NVMemAgings 255NVMemAllocate 255NVMemAllocSegs 4, 182, 255, 295ObjectId 361ObjectName 361, 386ObjectStatus 361ObjectType 361, 386OverRidable 368, 370PartName 233, 265PctAMPWT 179, 290PctDispatcher 180, 292PctParser 179, 292PctService 178, 289PEAvgCPU 301PECount 248PECPUsec 234, 266PEstate 233, 265PrcntKernel 249PrcntService 249PrcntUser 249Precedence 361PriorStatus 360ProcId 170, 245, 248, 285, 288QBName 397QBValue 397RecordId 364RecordStatus 365RecordType 364ReleaseNum 260, 303ReqCacheHits 234, 266ReqCount 234, 266ReqCPU 242, 273ReqIO 242, 273ReqNo 242, 273ReqSpool 267ReqStartTime 242, 273RequestNo 368ResLogging 260ResMonitor 260RuleID 370RuleSetId 372, 373RunVprocNo 233, 265

SeqNum 284SesMonitorLoc 303SesMonitorSys 302SessionCnt 302SessionNo 221, 233, 264, 279, 281, 283, 368, 370SessRunCount 172, 289SQLStep 281SQLText 284StateActiveDate 365StateActiveTime 365Status 171, 245, 248, 286, 288StepNum 281Subname 386TempSpaceUsg 242, 273Throttle_Category 372ThrottleLimit 387Time 362TimeHeld 368, 370UserAccount 234, 266UserId 234, 265UserName 221, 234, 265Username 368, 370UtilityCount 375UtilityLimit 375UtilityType 375Version 260, 303VprocLogging 303VprocMonitor 303VprocNo 170, 285, 288VprocType 169, 288Vproctype 285WDId 273, 368, 373, 383, 386WDName 368, 373WlcId 242Workload_Category 372XActCount 234, 266

resUsage tablesnode updates 17versus MONITOR PHYSICAL RESOURCE request 89versus MONITOR VIRTUAL RESOURCE request 167vproc updates 17

return valuesGetQueryBand 396IdentifyDatabase 223IdentifySession 224IdentifyTable 225IdentifyUser 226MonitorQueryBand 403MonitorSessionRate 276SetResourceRate 306SetSessionRate 310TDWMAbortDelayedRequest 353TDWMSummaryRate 384

REVOKE MONITOR command, SQL 40

Page 451: Workload management api

Index

Workload Management API: PM/API and Open API 451

RP 321description 321using Priority Scheduler 321using Teradata Dynamic Workload Management

workload definition 321RuleID result row 370rules, Teradata Dynamic Workload Management

filter 20throttle 20WD

RuleSetId result row 372, 373RunVprocNo response value 124RunVprocNo result row 233, 265

Ssample application, PM/API 405SampleSec response value 91, 169sampling interval, setting 16SeqNum result row 284SesMonitorLoc 17, 210SesMonitorLoc response value 196SesMonitorLoc result row 303SesMonitorSys 17SesMonitorSys rate 210, 310SesMonitorSys response value 196SesMonitorSys result row 302session, query band 22, 392SessionCnt result row 302session-level monitoring 18SessionNo response value 61, 124SessionNo result row 221, 233, 264, 279, 281, 283, 368, 370sessions

aborted 64blocked 64

sessions, monitoring 18SessRunCount result row 172, 289SET QUERY_BAND, SQL statement 22SET RESOURCE RATE request, PM/API 199

and MONITOR PHYSICAL RESOURCE 42, 106and MONITOR PHYSICAL SUMMARY 106and MONITOR VIRTUAL RESOURCE 42input data 199parcels 201privileges 201sample input 202sample output 202usage notes 200warning and error messages 202

SET SESSION ACCOUNT request, PM/API 204input data 204parcels 205sample input 206sample output 207

usage notes 205warning and error messages 207

SET SESSION ACCOUNT statement, SQL 345SET SESSION RATE request, PM/API 209

and MONITOR PHYSICAL SUMMARY 106input data 209, 214parcels 214privileges 209sample output 215scenarios 211, 212, 213, 214usage notes 209warning and error messages 215writing a Resource Supervisor 23writing an Idle Session Logoff 24

SetResourceRate function 305definition 305example 307input parameters 305return value 306usage notes 305

SetSessionAccount function 308definition 308examples 309input parameters 308return value 308usage notes 308

SetSessionRate function 310definition 310example 310input parameter 310return value 310usage notes 310

SQL commandsGRANT 40REVOKE MONITOR 40

SQL interfacesexamples 14query band 30requirements 31System PMPCTeradata Dynamic Workload Management 29using external stored procedures 395using UDFs 217, 395

SQL statementsALTER TABLE 57SET QUERY_BAND 22SET SESSION ACCOUNT 345

SQLStep result row 281SQLText result row 284state 19StateActiveDate result row 365StateActiveTime result row 365Status response value 85, 94, 162, 317Status result row 171, 245, 248, 286, 288

Page 452: Workload management api

Index

452 Workload Management API: PM/API and Open API

StepNum response value 150StepNum result row 281StepText response value 150, 151Subname result row 386SwapDrops response value 100SwapReads response value 99SwapWrites response value 99Syscon 359system conditions. See SysConSystem Performance Monitor and Production Control. See

System PMPCSystem PMPC

API examples 25CLIv2 interfaces 27, 50developing job control support applications 23features 16performing session-level monitoring 18performing system-level monitoring 18setting logging intervals 16setting sampling intervals 16SQL interfaces 27, 217

system tablesDBC.Dbase 69DBC.ResUsage 199DBC.SessionTbl 69, 205, 308DBC.Software_Event_LogV view 57, 83, 160, 201DBC.SW_Event_Log 39, 210DBC.TVM 69

system-level Monitoring 18SystemType response value 84, 161

TTDP internal sessions, identifying 55TDWM DELAY REQUEST CHANGE request, PM/API 325

input data 325parcels 326sample input 327sample output 327usage notes 326warning and error messages 327

TDWM LIST WD request, PM/API 329input data 329parcels 329sample input 330sample output 331usage notes 329warning and error messages 331

TDWM STATISTICS request, PM/API 333examples 336, 338, 339input data 333parcels 334usage notes 333warning and error messages 340

TDWM SUMMARY request, PM/APIinput data 341parcels 341sample input 343sample output 344usage notes 341warning and error messages 344

TDWM WD ASSIGNMENT request, PM/API 345input data 345parcels 346sample input 346sample output 347usage notes 345warning and error messages 347

TDWMAbortDelayedRequest function 353definition 353example 353input parameters 353return value 353usage notes 353

TDWMApply procedure 355definition 355example 356input parameters 355usage notes 355

TDWMAssignWD function 357definition 357example 358input parameters 357return value 357usage notes 357

TDWMEventControl procedure 359definition 359input parameters 359usage notes 359

TDWMEventMapping function 361definition 361example 362result rows 361usage notes 361

TDWMEventStatus function 363definition 363example 365input parameter 363result rows 364usage notes 363

TDWMGetDelayedQueries function 367definition 367examples 368input parameter 367result rows 368usage notes 367

TDWMGetDelayedUtilities function 370definition 370

Page 453: Workload management api

Index

Workload Management API: PM/API and Open API 453

example 371result rows 370

TDWMInquire function 372definition 372example 372result rows 372

TDWMListWDs function 373definition 373example 374input parameter 373result rows 373usage notes 373

TDWMLoadUtilStatistics function 375definition 375example 375result rows 375

TDWMObjectAssn procedure 376definition 376example 377input parameters 376

TDWMReleaseDelayedRequest function 378definition 378examples 378input parameters 378return value 378usage notes 378

TDWMRuleControl procedure 380definition 380example 380input parameters 380usage notes 380

TDWMSetLimits procedure 381definition 381example 381input parameter 381

TDWMSummary function 382definition 382example 383result rows 383usage notes 382

TDWMSummaryRate function 384definition 384example 384return value 384usage notes 384

TDWMThrottleStatistics function 385definition 385examples 387input parameter 385result rows 386usage notes 385

TDWMUserEventControl procedureactivating SysCon or OpEnv 359example 360

output parameters 360TempSpace response value 134TempSpaceUsg result row 242, 273Teradata DWM

enabling 139placing exclusive locks 376

Teradata Dynamic Workload ManagementCLIv2 interfaces 29, 312description 13enabling rules 205examples of PMPC APIs 25functionality 21regulating system events 19rules 20SQL interfaces 29, 352using events in Teradata DWM

Teradata Dynamic Workload Manager. See Teradata DWMTeradata SQL

keywords/reserved words 40versus PM/APIs 39

throttle 20Throttle_Category result row 372ThrottleLimit result row 387Time response value 315, 320Time result row 362TimeHeld result row 368, 370transaction, query band 22, 392

UUDFs

AbortListSessions 220AbortSession 218GetQueryBand 396GetQueryBandPairs 397IdentifyDatabase 223IdentifySession 224IdentifyTable 225IdentifyUser 226MonitorAWTResource 227MonitorMySessions 231MonitorPhysicalConfig 245MonitorPhysicalResource 247, 256MonitorPhysicalSummary 257MonitorQueryBand 403MonitorSession 262MonitorSessionRate 276MonitorSQLCurrentStep 278MonitorSQLSteps 280MonitorSQLText 283MonitorVirtualConfig 285MonitorVirtualResource 287MonitorVirtualSummary 297SetResourceRate 305

Page 454: Workload management api

Index

454 Workload Management API: PM/API and Open API

SetSessionAccount 308SetSessionRate 310TDWMAbortDelayedRequest 353TDWMAssignWD 357TDWMEventMapping 361TDWMEventStatus 363TDWMGetDelayedQueries 367TDWMGetDelayedUtilities 370TDWMInquire 372TDWMListWDs 373TDWMLoadUtilStatistics 375TDWMReleaseDelayedRequest 378TDWMSummary 382TDWMSummaryRate 384TDWMThrottleStatistics 385

UpAMPCount response value 137usage data, session level 42USER EVENT CONTROL request, PM/API 349

input data 349parcels 350response values 350usage notes 349warning and error messages 351

UserAccount response value 125UserAccount result row 234, 266User-Defined Event Status response value 350user-defined functions. See UDFsUserId response value 125UserId result row 234, 265UserName response value 61, 124UserName result row 221, 234, 265Username result row 368, 370USING Data String 33UtilityCount result row 375UtilityLimit result row 375UtilityType result row 375

VVersion response value 114, 197Version result row 260, 303virtual resource

logging rate 47monitoring rate 46

vproccollection rate 200logging rate 200resource usage monitoring 17ResUsage monitoring 17

Vproc Logging response value 197VProcLogging rate 200, 306VprocLogging result row 303VProcMonitor rate 200, 306VprocMonitor response value 197

VprocMonitor result row 303VProcNo response value 162VprocNo result row 170, 285, 288VProcType response value 162VprocType result row 169, 288Vproctype result row 285

WWarning messages, common 50WD 21WD ID response value 342WDId response value 138WDId result row 273, 368, 373, 383, 386WDName result row 368, 373WLC ID response value 330WLC Name response value 330WlcId result row 242work types

MSGWORKNEW 77MSGWORKONE 77

workload class. see WDworkload definition. See WDworkload management API

categories 27examples 25overview 13

Workload_Category result row 372

XXActCount response value 127XActCount result row 234, 266