Part VIII. Internals

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

Table of Contents

59. Overview of PostgreSQL Internals
59.1. The Path of a Query
59.2. How Connections Are Established
59.3. The Parser Stage
59.4. The PostgreSQL Rule System
59.5. Planner/Optimizer
59.6. Executor
60. System Catalogs
60.1. Overview
60.2. pg_aggregate
60.3. pg_am
60.4. pg_amop
60.5. pg_amproc
60.6. pg_attrdef
60.7. pg_attribute
60.8. pg_authid
60.9. pg_auth_members
60.10. pg_cast
60.11. pg_class
60.12. pg_collation
60.13. pg_constraint
60.14. pg_conversion
60.15. pg_database
60.16. pg_db_role_setting
60.17. pg_default_acl
60.18. pg_depend
60.19. pg_description
60.20. pg_enum
60.21. pg_event_trigger
60.22. pg_extension
60.23. pg_foreign_data_wrapper
60.24. pg_foreign_server
60.25. pg_foreign_table
60.26. pg_index
60.27. pg_inherits
60.28. pg_init_privs
60.29. pg_language
60.30. pg_largeobject
60.31. pg_largeobject_metadata
60.32. pg_namespace
60.33. pg_opclass
60.34. pg_operator
60.35. pg_opfamily
60.36. pg_parameter_acl
60.37. pg_partitioned_table
60.38. pg_policy
60.39. pg_proc
60.40. pg_publication
60.41. pg_publication_namespace
60.42. pg_publication_rel
60.43. pg_range
60.44. pg_replication_origin
60.45. pg_rewrite
60.46. pg_seclabel
60.47. pg_sequence
60.48. pg_shdepend
60.49. pg_shdescription
60.50. pg_shseclabel
60.51. pg_statistic
60.52. pg_statistic_ext
60.53. pg_statistic_ext_data
60.54. pg_subscription
60.55. pg_subscription_rel
60.56. pg_tablespace
60.57. pg_transform
60.58. pg_trigger
60.59. pg_ts_config
60.60. pg_ts_config_map
60.61. pg_ts_dict
60.62. pg_ts_parser
60.63. pg_ts_template
60.64. pg_type
60.65. pg_user_mapping
61. System Views
61.1. Overview
61.2. pg_available_extensions
61.3. pg_available_extension_versions
61.4. pg_backend_memory_contexts
61.5. pg_config
61.6. pg_cursors
61.7. pg_file_settings
61.8. pg_group
61.9. pg_hba_file_rules
61.10. pg_ident_file_mappings
61.11. pg_indexes
61.12. pg_locks
61.13. pg_matviews
61.14. pg_policies
61.15. pg_prepared_statements
61.16. pg_prepared_xacts
61.17. pg_publication_tables
61.18. pg_replication_origin_status
61.19. pg_replication_slots
61.20. pg_roles
61.21. pg_rules
61.22. pg_seclabels
61.23. pg_sequences
61.24. pg_settings
61.25. pg_shadow
61.26. pg_shmem_allocations
61.27. pg_stats
61.28. pg_stats_ext
61.29. pg_stats_ext_exprs
61.30. pg_tables
61.31. pg_timezone_abbrevs
61.32. pg_timezone_names
61.33. pg_user
61.34. pg_user_mappings
61.35. pg_views
62. Frontend/Backend Protocol
62.1. Overview
62.2. Message Flow
62.3. SASL Authentication
62.4. Streaming Replication Protocol
62.5. Logical Streaming Replication Protocol
62.6. Message Data Types
62.7. Message Formats
62.8. Error and Notice Message Fields
62.9. Logical Replication Message Formats
62.10. Summary of Changes since Protocol 2.0
63. PostgreSQL Coding Conventions
63.1. Formatting
63.2. Reporting Errors Within the Server
63.3. Error Message Style Guide
63.4. Miscellaneous Coding Conventions
64. Native Language Support
64.1. For the Translator
64.2. For the Programmer
65. Writing a Procedural Language Handler
66. Writing a Foreign Data Wrapper
66.1. Foreign Data Wrapper Functions
66.2. Foreign Data Wrapper Callback Routines
66.3. Foreign Data Wrapper Helper Functions
66.4. Foreign Data Wrapper Query Planning
66.5. Row Locking in Foreign Data Wrappers
67. Writing a Table Sampling Method
67.1. Sampling Method Support Functions
68. Writing a Custom Scan Provider
68.1. Creating Custom Scan Paths
68.2. Creating Custom Scan Plans
68.3. Executing Custom Scans
69. Genetic Query Optimizer
69.1. Query Handling as a Complex Optimization Problem
69.2. Genetic Algorithms
69.3. Genetic Query Optimization (GEQO) in PostgreSQL
69.4. Further Reading
70. Table Access Method Interface Definition
71. Index Access Method Interface Definition
71.1. Basic API Structure for Indexes
71.2. Index Access Method Functions
71.3. Index Scanning
71.4. Index Locking Considerations
71.5. Index Uniqueness Checks
71.6. Index Cost Estimation Functions
72. Generic WAL Records
73. Custom WAL Resource Managers
74. B-Tree Indexes
74.1. Introduction
74.2. Behavior of B-Tree Operator Classes
74.3. B-Tree Support Functions
74.4. Implementation
75. GiST Indexes
75.1. Introduction
75.2. Built-in Operator Classes
75.3. Extensibility
75.4. Implementation
75.5. Examples
76. SP-GiST Indexes
76.1. Introduction
76.2. Built-in Operator Classes
76.3. Extensibility
76.4. Implementation
76.5. Examples
77. GIN Indexes
77.1. Introduction
77.2. Built-in Operator Classes
77.3. Extensibility
77.4. Implementation
77.5. GIN Tips and Tricks
77.6. Limitations
77.7. Examples
78. BRIN Indexes
78.1. Introduction
78.2. Built-in Operator Classes
78.3. Extensibility
79. Hash Indexes
79.1. Overview
79.2. Implementation
80. Database Physical Storage
80.1. Database File Layout
80.2. TOAST
80.3. Free Space Map
80.4. Visibility Map
80.5. The Initialization Fork
80.6. Database Page Layout
80.7. Heap-Only Tuples (HOT)
81. Transaction Processing
81.1. Transactions and Identifiers
81.2. Transactions and Locking
81.3. Subtransactions
81.4. Two-Phase Transactions
82. System Catalog Declarations and Initial Contents
82.1. System Catalog Declaration Rules
82.2. System Catalog Initial Data
82.3. BKI File Format
82.4. BKI Commands
82.5. Structure of the Bootstrap BKI File
82.6. BKI Example
83. How the Planner Uses Statistics
83.1. Row Estimation Examples
83.2. Multivariate Statistics Examples
83.3. Planner Statistics and Security
84. Backup Manifest Format
84.1. Backup Manifest Top-level Object
84.2. Backup Manifest File Object
84.3. Backup Manifest WAL Range Object