Part VII. Internals

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

Table of Contents

53. Overview of PostgreSQL Internals
53.1. The Path of a Query
53.2. How Connections Are Established
53.3. The Parser Stage
53.4. The PostgreSQL Rule System
53.5. Planner/Optimizer
53.6. Executor
54. System Catalogs
54.1. Overview
54.2. pg_aggregate
54.3. pg_am
54.4. pg_amop
54.5. pg_amproc
54.6. pg_attrdef
54.7. pg_attribute
54.8. pg_attrmask
54.9. pg_authid
54.10. pg_auth_members
54.11. pg_cast
54.12. pg_class
54.13. pg_collation
54.14. pg_constraint
54.15. pg_conversion
54.16. pg_database
54.17. pg_db_role_setting
54.18. pg_default_acl
54.19. pg_depend
54.20. pg_description
54.21. pg_enum
54.22. pg_event_trigger
54.23. pg_extension
54.24. pg_foreign_data_wrapper
54.25. pg_foreign_server
54.26. pg_foreign_table
54.27. pg_index
54.28. pg_inherits
54.29. pg_init_privs
54.30. pg_language
54.31. pg_largeobject
54.32. pg_largeobject_metadata
54.33. pg_namespace
54.34. pg_opclass
54.35. pg_operator
54.36. pg_opfamily
54.37. pg_parameter_acl
54.38. pg_partitioned_table
54.39. pg_policy
54.40. pg_proc
54.41. pg_publication
54.42. pg_publication_namespace
54.43. pg_publication_rel
54.44. pg_range
54.45. pg_replication_origin
54.46. pg_rewrite
54.47. pg_seclabel
54.48. pg_sequence
54.49. pg_shdepend
54.50. pg_shdescription
54.51. pg_shseclabel
54.52. pg_statistic
54.53. pg_statistic_ext
54.54. pg_statistic_ext_data
54.55. pg_subscription
54.56. pg_subscription_rel
54.57. pg_tablespace
54.58. pg_transform
54.59. pg_trigger
54.60. pg_ts_config
54.61. pg_ts_config_map
54.62. pg_ts_dict
54.63. pg_ts_parser
54.64. pg_ts_template
54.65. pg_type
54.66. pg_user_mapping
55. System Views
55.1. Overview
55.2. pg_aios
55.3. pg_available_extensions
55.4. pg_available_extension_versions
55.5. pg_backend_memory_contexts
55.6. pg_config
55.7. pg_cursors
55.8. pg_file_settings
55.9. pg_group
55.10. pg_hba_file_rules
55.11. pg_ident_file_mappings
55.12. pg_indexes
55.13. pg_locks
55.14. pg_matviews
55.15. pg_policies
55.16. pg_prepared_statements
55.17. pg_prepared_xacts
55.18. pg_publication_tables
55.19. pg_replication_origin_status
55.20. pg_replication_slots
55.21. pg_roles
55.22. pg_rules
55.23. pg_seclabels
55.24. pg_sequences
55.25. pg_settings
55.26. pg_shadow
55.27. pg_shmem_allocations
55.28. pg_shmem_allocations_numa
55.29. pg_stats
55.30. pg_stats_ext
55.31. pg_stats_ext_exprs
55.32. pg_tables
55.33. pg_timezone_abbrevs
55.34. pg_timezone_names
55.35. pg_user
55.36. pg_user_mappings
55.37. pg_views
55.38. pg_wait_events
56. Frontend/Backend Protocol
56.1. Overview
56.2. Message Flow
56.3. SASL Authentication
56.4. Streaming Replication Protocol
56.5. Logical Streaming Replication Protocol
56.6. Message Data Types
56.7. Message Formats
56.8. Error and Notice Message Fields
56.9. Logical Replication Message Formats
56.10. Summary of Changes since Protocol 2.0
57. PostgreSQL Coding Conventions
57.1. Formatting
57.2. Reporting Errors Within the Server
57.3. Error Message Style Guide
57.4. Miscellaneous Coding Conventions
58. Native Language Support
58.1. For the Translator
58.2. For the Programmer
59. Writing a Procedural Language Handler
60. Writing a Foreign Data Wrapper
60.1. Foreign Data Wrapper Functions
60.2. Foreign Data Wrapper Callback Routines
60.3. Foreign Data Wrapper Helper Functions
60.4. Foreign Data Wrapper Query Planning
60.5. Row Locking in Foreign Data Wrappers
61. Writing a Table Sampling Method
61.1. Sampling Method Support Functions
62. Writing a Custom Scan Provider
62.1. Creating Custom Scan Paths
62.2. Creating Custom Scan Plans
62.3. Executing Custom Scans
63. Genetic Query Optimizer
63.1. Query Handling as a Complex Optimization Problem
63.2. Genetic Algorithms
63.3. Genetic Query Optimization (GEQO) in PostgreSQL
63.4. Further Reading
64. Table Access Method Interface Definition
65. Index Access Method Interface Definition
65.1. Basic API Structure for Indexes
65.2. Index Access Method Functions
65.3. Index Scanning
65.4. Index Locking Considerations
65.5. Index Uniqueness Checks
65.6. Index Cost Estimation Functions
66. Write Ahead Logging for Extensions
66.1. Generic WAL Records
66.2. Custom WAL Resource Managers
67. Built-in Index Access Methods
67.1. B-Tree Indexes
67.2. GiST Indexes
67.3. SP-GiST Indexes
67.4. GIN Indexes
67.5. BRIN Indexes
67.6. Hash Indexes
68. Database Physical Storage
68.1. Database File Layout
68.2. TOAST
68.3. Free Space Map
68.4. Visibility Map
68.5. The Initialization Fork
68.6. Database Page Layout
68.7. Heap-Only Tuples (HOT)
69. Transaction Processing
69.1. Transactions and Identifiers
69.2. Transactions and Locking
69.3. Subtransactions
69.4. Two-Phase Transactions
70. System Catalog Declarations and Initial Contents
70.1. System Catalog Declaration Rules
70.2. System Catalog Initial Data
70.3. BKI File Format
70.4. BKI Commands
70.5. Structure of the Bootstrap BKI File
70.6. BKI Example
71. How the Planner Uses Statistics
71.1. Row Estimation Examples
71.2. Multivariate Statistics Examples
71.3. Planner Statistics and Security
72. Backup Manifest Format
72.1. Backup Manifest Top-level Object
72.2. Backup Manifest File Object
72.3. Backup Manifest WAL Range Object