mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
f0d6f20278
This change allows us to eliminate the previous limit on stored query length, and it makes the shared-memory hash table very much smaller, allowing more statements to be tracked. (The default value of pg_stat_statements.max is therefore increased from 1000 to 5000.) In typical scenarios, the hash table can be large enough to hold all the statements commonly issued by an application, so that there is little "churn" in the set of tracked statements, and thus little need to do I/O to the file. To further reduce the need for I/O to the query-texts file, add a way to retrieve all the columns of the pg_stat_statements view except for the query text column. This is probably not of much interest for human use but it could be exploited by programs, which will prefer using the queryid anyway. Ordinarily, we'd need to bump the extension version number for the latter change. But since we already advanced pg_stat_statements' version number from 1.1 to 1.2 in the 9.4 development cycle, it seems all right to just redefine what 1.2 means. Peter Geoghegan, reviewed by Pavel Stehule
45 lines
1.3 KiB
SQL
45 lines
1.3 KiB
SQL
/* contrib/pg_stat_statements/pg_stat_statements--1.2.sql */
|
|
|
|
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
|
\echo Use "CREATE EXTENSION pg_stat_statements" to load this file. \quit
|
|
|
|
-- Register functions.
|
|
CREATE FUNCTION pg_stat_statements_reset()
|
|
RETURNS void
|
|
AS 'MODULE_PATHNAME'
|
|
LANGUAGE C;
|
|
|
|
CREATE FUNCTION pg_stat_statements(IN showtext boolean,
|
|
OUT userid oid,
|
|
OUT dbid oid,
|
|
OUT queryid bigint,
|
|
OUT query text,
|
|
OUT calls int8,
|
|
OUT total_time float8,
|
|
OUT rows int8,
|
|
OUT shared_blks_hit int8,
|
|
OUT shared_blks_read int8,
|
|
OUT shared_blks_dirtied int8,
|
|
OUT shared_blks_written int8,
|
|
OUT local_blks_hit int8,
|
|
OUT local_blks_read int8,
|
|
OUT local_blks_dirtied int8,
|
|
OUT local_blks_written int8,
|
|
OUT temp_blks_read int8,
|
|
OUT temp_blks_written int8,
|
|
OUT blk_read_time float8,
|
|
OUT blk_write_time float8
|
|
)
|
|
RETURNS SETOF record
|
|
AS 'MODULE_PATHNAME', 'pg_stat_statements_1_2'
|
|
LANGUAGE C STRICT VOLATILE;
|
|
|
|
-- Register a view on the function for ease of use.
|
|
CREATE VIEW pg_stat_statements AS
|
|
SELECT * FROM pg_stat_statements(true);
|
|
|
|
GRANT SELECT ON pg_stat_statements TO PUBLIC;
|
|
|
|
-- Don't want this to be available to non-superusers.
|
|
REVOKE ALL ON FUNCTION pg_stat_statements_reset() FROM PUBLIC;
|