Home | Previous Page | Next Page   Monitoring Database Server Performance > Monitoring Sessions and Queries >

Monitoring Current Query Activity and Resource Use

Use the following tools to monitor DSS queries:

Monitoring Resource Use by All Concurrent Queries

Monitor the shared memory and thread resources that the database server has granted for queries. For information about how the database server allocates resources to queries, see Appendix B. How SQL Queries Are Executed.

Monitoring Query Activity

To monitor the resource use of currently executing queries, use ISA or the isatool utility commands. The information displayed helps you understand how user applications are using the database server and lets you identify sessions and queries that use more than their share of resources.

Tip:
For analyzing and tuning specific queries, execute the SET EXPLAIN ON statement before the query runs. When the query is complete, examine the output stored in sqexplain.out or the file that you specify. The detailed information provided in the output file combines information provided by many separate onstat commands. For examples of sqexplain.out files, see Interpreting SET EXPLAIN Output.

For information about tuning the configuration parameters that affect queries, see the following sections:

The following table lists command-line utilities for specific resource-monitoring purposes. Run the command-line utilities from the connection coserver, which is the coserver where the query originated.

Command
Description
onstat -g rgm
Displays information about RGM parameters and policies, as well the queries in the wait and active queues. This option displays RGM wait and active queue information for each query currently in the system.

Use this information to get a snapshot of current query status and resource use. Use the session ID to identify or request query information in other onstat command output.

For an output sample and more information, refer to Monitoring All Concurrent Queries.

onstat -g sql
Displays SQL statement information by session.

For more information, refer to Monitoring Current Session Activity and Resource Use.

xctl onstat -g xmp
Displays information about the query segments and SQL operators that are currently executing on each coserver. This information includes session IDs.

For more information, refer to Monitoring Query Segments and SQL Operators.

onstat -g xqs qryid
Displays query statistics for a specific query plan. Obtain the value for qryid from the output of the onstat -g rgm or onstat -g xmp commands.

SET EXPLAIN output also displays query-plan information, as discussed in Using Command-Line Utilities to Monitor Query Execution.

For more information, refer to Monitoring SQL Operator Statistics.

onstat -g xqp qryid
Displays summary information about a specific query plan. Obtain the value for qryid from the output of the onstat -g rgm or onstat -g xmp commands.

For more information, refer to Monitoring Query Plans.

xctl onstat -u and xctl onstat -g ath
Display user threads and transactions on all coservers, listed by coserver.

For more information, refer to Monitoring User Threads and Transactions.

Monitoring All Concurrent Queries

Use ISA or onstat -g rgm to display information about waiting and executing queries.

Figure 13. Sample onstat -g rgm Output
Resource Grant Manager (RGM)
============================

DS_ADM_POLICY:                      FAIR
DS_MAX_QUERIES:                     32
MAX_PDQPRIORITY:                    100
DS_TOTAL_MEMORY:                    4096 KB
DS_TOTAL_TMPSPACE:                  1600 KB

Coserver Capabilities
-----------------------------------------------------------
                          Number cosvrs   Active/Enabled      
Total cosrvs              2               2                   
Compute Capable cosvrs    2               2                   
TempData Capable cosvrs   2               2                   
-----------------------------------------------------------

DS Total Memory Across Coservers:   8192 KB

Queries:   Waiting    Active 
           0          2 

Memory:    Total      Free    
(KB)       8192       7680    

RGM Wait Queue:   (len = 0)
---------------
No waiting queries.

RGM Active Queue: (len = 1)
-----------------
Lvl  Session  Plan  PdqPrio     Memory (KB) #Cosvrs Local Cosvr Tmp Limit  Tmp Quota (Kb)
50   1.14     3     75.00-75.00 6144           2                NO LIMIT        - 
50   1.20     6     5.00-5.00    512           2                    1.00 %     16 

Figure 13 shows the output of onstat -g rgm. The first output section displays the following information.

Field Name
Description
DS_ADM_POLICY
Whether the RGM uses the STRICT or FAIR admission policy for scheduling queries
DS_MAX_QUERIES
The maximum number of RGM-managed queries that can run concurrently on the database server
MAX_PDQPRIORITY
The percent of DS_TOTAL_MEMORY available for a single query
DS_TOTAL_MEMORY
The maximum amount of memory that can be granted for use by RGM-managed queries on each coserver
DS_TOTAL_TMPSPACE
The amount of temporary space available on each coserver for operator overflow for a single query

The second output section displays the following coserver capability information.

