This topic describes the views of PolarDB for PostgreSQL(Compatible with Oracle). You can query views to obtain information about SQL statements. This way, you can identify performance issues.
SQL
To obtain information about SQL statements, you can query the views that are described in this topic.
- pg_stat_statementsThe following table describes the parameters in this view.Note To use the pg_stat_statements view, you must create the
pg_stat_statementsplug-in by executing the create extension pg_stat_statements statement.Parameter Type Description useridoid The object identifier (OID) of the user who executes the SQL statement. dbidoid The OID of the database in which the SQL statement is executed. queryidbigint The internal hash code calculated based on the parse tree of the SQL statement. querytext The text of the SQL statement. callsbigint The number of SQL statements that are executed. total_timedouble precision The total time consumed to execute the SQL statement. Unit: milliseconds. min_timedouble precision The shortest time consumed to execute the SQL statement. Unit: milliseconds. max_timedouble precision The longest time consumed to execute the SQL statement. Unit: milliseconds. mean_timedouble precision The average time consumed to execute the SQL statement. Unit: milliseconds. stddev_timedouble precision The population standard deviation of the time consumed to execute the SQL statement. Unit: milliseconds. rowsbigint The total number of rows retrieved or affected by the SQL statement. shared_blks_hitbigint The total number of shared-block cache hits by the SQL statement. shared_blks_readbigint The total number of shared blocks read by the SQL statement. shared_blks_dirtiedbigint The total number of shared blocks dirtied by the SQL statement. shared_blks_writtenbigint The total number of shared blocks written by the SQL statement. local_blks_hitbigint The total number of local-block cache hits by the SQL statement. local_blks_readbigint The total number of local blocks read by the SQL statement. local_blks_dirtiedbigint The total number of local blocks dirtied by the SQL statement. local_blks_writtenbigint The total number of local blocks written by the SQL statement. temp_blks_readbigint The total number of temporary blocks read by the SQL statement. temp_blks_writtenbigint The total number of temporary blocks written by the SQL statement. blk_read_timedouble precision The total time consumed to read blocks. Unit: milliseconds. This parameter is valid only if the track_io_timing parameter is set to on. Otherwise, zero is returned. blk_write_timedouble precision The total time consumed to write blocks. Unit: milliseconds. This parameter is valid only if the track_io_timing parameter is set to on. Otherwise, zero is returned. - polar_stat_sqlThe following table describes the parameters in this view.Note To use the polar_stat_sql view, you must create the
polar_stat_sqlplug-in by executing the create extension polar_stat_sql statement. The polar_stat_sql view can be used as an extension of thepg_stat_statementsview.Parameter Type Description queryidbigint The ID of a query. datnamename The name of the database. rolnamename The username. user_timedouble The period when the user mode is used. system_timedouble The period when the system mode is used. minfltsbigint The number of recycled pages or minor faults. majfltsbigint The number of major page faults. nswapsbigint The number of page swaps. readsbigint The number of bytes read from disks. reads_blksbigint The number of blocks read from disks. writesbigint The number of bytes written to disks. writes_blksbigint The number of blocks written to disks. msgsndsbigint The number of IPC messages that are sent. msgrcvsbigint The number IPC messages that are received. nsignalsbigint The number of semaphores that are received. nvcswsbigint The number of voluntary context switches. nivcswsbigint The number of involuntary context switches. scan_rowsdouble The number of rows read by scan node operations. scan_timedouble The time consumed to perform scan node operations. scan_countbigint The number of scan node operations. join_rowsdouble The number of rows read by join node operations. join_timedouble The time consumed to perform join node operations. join_countbigint The number of join node operations. sort_rowsdouble The number of rows read by sort node operations. sort_timedouble The time consumed to perform sort node operations. sort_countbigint The number of sort node operations. group_rowsdouble The number of rows read by group node operations. group_timedouble The time consumed to perform group node operations. group_countbigint The number of group node operations. hash_rowsdouble The number of rows read by hash node operations. hash_memorybigint The memory used by hash node operations. Unit: bytes. hash_countbigint The number of hash node operations. parse_timedouble The time consumed to parse the SQL statement. analyze_timedouble The time consumed to analyze the SQL statement. rewrite_timedouble The time consumed to rewrite the SQL statement. plan_timedouble The time consumed to generate the execution plan. execute_timedouble The time at which the recorded SQL statement was executed. lwlock_waitdouble The lwlock wait time. rel_lock_waitdouble The wait time for table locks. xact_lock_waitdouble The wait time for transaction locks. page_lock_waitdouble The wait time for page locks. tuple_lock_waitdouble The wait time for row locks. shared_read_ps bigint The read IOPS. shared_write_ps bigint The write IOPS. shared_read_throughput bigint The read throughput. Unit: bytes. shared_write_throughput bigint The write throughput. Unit: bytes. shared_read_latency double The read latency. Unit: microseconds. shared_write_latency double The write latency. Unit: microseconds. io_open_num bigint The number of open file operations. io_seek_count bigint The number of seek file operations. io_open_time double The time consumed to perform open file operations. Unit: microseconds. io_seek_time double The time consumed to perform seek file operations. Unit: microseconds. - polar_stat_query_countThe following table describes the parameters in this view.Note To use the polar_stat_query_count view, you must create the
polar_stat_sqlplug-in by executing the create extension polar_stat_sql statement.Parameter Type Description sqltypetext The SQL type. Valid values: DQL, DML, DDL, and DCL. cmdtypetext The SQL statement type. Examples: SELECT, INSERT, and UPDATE. countbigint The total number of executions.