postgresql/doc/src/sgml/ref
Alvaro Herrera 5de890e361
Add EXPLAIN (MEMORY) to report planner memory consumption
This adds a new "Memory:" line under the "Planning:" group (which
currently only has "Buffers:") when the MEMORY option is specified.

In order to make the reporting reasonably accurate, we create a separate
memory context for planner activities, to be used only when this option
is given.  The total amount of memory allocated by that context is
reported as "allocated"; we subtract memory in the context's freelists
from that and report that result as "used".  We use
MemoryContextStatsInternal() to obtain the quantities.

The code structure to show buffer usage during planning was not in
amazing shape, so I (Álvaro) modified the patch a bit to clean that up
in passing.

Author: Ashutosh Bapat
Reviewed-by: David Rowley, Andrey Lepikhov, Jian He, Andy Fan
Discussion: https://www.postgresql.org/message-id/CAExHW5sZA=5LJ_ZPpRO-w09ck8z9p7eaYAqq3Ks9GDfhrxeWBw@mail.gmail.com
2024-01-29 17:53:03 +01:00
..
abort.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
allfiles.sgml Add new pg_walsummary tool. 2024-01-11 12:48:27 -05:00
alter_aggregate.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_collation.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_conversion.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_database.sgml Revert "Add USER SET parameter values for pg_db_role_setting" 2023-05-17 20:28:57 +03:00
alter_default_privileges.sgml doc: restructure ALTER DEFAULT PRIVILEGES 2023-11-13 14:27:38 -05:00
alter_domain.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_event_trigger.sgml Allow CURRENT_ROLE where CURRENT_USER is accepted 2020-09-17 11:40:08 +02:00
alter_extension.sgml Reconsider the handling of procedure OUT parameters. 2021-06-10 17:11:36 -04:00
alter_foreign_data_wrapper.sgml doc: Fix syntax in ALTER FOREIGN DATA WRAPPER example 2023-12-19 14:13:50 +01:00
alter_foreign_table.sgml doc: Fix example command for ALTER FOREIGN TABLE ... OPTIONS. 2023-06-08 20:12:51 +09:00
alter_function.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_group.sgml Make role grant system more consistent with other privileges. 2022-08-22 11:35:17 -04:00
alter_index.sgml Revert per-index collation version tracking feature. 2021-05-07 21:10:11 +12:00
alter_language.sgml Allow CURRENT_ROLE where CURRENT_USER is accepted 2020-09-17 11:40:08 +02:00
alter_large_object.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_materialized_view.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_opclass.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_operator.sgml Extend ALTER OPERATOR to allow setting more optimization attributes. 2023-10-20 12:28:46 -04:00
alter_opfamily.sgml Use the correct article for abbreviations 2021-06-11 13:38:04 +12:00
alter_policy.sgml doc: Improve hyphenation consistency 2021-04-21 08:14:43 +02:00
alter_procedure.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_publication.sgml Doc: Make link names consistent in logical replication commands. 2023-10-30 10:46:31 +05:30
alter_role.sgml Improve some documentation about the bootstrap superuser. 2024-01-18 21:39:51 -06:00
alter_routine.sgml Doc: fix confusion about LEAKPROOF in syntax summaries. 2021-06-23 14:27:13 -04:00
alter_rule.sgml
alter_schema.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_sequence.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_server.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_statistics.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_subscription.sgml Doc: Make link names consistent in logical replication commands. 2023-10-30 10:46:31 +05:30
alter_system.sgml doc: improve ALTER SYSTEM description of value list quoting 2023-10-31 10:21:32 -04:00
alter_table.sgml Make attstattarget nullable 2024-01-13 18:14:53 +01:00
alter_tablespace.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_trigger.sgml Make ALTER TRIGGER RENAME consistent for partitioned tables 2021-07-22 18:33:47 -04:00
alter_tsconfig.sgml Allow CURRENT_ROLE where CURRENT_USER is accepted 2020-09-17 11:40:08 +02:00
alter_tsdictionary.sgml Allow CURRENT_ROLE where CURRENT_USER is accepted 2020-09-17 11:40:08 +02:00
alter_tsparser.sgml
alter_tstemplate.sgml
alter_type.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
alter_user.sgml Revert "Add USER SET parameter values for pg_db_role_setting" 2023-05-17 20:28:57 +03:00
alter_user_mapping.sgml Allow CURRENT_ROLE where CURRENT_USER is accepted 2020-09-17 11:40:08 +02:00
alter_view.sgml More documentation update for GRANT ... WITH SET OPTION. 2023-01-16 10:35:29 -05:00
analyze.sgml doc: mention that ANALYZE does block DDL 2023-11-08 16:05:02 -05:00
begin.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
call.sgml Reconsider the handling of procedure OUT parameters. 2021-06-10 17:11:36 -04:00
checkpoint.sgml Rename pg_checkpointer predefined role to pg_checkpoint. 2022-07-05 13:31:42 -04:00
close.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
cluster.sgml Doc: move unparenthesized syntaxes for a few commands. 2023-07-19 15:26:59 -07:00
clusterdb.sgml Fix connection string handling in src/bin/scripts/ programs. 2020-10-19 19:03:46 -04:00
comment.sgml Doc: clarify use of NULL to drop comments and security labels. 2023-01-31 14:32:24 -05:00
commit.sgml Doc: add XML ID attributes to <sectN> and <varlistentry> tags. 2023-01-09 15:08:24 -05:00
commit_prepared.sgml doc: Remove unused title ids 2020-03-13 15:45:37 +01:00
copy.sgml Rename COPY option from SAVE_ERROR_TO to ON_ERROR 2024-01-19 15:15:51 +02:00
create_access_method.sgml tableam: basic documentation. 2019-04-03 17:40:29 -07:00
create_aggregate.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
create_cast.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
create_collation.sgml doc: Add more ICU rules examples 2023-08-23 11:23:42 +02:00
create_conversion.sgml Add 'noError' argument to encoding conversion functions. 2021-04-01 11:45:22 +03:00
create_database.sgml doc: Add more ICU rules examples 2023-08-23 11:23:42 +02:00
create_domain.sgml Convert domain_in to report errors softly. 2022-12-11 12:56:54 -05:00
create_event_trigger.sgml Add GUC for temporarily disabling event triggers 2023-09-25 12:41:49 +02:00
create_extension.sgml doc: Fix man page whitespace issues 2021-04-09 23:36:46 +02:00
create_foreign_data_wrapper.sgml
create_foreign_table.sgml doc: Fix some typos and grammar 2023-10-25 09:40:55 +09:00
create_function.sgml Assorted improvements to SECURITY DEFINER functions documentation. 2023-01-16 10:49:59 -05:00
create_group.sgml Doc: sync CREATE GROUP syntax synopsis with CREATE ROLE. 2020-04-10 10:44:09 -04:00
create_index.sgml doc: mention "bloom" as a possible index access method 2022-08-31 22:35:09 -04:00
create_language.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
create_materialized_view.sgml Doc: be more precise about conflicts between relation names. 2021-11-02 12:12:02 -04:00
create_opclass.sgml Use the correct article for abbreviations 2021-06-11 13:38:04 +12:00
create_operator.sgml Doc: update CREATE OPERATOR's statement about => as an operator. 2023-10-20 13:01:02 -04:00
create_opfamily.sgml
create_policy.sgml Add support for MERGE SQL command 2022-03-28 16:47:48 +02:00
create_procedure.sgml doc: Fix man page whitespace issues 2021-04-09 23:36:46 +02:00
create_publication.sgml Doc: Make link names consistent in logical replication commands. 2023-10-30 10:46:31 +05:30
create_role.sgml doc: Move CREATE ROLE's IN GROUP and USER to deprecated 2023-10-10 16:44:02 -04:00
create_rule.sgml Doc: update CREATE RULE ref page's hoary discussion of views. 2023-11-03 11:48:23 -04:00
create_schema.sgml Fix various typos in code and tests 2023-02-09 14:43:53 +09:00
create_sequence.sgml doc: fix wrong tag used in create sequence manual. 2022-08-16 09:20:14 +09:00
create_server.sgml doc: foreign servers with pushdown need matching collation 2023-10-10 16:04:56 -04:00
create_statistics.sgml Doc: mention that extended stats aren't used for joins 2023-06-22 12:45:50 +12:00
create_subscription.sgml Re-validate connection string in libpqrcv_connect(). 2024-01-12 13:41:36 -08:00
create_table.sgml Add temporal PRIMARY KEY and UNIQUE constraints 2024-01-24 16:34:37 +01:00
create_table_as.sgml doc: clarify CREATE TABLE AS ... IF NOT EXISTS 2022-08-12 10:59:00 -04:00
create_tablespace.sgml Remove configure probes for symlink/readlink, and dead code. 2022-08-05 09:22:56 +12:00
create_transform.sgml plpython: Adjust docs after removal of Python 2 support. 2022-03-07 18:30:57 -08:00
create_trigger.sgml Support TRUNCATE triggers on foreign tables. 2022-07-12 09:18:02 +09:00
create_tsconfig.sgml
create_tsdictionary.sgml
create_tsparser.sgml
create_tstemplate.sgml
create_type.sgml Create infrastructure for "soft" error reporting. 2022-12-09 09:58:38 -05:00
create_user.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
create_user_mapping.sgml Allow CURRENT_ROLE where CURRENT_USER is accepted 2020-09-17 11:40:08 +02:00
create_view.sgml Add support for security invoker views. 2022-03-22 10:28:10 +00:00
createdb.sgml CREATE DATABASE: make LOCALE apply to all collation providers. 2023-06-16 10:27:32 -07:00
createuser.sgml Document deprecated createuser option. 2023-05-23 19:35:05 -07:00
deallocate.sgml
declare.sgml In plpgsql, don't preassign portal names to bound cursor variables. 2023-01-01 13:22:34 -05:00
delete.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
discard.sgml Fix order of steps in DISCARD ALL documentation 2019-06-11 12:22:11 -04:00
do.sgml doc: Remove unused title ids 2020-03-13 15:45:37 +01:00
drop_access_method.sgml
drop_aggregate.sgml
drop_cast.sgml doc: make ref/*.sgml file header comment layout consistent 2020-05-15 08:52:24 -04:00
drop_collation.sgml doc: make ref/*.sgml file header comment layout consistent 2020-05-15 08:52:24 -04:00
drop_conversion.sgml doc: make ref/*.sgml file header comment layout consistent 2020-05-15 08:52:24 -04:00
drop_database.sgml doc: Trim trailing whitespace 2020-06-07 13:24:40 +02:00
drop_domain.sgml
drop_event_trigger.sgml
drop_extension.sgml doc: clarify DROP EXTENSION dependent members text 2022-08-12 09:07:11 -04:00
drop_foreign_data_wrapper.sgml
drop_foreign_table.sgml doc: make ref/*.sgml file header comment layout consistent 2020-05-15 08:52:24 -04:00
drop_function.sgml doc: Fix man page whitespace issues 2020-06-07 14:54:28 +02:00
drop_group.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
drop_index.sgml doc: Clarify use of ACCESS EXCLUSIVE lock in various sections 2021-04-01 15:28:37 +09:00
drop_language.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
drop_materialized_view.sgml
drop_opclass.sgml
drop_operator.sgml Remove support for postfix (right-unary) operators. 2020-09-17 19:38:05 -04:00
drop_opfamily.sgml
drop_owned.sgml Allow granting SET and ALTER SYSTEM privileges on GUC parameters. 2022-04-06 13:24:33 -04:00
drop_policy.sgml doc: Improve hyphenation consistency 2021-04-21 08:14:43 +02:00
drop_procedure.sgml doc: Fix man page whitespace issues 2022-04-07 18:25:12 +02:00
drop_publication.sgml
drop_role.sgml Restrict the privileges of CREATEROLE users. 2023-01-10 12:44:30 -05:00
drop_routine.sgml Reconsider the handling of procedure OUT parameters. 2021-06-10 17:11:36 -04:00
drop_rule.sgml
drop_schema.sgml
drop_sequence.sgml
drop_server.sgml
drop_statistics.sgml doc: Mention CASCADE/RESTRICT for DROP STATISTICS 2021-07-19 12:39:38 +09:00
drop_subscription.sgml Doc: Add more links in logical replication pages. 2023-10-13 12:13:46 +05:30
drop_table.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
drop_tablespace.sgml
drop_transform.sgml plpython: Adjust docs after removal of Python 2 support. 2022-03-07 18:30:57 -08:00
drop_trigger.sgml
drop_tsconfig.sgml
drop_tsdictionary.sgml
drop_tsparser.sgml
drop_tstemplate.sgml
drop_type.sgml
drop_user.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
drop_user_mapping.sgml Allow CURRENT_ROLE where CURRENT_USER is accepted 2020-09-17 11:40:08 +02:00
drop_view.sgml
dropdb.sgml Fix connection string handling in src/bin/scripts/ programs. 2020-10-19 19:03:46 -04:00
dropuser.sgml Restrict the privileges of CREATEROLE users. 2023-01-10 12:44:30 -05:00
ecpg-ref.sgml Fix our getopt_long's behavior for a command line argument of just "-". 2020-03-23 11:58:00 -04:00
end.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
execute.sgml Doc: fix "Unresolved ID reference" warnings, clean up man page cross-refs. 2020-05-11 14:15:55 -04:00
explain.sgml Add EXPLAIN (MEMORY) to report planner memory consumption 2024-01-29 17:53:03 +01:00
fetch.sgml doc: Fix XML formatting that psql cannot handle 2023-02-03 09:04:35 +01:00
grant.sgml Revert MAINTAIN privilege and pg_maintain predefined role. 2023-07-07 11:25:13 -07:00
import_foreign_schema.sgml
initdb.sgml doc: clarify who owns the initdb-created cluster, by default 2024-01-10 11:20:15 -05:00
insert.sgml doc: clarify that "excluded" ON CONFLICT is a single row 2022-07-14 15:33:28 -04:00
listen.sgml Use larger segment file names for pg_notify 2023-11-29 01:41:48 +02:00
load.sgml doc: make ref/*.sgml file header comment layout consistent 2020-05-15 08:52:24 -04:00
lock.sgml Revert MAINTAIN privilege and pg_maintain predefined role. 2023-07-07 11:25:13 -07:00
merge.sgml Decorate WITH with literal markup tags 2024-01-16 13:51:15 +01:00
move.sgml doc: Fix XML formatting that psql cannot handle 2023-02-03 09:04:35 +01:00
notify.sgml Use larger segment file names for pg_notify 2023-11-29 01:41:48 +02:00
pg_amcheck.sgml Teach contrib/amcheck to check the unique constraint violation 2023-10-28 00:21:23 +03:00
pg_basebackup.sgml Fix numerous typos in incremental backup commits. 2023-12-21 15:36:17 -05:00
pg_checksums.sgml Document that --sync-method takes an argument. 2023-10-04 14:40:50 -05:00
pg_combinebackup.sgml Fix numerous typos in incremental backup commits. 2023-12-21 15:36:17 -05:00
pg_config-ref.sgml Add missing <application> tags in application doc <refentrytitle>s 2020-07-10 16:51:29 +02:00
pg_controldata.sgml doc: remove unnecessary blank before command option text 2020-12-03 11:33:24 -05:00
pg_ctl-ref.sgml Remove exclusive backup mode 2022-04-06 14:41:03 -04:00
pg_dump.sgml Read include/exclude commands for dump/restore from file 2023-11-29 14:56:24 +01:00
pg_dumpall.sgml Read include/exclude commands for dump/restore from file 2023-11-29 14:56:24 +01:00
pg_isready.sgml doc: libpq connection options can override command-line flags 2020-10-02 22:19:31 -04:00
pg_receivewal.sgml doc: wording improvements 2023-10-27 17:23:34 -04:00
pg_recvlogical.sgml doc: wording improvements 2023-10-27 17:23:34 -04:00
pg_resetwal.sgml doc: pg_resetwal: Add comments how the multipliers are derived 2023-11-06 09:16:00 +01:00
pg_restore.sgml Read include/exclude commands for dump/restore from file 2023-11-29 14:56:24 +01:00
pg_rewind.sgml Document that --sync-method takes an argument. 2023-10-04 14:40:50 -05:00
pg_verifybackup.sgml Add support for progress reporting to pg_verifybackup 2023-02-06 14:40:31 +09:00
pg_waldump.sgml doc: wording improvements 2023-10-27 17:23:34 -04:00
pg_walsummary.sgml Fix typo. 2024-01-12 09:46:46 -05:00
pgarchivecleanup.sgml pg_archivecleanup: Add --clean-backup-history 2023-07-19 13:41:22 +09:00
pgbench.sgml pgbench: Add \syncpipeline 2024-01-24 16:55:19 +09:00
pgtestfsync.sgml Remove trailing whitespace from *.sgml files. 2022-04-20 11:04:49 -04:00
pgtesttiming.sgml doc: make ref/*.sgml file header comment layout consistent 2020-05-15 08:52:24 -04:00
pgupgrade.sgml Doc: Fix incorrect reference to conflicting column in pg_replication_slots. 2024-01-29 12:13:39 +05:30
postgres-ref.sgml Provide options for postmaster to kill child processes with SIGABRT. 2022-11-21 11:59:29 -05:00
prepare.sgml Doc: Miscellaneous doc updates for MERGE. 2023-02-26 09:06:04 +00:00
prepare_transaction.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
psql-ref.sgml doc: \copy can get data values \. and end-of-input confused 2023-11-03 13:57:59 -04:00
reassign_owned.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
refresh_materialized_view.sgml doc: remove double-negative in REFRESH MATERIALIZED ... CONCURR 2023-11-22 16:40:10 -05:00
reindex.sgml Revert MAINTAIN privilege and pg_maintain predefined role. 2023-07-07 11:25:13 -07:00
reindexdb.sgml Harmonize password reuse in vacuumdb, clusterdb, and reindexdb. 2023-07-28 10:07:44 -07:00
release_savepoint.sgml doc: add transaction processing chapter with internals info 2022-11-29 20:49:52 -05:00
reset.sgml
revoke.sgml Revert MAINTAIN privilege and pg_maintain predefined role. 2023-07-07 11:25:13 -07:00
rollback.sgml Doc: add XML ID attributes to <sectN> and <varlistentry> tags. 2023-01-09 15:08:24 -05:00
rollback_prepared.sgml doc: Remove unused title ids 2020-03-13 15:45:37 +01:00
rollback_to.sgml doc: add transaction processing chapter with internals info 2022-11-29 20:49:52 -05:00
savepoint.sgml doc: clarify the behavior of identically-named savepoints 2022-07-14 15:44:22 -04:00
security_label.sgml Doc: clarify use of NULL to drop comments and security labels. 2023-01-31 14:32:24 -05:00
select.sgml doc: FOR UPDATE / KEY / SHARE / KEY SHARE takes an table alias 2023-12-07 19:43:04 -05:00
select_into.sgml Fix various typos, grammar and code style in comments and docs 2022-01-25 09:40:04 +09:00
set.sgml doc: mention that SET TIME ZONE often needs to be quoted 2022-08-31 20:27:27 -04:00
set_constraints.sgml doc: make ref/*.sgml file header comment layout consistent 2020-05-15 08:52:24 -04:00
set_role.sgml Add a SET option to the GRANT command. 2022-11-18 12:32:56 -05:00
set_session_auth.sgml Fix privilege check for SET SESSION AUTHORIZATION. 2023-07-13 21:13:45 -07:00
set_transaction.sgml Doc: Miscellaneous doc updates for MERGE. 2023-02-26 09:06:04 +00:00
show.sgml Remove trailing whitespace from *.sgml files. 2022-04-20 11:04:49 -04:00
start_transaction.sgml Improve <xref> vs. <command> formatting in the documentation 2020-10-03 16:40:02 +02:00
truncate.sgml doc: Review for "Allow TRUNCATE command to truncate foreign tables". 2021-04-27 18:39:30 +09:00
unlisten.sgml
update.sgml doc: Make UPDATE FROM examples consistent 2022-03-29 14:53:20 +02:00
vacuum.sgml doc: Fix description of BUFFER_USAGE_LIMIT for VACUUM and ANALYZE 2023-09-20 13:36:54 +09:00
vacuumdb.sgml Harmonize password reuse in vacuumdb, clusterdb, and reindexdb. 2023-07-28 10:07:44 -07:00
values.sgml doc: Properly punctuate "etc." 2022-05-19 09:42:17 +02:00