Field Name
Description
Total cosrvs
The total number of coservers in the database server, both specific-purpose and fully capable coservers. For information about coserver capabilities, refer to the IBM Informix: Extended Parallel Server Administrator's Guide.
Compute Capable cosrvs
The number of coservers configured for compute capabilities. Fully capable coservers are included.
TempData Capable cosrvs
The number of coservers configured for temporary data capabilities. Fully capable coservers are included.

The third output section displays the following query information.

Column Name
Description
Active
The number of RGM-managed queries that are currently executing
Waiting
The number of RGM-managed queries that are ready to run but are waiting for sufficient memory or for admission-control reasons

The fourth output section displays memory use.

Column Name
Description
Total
The kilobytes of memory available for use by queries that require parallel processing. To calculate this total, RGM multiplies the DS_TOTAL_MEMORY value by the number of coservers defined in your ONCONFIG file that are currently initialized.
Free
The kilobytes of memory currently available

The fifth and sixth output sections list the queries in the Wait and Active queues. The following information appears for each query in the Active queue.

Column Name
Description
Lvl
The scheduling level for the query
Session
The global session ID for the session that initiated the query

The global session ID has the following format:

coserver_number.local-id

Plan
The query plan ID
PdqPrio
The PDQPRIORITY range requested for the query

If SET ENVIRONMENT IMPLICIT_PDQ is in effect for the session that initiated the query, memory is estimated by the optimizer. For information, see Enabling Optimizer-Determined Memory Allocation

Memory
The number of kilobytes of memory currently granted to the query
#Cosvrs
The number of coservers that are executing the query
Local Cosvr
For local queries, displays the coserver on which the query requires memory
Tmp Limit
If temporary space limits are enable for this session, the percent of the temporary space limit the query can use
Tmp Quota
The value of DS_TOTAL_TMPSPACE configuration parameter, which specifies the temporary space allowed for query operator overflow. For information, see Limiting Temporary Space for Individual Query Overflow.

If temporary space limits are not enabled for this session, NO LIMIT appears even if DS_TOTAL_TMPSPACE is set in the configuration file. For information about enabling temporary space limits for query overflow, see Limiting Temporary Space for Query-Operator Overflow

For queries in the Wait queue, the following information appears instead of memory-grant and temporary-space information.

Column Name
Description
Candidate
An asterisk (*) marks the next query to run
Wait Time
The number of seconds the query has been waiting

Using Command-Line Utilities to Monitor Query Execution

As queries execute, you can use ISA and onstat command options to monitor their current activity. The following sections describe the onstat command options and provide output samples where appropriate.

Monitoring Query Segments and SQL Operators

Use the xctl onstat -g xmp option to display information about the query segments and SQL operators that are currently executing on a coserver.

Figure 14 shows the XMP Query Segments section and the XMP Query Operators section of onstat -g xmp output on both coservers.

Figure 14. onstat -g xmp Query Segments Section
   

XMP Query Segments
segid  width  numbr  qryid  sessid    flags      seqno 
0      1      1      16        1.36    0x11a      1     
3      2      1      16        1.36    0x118      3     

XMP Query Operators
opaddr     qry  segid branch brtid opname  phase  rows   in1        in2       
0xb3147f8  16   3     0-0    133   xchg    create 0      0xb314940  0x0       
0xb314940  16   3     0-0    133   group   create 0      0xb3171f8  0x0       
0xb3171f8  16   3     0-0    133   hjoin   overflow 2305 0xb317310  0xb317538 
0xb317310  16   3     0-0    133   xchg    done   1489   0x0        0x0       
0xb317538  16   3     0-0    133   xchg    done   4973   0x0        0x0 

Figure 14 shows the first section of onstat -g xmp, which contains Query Segments information.

Column Name
Description
segid
The ID of the segment within a plan
width
The number of instances for this branch for the entire plan, not just this coserver
numbr
The branch ID within the segment
qryid
The plan ID

Use this value for the onstat -g xqp qryid and onstat -g xqs qryid commands.

sessid
The global session ID for the user
flags
The processing flags for the segment
seqno
The sequence number, which represents the order that the segment within the plan was activated for execution

The second section of the display shows information about the SQL operators that the query uses. For information about interpreting query operator information, see Interpreting SQL Operator Runtime Data in the Query Plan and Interpreting SET EXPLAIN Output.

Field Name
Description
opaddr
The in-memory address of operator structure

This information helps to associate in1 and in2 values with other operators

qry
The plan ID for the query
segid
The ID for the segment within a plan
branch
The ID for the branch within the segment
brtid
The thread ID that is executing the branch instance
opname
The type of SQL operator
phase
The processing phase of SQL operator
rows
The number of rows that this SQL operator processed
in1/in2
The address of SQL operators

