バージョンごとのドキュメント一覧

第61章 カスタムスキャンプロバイダの作成

目次

61.1. カスタムスキャンパスの作成
61.1.1. カスタムスキャンパスのコールバック
61.2. カスタムスキャン計画の作成
61.2.1. カスタムスキャン計画のコールバック
61.3. カスタムスキャンの実行
61.3.1. カスタムスキャン実行のコールバック
<title>Writing a Custom Scan Provider</title>

<productname>PostgreSQL</productname> supports a set of experimental facilities which are intended to allow extension modules to add new scan types to the system. Unlike a <link linkend="fdwhandler">foreign data wrapper</link>, 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. PostgreSQLでは、システムに新しいスキャン方式を追加する拡張モジュールを可能にするためのいくつかの実験的機構をサポートしています。 外部データラッパーが自分の外部テーブルのスキャン方法を知っていることだけを担当するのと異なり、カスタムスキャンプロバイダはシステム内のリレーションをスキャンする代替方式を提供することができます。 典型的には、カスタムスキャンプロバイダを作成する理由は、キャッシュの利用や何らかの形式のハードウェアアクセラレーションといったコアシステムによってサポートされない最適化を利用可能にすることでしょう。 本章では新しいカスタムスキャンプロバイダの作成方法について概要を説明します。

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. 新しい種類のカスタムスキャンの実装には3段階のプロセスがあります。 第一に、計画段階において、提案される戦略を用いたスキャンを表現するアクセスパスを生成する必要があります。 第二に、プランナがあるリレーションをスキャンするための最適戦略として、そのアクセスパスの一つを選んだとき、アクセスパスが計画に変換されなければなりません。 最後に、計画を実行して、同じリレーションを対象とする他のアクセスパスが生成するのと同じ結果を生成することが可能でなければなりません。