Part VII. Internals

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

Table of Contents

54. Overview of PostgreSQL Internals
54.1. The Path of a Query
54.2. How Connections Are Established
54.3. The Parser Stage
54.4. The PostgreSQL Rule System
54.5. Planner/Optimizer
54.6. Executor
55. System Catalogs
55.1. Overview
55.2. pg_aggregate
55.3. pg_am
55.4. pg_amop
55.5. pg_amproc
55.6. pg_attrdef
55.7. pg_attribute
55.8. pg_attrmask
55.9. pg_authid
55.10. pg_auth_members
55.11. pg_cast
55.12. pg_class
55.13. pg_collation
55.14. pg_constraint
55.15. pg_conversion
55.16. pg_database
55.17. pg_db_role_setting
55.18. pg_default_acl
55.19. pg_depend
55.20. pg_description
55.21. pg_enum
55.22. pg_event_trigger
55.23. pg_extension
55.24. pg_foreign_data_wrapper
55.25. pg_foreign_server
55.26. pg_foreign_table
55.27. pg_index
55.28. pg_inherits
55.29. pg_init_privs
55.30. pg_language
55.31. pg_largeobject
55.32. pg_largeobject_metadata
55.33. pg_namespace
55.34. pg_opclass
55.35. pg_operator
55.36. pg_opfamily
55.37. pg_parameter_acl
55.38. pg_partitioned_table
55.39. pg_policy
55.40. pg_proc
55.41. pg_publication
55.42. pg_publication_namespace
55.43. pg_publication_rel
55.44. pg_range
55.45. pg_replication_origin
55.46. pg_rewrite
55.47. pg_seclabel
55.48. pg_sequence
55.49. pg_shdepend
55.50. pg_shdescription
55.51. pg_shseclabel
55.52. pg_statistic
55.53. pg_statistic_ext
55.54. pg_statistic_ext_data
55.55. pg_subscription
55.56. pg_subscription_rel
55.57. pg_tablespace
55.58. pg_transform
55.59. pg_trigger
55.60. pg_ts_config
55.61. pg_ts_config_map
55.62. pg_ts_dict
55.63. pg_ts_parser
55.64. pg_ts_template
55.65. pg_type
55.66. pg_user_mapping
56. System Views
56.1. Overview
56.2. pg_available_extensions
56.3. pg_available_extension_versions
56.4. pg_backend_memory_contexts
56.5. pg_config
56.6. pg_cursors
56.7. pg_file_settings
56.8. pg_group
56.9. pg_hba_file_rules
56.10. pg_ident_file_mappings
56.11. pg_indexes
56.12. pg_locks
56.13. pg_matviews
56.14. pg_policies
56.15. pg_prepared_statements
56.16. pg_prepared_xacts
56.17. pg_publication_tables
56.18. pg_replication_origin_status
56.19. pg_replication_slots
56.20. pg_roles
56.21. pg_rules
56.22. pg_seclabels
56.23. pg_sequences
56.24. pg_settings
56.25. pg_shadow
56.26. pg_shmem_allocations
56.27. pg_stats
56.28. pg_stats_ext
56.29. pg_stats_ext_exprs
56.30. pg_tables
56.31. pg_timezone_abbrevs
56.32. pg_timezone_names
56.33. pg_user
56.34. pg_user_mappings
56.35. pg_views
57. Frontend/Backend Protocol
57.1. Overview
57.2. Message Flow
57.3. SASL Authentication
57.4. Streaming Replication Protocol
57.5. Logical Streaming Replication Protocol
57.6. Message Data Types
57.7. Message Formats
57.8. Error and Notice Message Fields
57.9. Logical Replication Message Formats
57.10. Summary of Changes since Protocol 2.0
58. PostgreSQL Coding Conventions
58.1. Formatting
58.2. Reporting Errors Within the Server
58.3. Error Message Style Guide
58.4. Miscellaneous Coding Conventions
59. Native Language Support
59.1. For the Translator
59.2. For the Programmer
60. Writing a Procedural Language Handler
61. Writing a Foreign Data Wrapper
61.1. Foreign Data Wrapper Functions
61.2. Foreign Data Wrapper Callback Routines
61.3. Foreign Data Wrapper Helper Functions
61.4. Foreign Data Wrapper Query Planning
61.5. Row Locking in Foreign Data Wrappers
62. Writing a Table Sampling Method
62.1. Sampling Method Support Functions
63. Writing a Custom Scan Provider
63.1. Creating Custom Scan Paths
63.2. Creating Custom Scan Plans
63.3. Executing Custom Scans
64. Genetic Query Optimizer
64.1. Query Handling as a Complex Optimization Problem
64.2. Genetic Algorithms
64.3. Genetic Query Optimization (GEQO) in PostgreSQL
64.4. Further Reading
65. Table Access Method Interface Definition
66. Index Access Method Interface Definition
66.1. Basic API Structure for Indexes
66.2. Index Access Method Functions
66.3. Index Scanning
66.4. Index Locking Considerations
66.5. Index Uniqueness Checks
66.6. Index Cost Estimation Functions
67. Generic WAL Records
68. Custom WAL Resource Managers
69. B-Tree Indexes
69.1. Introduction
69.2. Behavior of B-Tree Operator Classes
69.3. B-Tree Support Functions
69.4. Implementation
70. GiST Indexes
70.1. Introduction
70.2. Built-in Operator Classes
70.3. Extensibility
70.4. Implementation
70.5. Examples
71. SP-GiST Indexes
71.1. Introduction
71.2. Built-in Operator Classes
71.3. Extensibility
71.4. Implementation
71.5. Examples
72. GIN Indexes
72.1. Introduction
72.2. Built-in Operator Classes
72.3. Extensibility
72.4. Implementation
72.5. GIN Tips and Tricks
72.6. Limitations
72.7. Examples
73. BRIN Indexes
73.1. Introduction
73.2. Built-in Operator Classes
73.3. Extensibility
74. Hash Indexes
74.1. Overview
74.2. Implementation
75. Database Physical Storage
75.1. Database File Layout
75.2. TOAST
75.3. Free Space Map
75.4. Visibility Map
75.5. The Initialization Fork
75.6. Database Page Layout
75.7. Heap-Only Tuples (HOT)
76. Transaction Processing
76.1. Transactions and Identifiers
76.2. Transactions and Locking
76.3. Subtransactions
76.4. Two-Phase Transactions
77. System Catalog Declarations and Initial Contents
77.1. System Catalog Declaration Rules
77.2. System Catalog Initial Data
77.3. BKI File Format
77.4. BKI Commands
77.5. Structure of the Bootstrap BKI File
77.6. BKI Example
78. How the Planner Uses Statistics
78.1. Row Estimation Examples
78.2. Multivariate Statistics Examples
78.3. Planner Statistics and Security
79. Backup Manifest Format
79.1. Backup Manifest Top-level Object
79.2. Backup Manifest File Object
79.3. Backup Manifest WAL Range Object