Operators are constructed into tree structures, and in1 and in2 represent linkage operators. A 0x0 value represents no child.

Monitoring Query Plans

Use the xctlonstat -g xqp qryid option to display summary information about a specific query plan while the query is executing. A plan can be displayed only from the connection coserver, which is the coserver where the sqlexec thread is running.

The database server uses SQL operators and exchanges to divide a query plan into segments and construct a tree of operators. The onstat -g xqp command displays this operator tree in the order of execution. The order of the operators in the output of the onstat -g xqp command is the same as in the output for the SQL statement SET EXPLAIN ON. For information about SQL operators, refer to Interpreting SQL Operator Runtime Data in the Query Plan. For information about the output of SET EXPLAIN ON, refer to Interpreting SET EXPLAIN Output.

To display the query plan summary for query plan 17, enter following command:

onstat -g xqp 17

Figure 15 shows the output for the preceding command.

Figure 15. Sample onstat -g xqp Output for Query Plan 17
XMP Query Plan

  oper       segid  brid   width  misc info 
  -----------------------------------------
  scan       4      0      2      dist
  scan       5      0      2      orders
  hjoin      3      0      2      
  group      3      0      2      
  group      2      0      2      
  sort       1      0      2 

This onstat -g xqp display shows the following query-plan information.

Column Name
Description
oper
The type of SQL operator

For more information on the types of SQL operators, refer to Interpreting SQL Operator Runtime Data in the Query Plan.

segid
The ID of the segment within a plan that contains the operator
brid
The branch ID within the segment that contains the operator
width
The number of instances of this branch in the query plan

Multiple instances can exist for each branch because the SQL operator can execute in parallel on multiple fragments of a table.

misc info
The names of scanned tables
Monitoring SQL Operator Statistics

You can use the onstat -g xqs qryid option to display query statistics for a specific query plan. A plan is available for display only on the connection coserver, which is the coserver on which the sqlexec thread is running.

A query plan is made up of SQL operators and exchanges. The onstat -g xqs command displays this operator tree in the order of execution. The following information appears for each SQL operator instance:

The onstat -g xqs command displays statistics for all currently active query plans. The statistics reported by onstat -g xqs are updated periodically as the query runs, and might not reflect the current state of the query. Some information, such as overflow information, might not be useful until the query is complete. The final statistics for the query appear in the sqexplain.out file if you run SET EXPLAIN ON before you run the query.

The following sample command displays SQL operator statistics for query plan ID 17:

onstat -g xqs 17

Figure 16 shows the output for the preceding command.

Figure 16. Sample onstat -g xqs Output for Query Plan 17
XMP Query Statistics

 Cosvr_ID: 1     
 Plan_ID: 17  

  type  segid brid information
  ----  ----- ---- -----------
  scan   4    0    inst cosvr time   rows_prod  rows_scan
                   ---- ----- ----   ---------  ---------
                   0    1     1      1481       1481      
                   1    2     1      1519       1519      
                   --------------------------------------
                   2                 3000       3000      

  scan   5    0    inst cosvr time   rows_prod  rows_scan
                   ---- ----- ----   ---------  ---------
                   0    1     0      6423       6423      
                   1    2     0      3577       3577      
                   --------------------------------------
                   2                 10000      10000     

  hjoin  3    0    inst cosvr time   rows_prod  rows_bld   rows_probe  mem        ovfl  tmp
                   ---- ----- ----   ---------  --------   ----------  ---        ----  ---
                   0    1     12     4941       1489       4973        552        808   214 
                   1    2     12     4993       1511       5027        568        832   222 
                   ------------------------------------------------------------------------
                   2                 9934       3000       10000       (384)

  group  3    0    inst cosvr time   rows_prod  rows_cons   mem        ovfl  tmp
                   ---- ----- ----   ---------  ---------   ---        ----  ---
                   0    1     12     112        4941        48         0     0   
                   1    2     12     112        4993        48         0     0   
                   -------------------------------------------------------------
                   2                 224        9934        (256)

  group  2    0    inst cosvr time   rows_prod  rows_cons   mem        ovfl  tmp
                   ---- ----- ----   ---------  ---------   ---        ----  ---
                   0    1     0      63         126         32         0     0   
                   1    2     0      49         98          16         0     0   
                   -------------------------------------------------------------
                   2                 112        224         (256)
  sort   1    0    inst cosvr time   rows
                   ---- ----- ----   ----
                   0    1     0      62
                   1    2     0      50
                   ----------------------

