Postgresql 中文操作指南
Chapter 61. Writing a Custom Scan Provider
Table of Contents
PostgreSQL 支持一组实验性功能,旨在允许扩展模块将新的扫描类型添加到系统中。与只负责了解如何扫描自己的外部表 foreign data wrapper 不同,自定义扫描提供程序可以为扫描系统中的任何关联提供一种替代方法。通常,编写自定义扫描提供程序的动机将是允许使用核心系统不支持的某些优化,例如缓存或某种形式的硬件加速。本章概述了如何编写新的自定义扫描提供程序。
PostgreSQL supports a set of experimental facilities which are intended to allow extension modules to add new scan types to the system. Unlike a foreign data wrapper, which is only responsible for knowing how to scan its own foreign tables, a custom scan provider can provide an alternative method of scanning any relation in the system. Typically, the motivation for writing a custom scan provider will be to allow the use of some optimization not supported by the core system, such as caching or some form of hardware acceleration. This chapter outlines how to write a new custom scan provider.
实现一种新的自定义扫描类型是一个三步过程。首先,在计划期间,有必要生成表示使用建议策略进行扫描的访问路径。其次,如果计划器将其中一个访问路径选为扫描特定关联的最佳策略,则必须将访问路径转换为计划。最后,必须能够执行该计划并生成与针对相同关联的任何其他访问路径所生成的结果相同的结果。
Implementing a new type of custom scan is a three-step process. First, during planning, it is necessary to generate access paths representing a scan using the proposed strategy. Second, if one of those access paths is selected by the planner as the optimal strategy for scanning a particular relation, the access path must be converted to a plan. Finally, it must be possible to execute the plan and generate the same results that would have been generated for any other access path targeting the same relation.