16.10 - How to Use DBQL - Teradata Database

Teradata Database Administration

Product
Teradata Database
Release Number
16.10
Release Date
April 2018
Content Type
Administration
Publication ID
B035-1093-161K
Language
English (United States)

To use DBQL:

  1. Grant the proper privileges to your administrative user for query logging. See Granting DBQL Administrative Privileges to Other Users.
  2. Determine what type of information you want to collect. This chapter lists the descriptions of each field in each DBQL log. Use the descriptions to get an idea of what type of information you want to collect and then look at the options you can employ to control the type of details and the amount of data logged. The options are discussed in WITH Logging Options and LIMIT Logging Options.
  3. Determine what you want to collect data for. Create DBQL rules to log queries of a user, group of users, an account, a list of accounts, or an application.

    Teradata recommends creating rules for accounts so that queries will be logged for any user who logs in under that account.

  4. Run the Database Initialization Program (DIP) script DIPPDCR to create archival tables for longer-term storage of DBQL and other performance data. DIPPDCR also creates the data extraction macros that populate these tables.
  5. Run the Viewpoint portlet Performance Data Collection to set up a recurring daily DBQL job. This job moves data from the DBQL log tables in DBC to the archival tables in the PDCRDATA database.
  6. Use the BEGIN QUERY LOGGING statement to create logging rules or use the REPLACE QUERY LOGGING statement to replace existing logging rules with new logging rules. Teradata recommends using scripts to enable and disable logging to avoid typographical errors.
    You must have the EXECUTE privilege on the DBC.DBQLAccessMacro macro to enable or disable DBQL logging. That is, you must have this privilege to submit the BEGIN QUERY LOGGING, REPLACE QUERY LOGGING, and END QUERY LOGGING statements.

    As users establish sessions and submit queries, DBQL will automatically enable rules according to the Best Fit Hierarchy. (See Best Fit Rule Hierarchy.)

    DBQL collects query information into a data cache based on rules you specify, flushes the cache periodically (see Options for Flushing the DBQL Cache), and writes the information to the DBQL dictionary tables. This information includes historical records of queries and their duration, performance data, and target activity.

  7. Upon examining the query log data, you may decide you need to adjust rules. You can use the REPLACE QUERY LOGGING statement to replace or delete existing rules using the END QUERY LOGGING statement.