SQL

Updated at:

This topic describes the views available in PolarDB for PostgreSQL (Compatible with Oracle). You can query these views to obtain SQL information and identify performance issues.

SQL

You can query the views described in this topic to obtain SQL information.

  • pg_stat_statements
    Note The pg_stat_statements view depends on the pg_stat_statements extension. You must create this extension by running the create extension pg_stat_statements command.
    ParameterTypeDescription
    useridoidThe OID of the user who executed the statement.
    dbidoidThe OID of the database in which the statement was executed.
    queryidbigintThe internal hash code calculated from the parse tree of the statement.
    querytextThe text of the statement.
    callsbigintThe number of times the statement was executed.
    total_timedouble precisionThe total time spent in the statement, in milliseconds.
    min_timedouble precisionThe minimum time spent in the statement, in milliseconds.
    max_timedouble precisionThe maximum time spent in the statement, in milliseconds.
    mean_timedouble precisionThe average time spent in the statement, in milliseconds.
    stddev_timedouble precisionThe population standard deviation of the time spent in the statement, in milliseconds.
    rowsbigintThe total number of rows retrieved or affected by the statement.
    shared_blks_hitbigintThe total number of shared block cache hits by the statement.
    shared_blks_readbigintThe total number of shared blocks read by the statement.
    shared_blks_dirtiedbigintThe total number of shared blocks dirtied by the statement.
    shared_blks_writtenbigintThe total number of shared blocks written by the statement.
    local_blks_hitbigintThe total number of local block cache hits by the statement.
    local_blks_readbigintThe total number of local blocks read by the statement.
    local_blks_dirtiedbigintThe total number of local blocks dirtied by the statement.
    local_blks_writtenbigintThe total number of local blocks written by the statement.
    temp_blks_readbigintThe total number of temporary blocks read by the statement.
    temp_blks_writtenbigintThe total number of temporary blocks written by the statement.
    blk_read_timedouble precisionThe total time the statement spent reading blocks, in milliseconds. This value is 0 if track_io_timing is disabled.
    blk_write_timedouble precisionThe total time the statement spent writing blocks, in milliseconds. This value is 0 if track_io_timing is disabled.
  • polar_stat_sql
    Note The `polar_stat_sql` view depends on the polar_stat_sql extension. You can submit a ticket to create this extension, which also serves as an extension to pg_stat_statements.
    ParameterTypeDescription
    queryidbigintThe query ID.
    datnamenameThe database name.
    rolnamenameThe username.
    user_timedoubleThe time spent in user mode.
    system_timedoubleThe time spent in system mode.
    minfltsbigintThe number of page reclaims (soft page faults).
    majfltsbigintThe number of page faults (hard page faults).
    nswapsbigintThe number of swaps.
    readsbigintThe number of bytes read from the disk.
    reads_blksbigintThe number of blocks read from the disk.
    writesbigintThe number of bytes written to the disk.
    writes_blksbigintThe number of blocks written to the disk.
    msgsndsbigintThe number of Inter-Process Communication (IPC) messages sent.
    msgrcvsbigintThe number of IPC messages received.
    nsignalsbigintThe number of semaphore acquisitions.
    nvcswsbigintThe number of voluntary context switches.
    nivcswsbigintThe number of involuntary context switches.
    scan_rowsdoubleThe number of rows read by the scan node.
    scan_timedoubleThe running time of the scan node.
    scan_countbigintThe number of executions of the scan node.
    join_rowsdoubleThe number of rows read by the join node.
    join_timedoubleThe running time of the join node.
    join_countbigintThe number of executions of the join node.
    sort_rowsdoubleThe number of rows read by the sort node.
    sort_timedoubleThe running time of the sort node.
    sort_countbigintThe number of executions of the sort node.
    group_rowsdoubleThe number of rows read by the group node.
    group_timedoubleThe running time of the group node.
    group_countbigintThe number of executions of the group node.
    hash_rowsdoubleThe number of rows read by the hash node.
    hash_memorybigintThe memory used by the hash node, in bytes.
    hash_countbigintThe number of executions of the hash node.
    parse_timedoubleThe parsing time.
    analyze_timedoubleThe analysis time.
    rewrite_timedoubleThe rewrite time.
    plan_timedoubleThe time to generate the execution plan.
    execute_timedoubleThe running time.
    lwlock_waitdoubleThe lwlock wait time.
    rel_lock_waitdoubleThe table lock wait time.
    xact_lock_waitdoubleThe transaction lock wait time.
    page_lock_waitdoubleThe page lock wait time.
    tuple_lock_waitdoubleThe row lock wait time.
    shared_read_psbigintThe read IOPS.
    shared_write_psbigintThe write IOPS.
    shared_read_throughputbigintThe read throughput, in bytes.
    shared_write_throughputbigintThe write throughput, in bytes.
    shared_read_latencydoubleThe read latency, in microseconds.
    shared_write_latencydoubleThe write latency, in microseconds.
    io_open_numbigintThe number of file open operations.
    io_seek_countbigintThe number of file seek operations.
    io_open_timedoubleThe time spent on file open operations, in microseconds.
    io_seek_timedoubleThe time spent on file seek operations, in microseconds.
  • polar_stat_query_count
    Note The polar_stat_query_count view depends on the polar_stat_sql plugin. You can submit a ticket to create this plugin.
    The following table describes the parameters.
    ParameterTypeDescription
    sqltypetextSQL Type: DQLDMLDDLDCL
    cmdtypetextSQL command type: SELECTINSERTUPDATE, ...
    countbigintThe total number of executions.