The onstat -g xqs output in Figure 16 shows the following SQL operator statistics.

Field Name
SQL Operator Statistics
type
The type of SQL operator
segid
The ID of the segment within a query plan that contains the operator
brid
The branch ID within the segment that contains the operator
operator information
SQL operator-specific statistics, including the time for each SQL operator instance, the number of kilobytes of memory required to build the hash table, and the number of partitions written as overflow to temporary space. If -1 appears in the Mem or Ovfl columns, no hash table was built.

For information about these SQL operator-specific statistics, refer to Interpreting SQL Operator Runtime Data in the Query Plan.

The order of the operators in the output of the onstat -g xqs command is the same as in the output of SET EXPLAIN and onstat -g xmp.

Monitoring User Threads and Transactions

Each decision-support query has a primary thread on the connection coserver. This primary thread can start additional threads to perform tasks for the query, such as scans and sorts.

For information about all the threads that are running for a decision-support query, use the xctl onstat -u and xctl onstat -g ath options. The xctl onstat -u option lists primary thread and any additional threads that are executing queries on participating coservers. The output of the onstat -u command on a specific coserver lists only the threads on that specific coserver.

The thread information shows what threads each session is running, how busy each thread is, and how many locks each thread holds.

For example, session 10 in Figure 17 has a total of five threads running.

Figure 17. onstat -u Output
Userthreads
address  flags   sessid   user     tty      wait     tout locks nreads
nwrites
80eb8c   ---P--D 0        informix -        0        0    0     33     19
80ef18   ---P--F 0        informix -        0        0    0     0      0
80f2a4   ---P--B 3        informix -        0        0    0     0      0
80f630   ---P--D 0        informix -        0        0    0     0      0
80fd48   ---P--- 45       chrisw   ttyp3    0        0    1     573    237
810460   ------- 10       chrisw   ttyp2    0        0    1     1      0
810b78   ---PR-- 42       chrisw   ttyp3    0        0    1     595    243
810f04   Y------ 10       chrisw   ttyp2    beacf8   0    1     1      0
811290   ---P--- 47       chrisw   ttyp3    0        0    2     585    235
81161c   ---PR-- 46       chrisw   ttyp3    0        0    1     571    239
8119a8   Y------ 10       chrisw   ttyp2    a8a944   0    1     1      0
81244c   ---P--- 43       chrisw   ttyp3    0        0    2     588    230
8127d8   ----R-- 10       chrisw   ttyp2    0        0    1     1      0
812b64   ---P--- 10       chrisw   ttyp2    0        0    1     20     0
812ef0   ---PR-- 44       chrisw   ttyp3    0        0    1     587    227
 15 active, 20 total, 17 maximum concurrent

P in the fourth flags column indicates the primary thread for a session. The code in the first flags column indicates why a thread is waiting. The possible flag codes are as follows.

Flag Code
Event for Which Thread Is Waiting
B
Buffer
C
Checkpoint
G
Logical-log write
L
Lock
S
Mutex
T
Transaction
Y
Condition
X
Rollback
DEFUNCT
The thread has incurred a serious assertion failure and has been suspended to allow other threads to continue their work. If this status flag appears, refer to the appendix in the IBM Informix: Extended Parallel Server Administrator's Reference that explains thread suspension.

The onstat -g ath option display also lists the primary thread and secondary threads on the connection coserver and participating coservers. In addition, it includes a name column that describes the activity of the thread, as Figure 18 shows.

Figure 18. onstat -g ath Output
Threads:
tid     tcb     rstcb   prty    status                  vp-class name
5       40067294 0        4     sleeping(secs: 0)         1cpu   xmf_svc
12      407c85e8 0        2     running                   5aio   aio vp
38      40a0deec 4006bdd0 2     sleeping(secs: 49)        1cpu   btclean
40      409e5c84 4006c540 4     sleeping(secs: 1)         1cpu   onmode_mon
128129  40b97788 4006df48 2     sleeping(secs: 1)         1cpu    
   sqlexec_1.3567
128130  4138187c 4006f598 2     sleeping(Forever)         1cpu 
   x_exec_1.3567
128134  40b01d18 4006d420 2     ready                     1cpu    x_hjoin_0
128136  408cd1a0 4006fd08 2     sleeping(Forever)         1cpu    x_scan_0
128137  408cd3cc 4006f950 2     running                   1cpu    x_scan_4
128138  904510d4 4006e6b8 2     sleeping(Forever)         1cpu    x_scan_8

Figure 18 output lists the following items:

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]