DIAGNOSTIC SET SAMPLES - Teradata Database

SQL Data Manipulation Language

Product
Teradata Database
Release Number
15.10
Language
English (United States)
Last Update
2018-10-06
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata® Database

Instructs the Optimizer on the test system to use the random AMP samples from the target (production) system for emulations.

where:

 

Syntax element …

Specifies …

ALL

All random AMP statistical samples for the specified scope level are to be disabled.

target_system_
name

Name of the target (production) system to be emulated. For information on object naming, see SQL Fundamentals.

target_system_name is not case sensitive and can be up to 63 characters in length.

Names that contain pad characters or nonstandard characters must be enclosed in APOSTROPHE characters.

target_system_name must be defined in SystemFE.Opt_RAS_Table before you can perform this request.

NOT

Disable sample selection.

SESSION

Sample values for the target system are in effect for the duration of the current session until one of the following events occurs:

  • You log off the session
  • You restart the database
  • You change the samples in effect by performing the following request:
  •      DIAGNOSTIC SET SAMPLES target_system_name
         NOT ON FOR SESSION TABLE table_name

    SYSTEM

    Sample values for the target system are in effect for all sessions across all restarts and reboots until you perform the following request:

         DIAGNOSTIC SET SAMPLES target_system_name 
         NOT ON FOR SYSTEM TABLE table_name

    database_name

    Name of the database in which table_name is defined.

    If the name contains pad characters or non-standard characters, it must be demarcated by APOSTROPHE characters.

    table_name

    Name of the table for which random AMP sample statistics emulation is to be performed.

    If the name contains pad characters or non-standard characters, it must be demarcated by APOSTROPHE characters.

    DIAGNOSTIC SET SAMPLES is a Teradata extension to the ANSI SQL:2011 standard.

    You must have SELECT privileges on SystemFE.Opt_RAS_Table to set samples on or off.

    DIAGNOSTIC SET SAMPLES requires Target Level Emulation to be enabled in order to set scope level cost estimation data.

    For more information, see SQL Request and Transaction Processing.

    You cannot perform DIAGNOSTIC SET SAMPLES in ANSI session mode or within explicit transaction boundaries in Teradata session mode.

    Scope levels have a sequential precedence. The following table lists the precedence ratings for the various scope levels for DIAGNOSTIC SET SAMPLES:

     

    Precedence

    Option

    1

    SESSION

    2

    SYSTEM

    Note that DIAGNOSTIC SET SAMPLES does not offer scope levels of IFP or REQUEST.

    Random AMP statistical samples can be emulated for a maximum of 128 tables at a time per scope level.

    You cannot create or drop any of the following indexes for a table while that table is subject to random AMP sample emulation:

  • Hash (see “CREATE HASH INDEX” and “DROP HASH INDEX” in SQL Data Definition Language)
  • Join (see “CREATE JOIN INDEX” and “DROP JOIN INDEX” in SQL Data Definition Language)
  • Secondary (see “CREATE INDEX” and “DROP INDEX” in SQL Data Definition Language)
  • Otherwise, the system returns an error.

    To disable random AMP sampling, use the DIAGNOSTIC HELP SAMPLES request to determine which samples have been set, then use DIAGNOSTIC SET SAMPLES to disable them. See “DIAGNOSTIC HELP SAMPLES” on page 617.

    To use random AMP sampling on the table with the index change, you must use the following general procedure:

    1 Make the index change on the target system.

    2 Extract a fresh random AMP sample from the target system.

    3 Apply the fresh sample to the source system.

    The following examples require that a corresponding row exist in the SystemFE.Opt_RAS_Table with the column values listed below:

     

    Column Name

    Value Name

    System Name

    test_1

    Database Name

    employee

    Table Name

    payroll

    Enable the imported random AMP statistical samples for the payroll table in database employee on test machine test_1.

         DIAGNOSTIC SET SAMPLES test_1 
         ON FOR SESSION TABLE employee.payroll;

    Disable the imported random AMP statistical samples for the payroll table in database employee on test machine test_1.

         DIAGNOSTIC SET SAMPLES test_1 
         NOT ON FOR SESSION TABLE employee.payroll;

    Disable all random AMP statistical samples for all tables enabled at the SYSTEM scope level.

         DIAGNOSTIC SET ALL SAMPLES 
         NOT ON FOR SYSTEM;

    Disable all random AMP statistical samples for all tables enabled at the SESSION scope level.

         DIAGNOSTIC SET ALL SAMPLES 
         NOT ON FOR SESSION;

    For more information about random AMP samples, see:

  • “DIAGNOSTIC DUMP SAMPLES” on page 615
  • “DIAGNOSTIC HELP SAMPLES” on page 617
  • SQL Request and Transaction Processing