Part VII. Internals

This part contains assorted information that might be of use to PostgreSQL developers.

Table of Contents

52. Overview of PostgreSQL Internals
52.1. The Path of a Query
52.2. How Connections Are Established
52.3. The Parser Stage
52.4. The PostgreSQL Rule System
52.5. Planner/Optimizer
52.6. Executor
53. System Catalogs
53.1. Overview
53.2. pg_aggregate
53.3. pg_am
53.4. pg_amop
53.5. pg_amproc
53.6. pg_attrdef
53.7. pg_attribute
53.8. pg_attrmask
53.9. pg_authid
53.10. pg_auth_members
53.11. pg_cast
53.12. pg_class
53.13. pg_collation
53.14. pg_constraint
53.15. pg_conversion
53.16. pg_database
53.17. pg_db_role_setting
53.18. pg_default_acl
53.19. pg_depend
53.20. pg_description
53.21. pg_enum
53.22. pg_event_trigger
53.23. pg_extension
53.24. pg_foreign_data_wrapper
53.25. pg_foreign_server
53.26. pg_foreign_table
53.27. pg_index
53.28. pg_inherits
53.29. pg_init_privs
53.30. pg_language
53.31. pg_largeobject
53.32. pg_largeobject_metadata
53.33. pg_namespace
53.34. pg_opclass
53.35. pg_operator
53.36. pg_opfamily
53.37. pg_parameter_acl
53.38. pg_partitioned_table
53.39. pg_policy
53.40. pg_proc
53.41. pg_publication
53.42. pg_publication_namespace
53.43. pg_publication_rel
53.44. pg_range
53.45. pg_replication_origin
53.46. pg_rewrite
53.47. pg_seclabel
53.48. pg_sequence
53.49. pg_shdepend
53.50. pg_shdescription
53.51. pg_shseclabel
53.52. pg_statistic
53.53. pg_statistic_ext
53.54. pg_statistic_ext_data
53.55. pg_subscription
53.56. pg_subscription_rel
53.57. pg_tablespace
53.58. pg_transform
53.59. pg_trigger
53.60. pg_ts_config
53.61. pg_ts_config_map
53.62. pg_ts_dict
53.63. pg_ts_parser
53.64. pg_ts_template
53.65. pg_type
53.66. pg_user_mapping
54. System Views
54.1. Overview
54.2. pg_available_extensions
54.3. pg_available_extension_versions
54.4. pg_backend_memory_contexts
54.5. pg_config
54.6. pg_cursors
54.7. pg_file_settings
54.8. pg_group
54.9. pg_hba_file_rules
54.10. pg_ident_file_mappings
54.11. pg_indexes
54.12. pg_locks
54.13. pg_matviews
54.14. pg_policies
54.15. pg_prepared_statements
54.16. pg_prepared_xacts
54.17. pg_publication_tables
54.18. pg_replication_origin_status
54.19. pg_replication_slots
54.20. pg_roles
54.21. pg_rules
54.22. pg_seclabels
54.23. pg_sequences
54.24. pg_settings
54.25. pg_shadow
54.26. pg_shmem_allocations
54.27. pg_stats
54.28. pg_stats_ext
54.29. pg_stats_ext_exprs
54.30. pg_tables
54.31. pg_timezone_abbrevs
54.32. pg_timezone_names
54.33. pg_user
54.34. pg_user_mappings
54.35. pg_views
54.36. pg_wait_events
55. Frontend/Backend Protocol
55.1. Overview
55.2. Message Flow
55.3. SASL Authentication
55.4. Streaming Replication Protocol
55.5. Logical Streaming Replication Protocol
55.6. Message Data Types
55.7. Message Formats
55.8. Error and Notice Message Fields
55.9. Logical Replication Message Formats
55.10. Summary of Changes since Protocol 2.0
56. PostgreSQL Coding Conventions
56.1. Formatting
56.2. Reporting Errors Within the Server
56.3. Error Message Style Guide
56.4. Miscellaneous Coding Conventions
57. Native Language Support
57.1. For the Translator
57.2. For the Programmer
58. Writing a Procedural Language Handler
59. Writing a Foreign Data Wrapper
59.1. Foreign Data Wrapper Functions
59.2. Foreign Data Wrapper Callback Routines
59.3. Foreign Data Wrapper Helper Functions
59.4. Foreign Data Wrapper Query Planning
59.5. Row Locking in Foreign Data Wrappers
60. Writing a Table Sampling Method
60.1. Sampling Method Support Functions
61. Writing a Custom Scan Provider
61.1. Creating Custom Scan Paths
61.2. Creating Custom Scan Plans
61.3. Executing Custom Scans
62. Genetic Query Optimizer
62.1. Query Handling as a Complex Optimization Problem
62.2. Genetic Algorithms
62.3. Genetic Query Optimization (GEQO) in PostgreSQL
62.4. Further Reading
63. Table Access Method Interface Definition
64. Index Access Method Interface Definition
64.1. Basic API Structure for Indexes
64.2. Index Access Method Functions
64.3. Index Scanning
64.4. Index Locking Considerations
64.5. Index Uniqueness Checks
64.6. Index Cost Estimation Functions
65. Write Ahead Logging for Extensions
65.1. Generic WAL Records
65.2. Custom WAL Resource Managers
66. Built-in Index Access Methods
66.1. B-Tree Indexes
66.2. GiST Indexes
66.3. SP-GiST Indexes
66.4. GIN Indexes
66.5. BRIN Indexes
66.6. Hash Indexes
67. Database Physical Storage
67.1. Database File Layout
67.2. TOAST
67.3. Free Space Map
67.4. Visibility Map
67.5. The Initialization Fork
67.6. Database Page Layout
67.7. Heap-Only Tuples (HOT)
68. Transaction Processing
68.1. Transactions and Identifiers
68.2. Transactions and Locking
68.3. Subtransactions
68.4. Two-Phase Transactions
69. System Catalog Declarations and Initial Contents
69.1. System Catalog Declaration Rules
69.2. System Catalog Initial Data
69.3. BKI File Format
69.4. BKI Commands
69.5. Structure of the Bootstrap BKI File
69.6. BKI Example
70. How the Planner Uses Statistics
70.1. Row Estimation Examples
70.2. Multivariate Statistics Examples
70.3. Planner Statistics and Security
71. Backup Manifest Format
71.1. Backup Manifest Top-level Object
71.2. Backup Manifest File Object
71.3. Backup Manifest WAL Range Object