Part VII. Internals

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

Table of Contents

50. Overview of PostgreSQL Internals
50.1. The Path of a Query
50.2. How Connections are Established
50.3. The Parser Stage
50.4. The PostgreSQL Rule System
50.5. Planner/Optimizer
50.6. Executor
51. System Catalogs
51.1. Overview
51.2. pg_aggregate
51.3. pg_am
51.4. pg_amop
51.5. pg_amproc
51.6. pg_attrdef
51.7. pg_attribute
51.8. pg_authid
51.9. pg_auth_members
51.10. pg_cast
51.11. pg_class
51.12. pg_collation
51.13. pg_constraint
51.14. pg_conversion
51.15. pg_database
51.16. pg_db_role_setting
51.17. pg_default_acl
51.18. pg_depend
51.19. pg_description
51.20. pg_enum
51.21. pg_event_trigger
51.22. pg_extension
51.23. pg_foreign_data_wrapper
51.24. pg_foreign_server
51.25. pg_foreign_table
51.26. pg_index
51.27. pg_inherits
51.28. pg_init_privs
51.29. pg_language
51.30. pg_largeobject
51.31. pg_largeobject_metadata
51.32. pg_namespace
51.33. pg_opclass
51.34. pg_operator
51.35. pg_opfamily
51.36. pg_partitioned_table
51.37. pg_pltemplate
51.38. pg_policy
51.39. pg_proc
51.40. pg_publication
51.41. pg_publication_rel
51.42. pg_range
51.43. pg_replication_origin
51.44. pg_rewrite
51.45. pg_seclabel
51.46. pg_sequence
51.47. pg_shdepend
51.48. pg_shdescription
51.49. pg_shseclabel
51.50. pg_statistic
51.51. pg_statistic_ext
51.52. pg_subscription
51.53. pg_subscription_rel
51.54. pg_tablespace
51.55. pg_transform
51.56. pg_trigger
51.57. pg_ts_config
51.58. pg_ts_config_map
51.59. pg_ts_dict
51.60. pg_ts_parser
51.61. pg_ts_template
51.62. pg_type
51.63. pg_user_mapping
51.64. System Views
51.65. pg_available_extensions
51.66. pg_available_extension_versions
51.67. pg_config
51.68. pg_cursors
51.69. pg_file_settings
51.70. pg_group
51.71. pg_hba_file_rules
51.72. pg_indexes
51.73. pg_locks
51.74. pg_matviews
51.75. pg_policies
51.76. pg_prepared_statements
51.77. pg_prepared_xacts
51.78. pg_publication_tables
51.79. pg_replication_origin_status
51.80. pg_replication_slots
51.81. pg_roles
51.82. pg_rules
51.83. pg_seclabels
51.84. pg_sequences
51.85. pg_settings
51.86. pg_shadow
51.87. pg_stats
51.88. pg_tables
51.89. pg_timezone_abbrevs
51.90. pg_timezone_names
51.91. pg_user
51.92. pg_user_mappings
51.93. pg_views
52. Frontend/Backend Protocol
52.1. Overview
52.2. Message Flow
52.3. SASL Authentication
52.4. Streaming Replication Protocol
52.5. Logical Streaming Replication Protocol
52.6. Message Data Types
52.7. Message Formats
52.8. Error and Notice Message Fields
52.9. Logical Replication Message Formats
52.10. Summary of Changes since Protocol 2.0
53. PostgreSQL Coding Conventions
53.1. Formatting
53.2. Reporting Errors Within the Server
53.3. Error Message Style Guide
53.4. Miscellaneous Coding Conventions
54. Native Language Support
54.1. For the Translator
54.2. For the Programmer
55. Writing A Procedural Language Handler
56. Writing A Foreign Data Wrapper
56.1. Foreign Data Wrapper Functions
56.2. Foreign Data Wrapper Callback Routines
56.3. Foreign Data Wrapper Helper Functions
56.4. Foreign Data Wrapper Query Planning
56.5. Row Locking in Foreign Data Wrappers
57. Writing A Table Sampling Method
57.1. Sampling Method Support Functions
58. Writing A Custom Scan Provider
58.1. Creating Custom Scan Paths
58.2. Creating Custom Scan Plans
58.3. Executing Custom Scans
59. Genetic Query Optimizer
59.1. Query Handling as a Complex Optimization Problem
59.2. Genetic Algorithms
59.3. Genetic Query Optimization (GEQO) in PostgreSQL
59.4. Further Reading
60. Index Access Method Interface Definition
60.1. Basic API Structure for Indexes
60.2. Index Access Method Functions
60.3. Index Scanning
60.4. Index Locking Considerations
60.5. Index Uniqueness Checks
60.6. Index Cost Estimation Functions
61. Generic WAL Records
62. GiST Indexes
62.1. Introduction
62.2. Built-in Operator Classes
62.3. Extensibility
62.4. Implementation
62.5. Examples
63. SP-GiST Indexes
63.1. Introduction
63.2. Built-in Operator Classes
63.3. Extensibility
63.4. Implementation
63.5. Examples
64. GIN Indexes
64.1. Introduction
64.2. Built-in Operator Classes
64.3. Extensibility
64.4. Implementation
64.5. GIN Tips and Tricks
64.6. Limitations
64.7. Examples
65. BRIN Indexes
65.1. Introduction
65.2. Built-in Operator Classes
65.3. Extensibility
66. Database Physical Storage
66.1. Database File Layout
66.2. TOAST
66.3. Free Space Map
66.4. Visibility Map
66.5. The Initialization Fork
66.6. Database Page Layout
67. BKI Backend Interface
67.1. BKI File Format
67.2. BKI Commands
67.3. Structure of the Bootstrap BKI File
67.4. Example
68. How the Planner Uses Statistics
68.1. Row Estimation Examples
68.2. Multivariate Statistics Examples
68.3. Planner Statistics and Security