SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
Custom Scan API

KaiGai Kohei <kaigai@kaigai.gr.jp>
(Tw: @kkaigai)
自己紹介

 海外 浩平 (かいがい こうへい)
最近、国内に戻ってきました。
 SE-PostgreSQLやPG-Stromを作っています。
2

PostgreSQL Unconference #3
Custom Scan APIとは
Extensionがエグゼキュータ処理を乗っ取るAPI
俺様的方法で Scan を実装できる

俺様的方法で Join を実装できる
(俺様的方法で Xxxx を実装できる)
PostgreSQL v9.4 の標準機能化に向けて議論の途中

3

PostgreSQL Unconference #3
ExecutorXXX_hook ではダメなのか?(1/3)
/* Hook for plugins to get control in ExecutorStart() */
typedef void (*ExecutorStart_hook_type) (QueryDesc *queryDesc,
int eflags);
extern PGDLLIMPORT ExecutorStart_hook_type ExecutorStart_hook;
/* Hook for plugins to get control in ExecutorRun() */
typedef void (*ExecutorRun_hook_type) (QueryDesc *queryDesc,
ScanDirection direction,
long count);
extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook;

/* Hook for plugins to get control in ExecutorFinish() */
typedef void (*ExecutorFinish_hook_type) (QueryDesc *queryDesc);
extern PGDLLIMPORT ExecutorFinish_hook_type ExecutorFinish_hook;
/* Hook for plugins to get control in ExecutorEnd() */
typedef void (*ExecutorEnd_hook_type) (QueryDesc *queryDesc);
extern PGDLLIMPORT ExecutorEnd_hook_type ExecutorEnd_hook;
4

PostgreSQL Unconference #3
ExecutorXXX_hook ではダメなのか?(2/3)
postgres=# explain(costs off) select y from l_tbl join r_tbl
on a = x group by y,b order by b;
QUERY PLAN
------------------------------------------------独自のソート実装を
Group
エクステンションとし
Group Key: l_tbl.b, r_tbl.y
て実装できるか?
-> Sort
Sort Key: l_tbl.b, r_tbl.y
-> Merge Join
Merge Cond: (l_tbl.a = r_tbl.x)
-> Sort
Sort Key: l_tbl.a
-> Seq Scan on l_tbl
-> Materialize
-> Sort
Sort Key: r_tbl.x
-> Seq Scan on r_tbl
(13 rows)
5

PostgreSQL Unconference #3
ExecutorXXX_hook ではダメなのか?(3/3)
TupleTableSlot *ExecProcNode(PlanState *node)
{
:
switch (nodeTag(node))
{
:
case T_SeqScanState:
result = ExecSeqScan((SeqScanState *) node);
break;
:
default:
elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(node));
result = NULL;
break;
}
何か 『任意の処理を行う』 ノードを
return result;
PostgreSQL本体が認識できる
}
必要がある。
6

PostgreSQL Unconference #3
Custom Scan API (1/3)
 オプティマイザへ介入するためのフック
/* Hook for plugins to add custom scan path */
typedef void (*add_scan_path_hook_type)(PlannerInfo *root,
RelOptInfo *baserel,
RangeTblEntry *rte);
extern PGDLLIMPORT add_scan_path_hook_type add_scan_path_hook;

/* Hook for plugins to add custom join path */
typedef void (*add_join_path_hook_type)(PlannerInfo *root,
RelOptInfo *joinrel,
RelOptInfo *outerrel,
RelOptInfo *innerrel,
JoinType jointype,
SpecialJoinInfo *sjinfo,
List *restrictlist,
List *mergeclause_list,
SemiAntiJoinFactors *semafac,
Relids param_source_rels,
Relids extra_lateral_rels);
extern PGDLLIMPORT add_join_path_hook_type add_join_path_hook;
7

PostgreSQL Unconference #3
Custom Scan API (2/3)
エグゼキュータに介入するためのコールバック#1
typedef void (*InitCustomScanPlan_function)
(PlannerInfo *root,
CustomScan *cscan_plan,
CustomPath *cscan_path,
List *tlist,
List *scan_clauses);
typedef void (*SetPlanRefCustomScan_function)
(PlannerInfo *root,
CustomScan *cscan_plan,
int rtoffset);
typedef void (*BeginCustomScan_function)
(CustomScanState *csstate, int eflags);
typedef TupleTableSlot *
(*ExecCustomScan_function)(CustomScanState *csstate);

8

PostgreSQL Unconference #3
Custom Scan API (3/3)
エグゼキュータに介入するためのコールバック#2
typedef Node *(*MultiExecCustomScan_function)
(CustomScanState *csstate);
typedef void (*EndCustomScan_function)
(CustomScanState *csstate);
typedef void (*ReScanCustomScan_function)
(CustomScanState *csstate);
typedef void (*MarkPosCustomScan_function)
(CustomScanState *csstate);
typedef void (*RestorePosCustom_function)
(CustomScanState *csstate);
typedef void (*ExplainCustomScan_function)
(CustomScanState *csstate,
ExplainState *es);
9

PostgreSQL Unconference #3
PostgreSQLクエリ処理の流れ (1/2)
SQL
IndexScan

クエリ・パーサ (構文解析)

クエリ・オプティマイザ (最適化)

Path
Cost=100

IndexPath
Cost=5

クエリ・エグゼキュータ(実行)

SeqScan

IndexScan

結果セット
10

PostgreSQL Unconference #3

TidScan
PostgreSQLクエリ処理の流れ (2/3)
SQL
CustomScan

クエリ・パーサ (構文解析)

クエリ・オプティマイザ (最適化)

Path
Cost=100

IndexPath
Cost=5

クエリ・エグゼキュータ(実行)

SeqScan

IndexScan

Custom
ScanPath
Cost=1

Extension
モジュール

結果セット
11

TidScan

PostgreSQL Unconference #3

Custom
Scan
PostgreSQLクエリ処理の流れ (3/3)
SQL

クエリ・パーサ (構文解析)
実行開始

クエリ・オプティマイザ (最適化)

一行を取り出し

実行終了
クエリ・エグゼキュータ(実行)
再帰的な
呼び出しも…。

結果セット
12

Custom Scan API
Extension
モジュール

PostgreSQL Unconference #3
FDWとの違い
FDW / Foreign Table
 参照や更新の対象として使用できる。
 “一行を返す”時に、データ型は常にテーブル定義と
一致していなければならない。
 オブジェクトを実装する役割

Custom Scan API
 参照や更新の対象として使用できない
 “一行を返す” 時に、データ型を任意に定める事ができる。
(上位ノードの期待通りである事はモジュールの責任)
 メソッドを実装する役割

13

PostgreSQL Unconference #3
データ型が変動するとは?
SELECT * FROM t1 JOIN t2 ON t1.a = t2.x;
HeapTuple

JOIN
Scan t1

HeapTuple

事前にデータ型は
明らかであるのか?

Custom Scan
Scan t1

Scan t2

Scan t2

 テーブルスキャンを実装する場合、返却されるタプルの型は事前に明らか
CREATE TABLEで指定したデータ型
 JOINを実装する場合、返却されるタプルの型は毎回変わる
JOINされるテーブルの定義による
14

PostgreSQL Unconference #3
JoinをCustomScan APIで置き換えた例
Postgres_fdw への機能拡張
 Foreign table 同士のJOINで、
 同一のForeign serverにホストされており、
 結合条件がリモート実行可能なものである場合
postgres=# explain (costs off, verbose)
select * from ft1 where b like '%aaa%';
QUERY PLAN
---------------------------------------------------------Foreign Scan on public.ft1
Output: a, b
Remote SQL: SELECT a, b FROM public.t1
WHERE ((b ~~ '%aaa%'::text))
(3 rows)

15

PostgreSQL Unconference #3
JoinをCustomScan APIで置き換えた例
Postgres_fdw への機能拡張
 Foreign table 同士のJOINで、
 同一のForeign serverにホストされており、
 結合条件がリモート実行可能なものである場合
postgres=# explain (costs off, verbose)
select * from ft1 join ft2 on a = x
where b like '%aaa%';
QUERY PLAN
---------------------------------------------------------Custom Scan (postgres-fdw)
Output: a, b, x, y
Remote SQL: SELECT r1.a, r1.b, r2.x, r2.y FROM
(public.t1 r1 JOIN public.t2 r2 ON ((r1.a = r2.x)))
WHERE ((r1.b ~~ '%aaa%'::text))
(3 rows)
16

PostgreSQL Unconference #3
その他の利用例 (1/3) – Cache-only Scan
postgres=# EXPLAIN(costs off)
SELECT a,b FROM t1 WHERE a > b;
QUERY PLAN
--------------------------------------Custom Scan (cache scan) on t1
Filter: ((a)::double precision > b)
(2 rows)

エグゼキュータ

列A、Bのみ
キャッシュ
キャッシュヒット

Custom Scan
(cache_scan)
ミスヒット

17

heap

PostgreSQL Unconference #3
その他の利用例 (2/3) – Cache-only Scan
postgres=# EXPLAIN(costs off)
SELECT a,b FROM t1 WHERE a > b;
QUERY PLAN
--------------------------------------Custom Scan (cache scan) on t1
Filter: ((a)::double precision > b)
(2 rows)

エグゼキュータ

列A、Bのみ
キャッシュ
キャッシュヒット

Custom Scan
(cache_scan)
ミスヒット

18

heap

PostgreSQL Unconference #3

キャッシュに載ったデータを
GPGPUで”超”並列処理。
その他の利用例 (3/3) – Cheat Join
!!Just An Idea!!

(3,2)

(2,4)

PostgreSQL Unconference #3

(3,1)

(4,3)

:

19

(8,2)

(2,3)

Right
Relation

(7,3)

(2,2)

Left
Relation

(5,1)

(2,1)

Nest Loop

(4,2)

(1,5)

Custom Scan
(cheat join)

(7,3)

(1,4)

Cheat Join

Right
Tid

(1,3)

エグゼキュータ

Left
Tid
(1,2)

② カンペを参照
しつつ TidScan

:

① カンペを作成
Call for your feedback!

20

PostgreSQL Unconference #3

Mais conteúdo relacionado

Mais procurados

C#次世代非同期処理概観 - Task vs Reactive Extensions
C#次世代非同期処理概観 - Task vs Reactive ExtensionsC#次世代非同期処理概観 - Task vs Reactive Extensions
C#次世代非同期処理概観 - Task vs Reactive ExtensionsYoshifumi Kawai
 
GPUをJavaで使う話(Java Casual Talks #1)
GPUをJavaで使う話(Java Casual Talks #1)GPUをJavaで使う話(Java Casual Talks #1)
GPUをJavaで使う話(Java Casual Talks #1)なおき きしだ
 
About GStreamer 1.0 application development for beginners
About GStreamer 1.0 application development for beginnersAbout GStreamer 1.0 application development for beginners
About GStreamer 1.0 application development for beginnersShota TAMURA
 
async/await のしくみ
async/await のしくみasync/await のしくみ
async/await のしくみ信之 岩永
 
Qt Creator を拡張する
Qt Creator を拡張するQt Creator を拡張する
Qt Creator を拡張するTakumi Asaki
 
片手間MySQLチューニング戦略
片手間MySQLチューニング戦略片手間MySQLチューニング戦略
片手間MySQLチューニング戦略yoku0825
 
HandlerSocket plugin for MySQL
HandlerSocket plugin for MySQLHandlerSocket plugin for MySQL
HandlerSocket plugin for MySQLakirahiguchi
 
PostgreSQLの関数属性を知ろう
PostgreSQLの関数属性を知ろうPostgreSQLの関数属性を知ろう
PostgreSQLの関数属性を知ろうkasaharatt
 
Deep Dive async/await in Unity with UniTask(UniRx.Async)
Deep Dive async/await in Unity with UniTask(UniRx.Async)Deep Dive async/await in Unity with UniTask(UniRx.Async)
Deep Dive async/await in Unity with UniTask(UniRx.Async)Yoshifumi Kawai
 
Lisp Tutorial for Pythonista : Day 4
Lisp Tutorial for Pythonista : Day 4Lisp Tutorial for Pythonista : Day 4
Lisp Tutorial for Pythonista : Day 4Ransui Iso
 
History & Practices for UniRx UniRxの歴史、或いは開発(中)タイトルの用例と落とし穴の回避法
History & Practices for UniRx UniRxの歴史、或いは開発(中)タイトルの用例と落とし穴の回避法History & Practices for UniRx UniRxの歴史、或いは開発(中)タイトルの用例と落とし穴の回避法
History & Practices for UniRx UniRxの歴史、或いは開発(中)タイトルの用例と落とし穴の回避法Yoshifumi Kawai
 
CEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭する
CEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭するCEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭する
CEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭するYoshifumi Kawai
 
linq.js - Linq to Objects for JavaScript
linq.js - Linq to Objects for JavaScriptlinq.js - Linq to Objects for JavaScript
linq.js - Linq to Objects for JavaScriptYoshifumi Kawai
 
GoBGP活用によるSD-WANプラクティス
GoBGP活用によるSD-WANプラクティスGoBGP活用によるSD-WANプラクティス
GoBGP活用によるSD-WANプラクティスToshiki Tsuboi
 
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」Tsuyoshi Yamamoto
 

Mais procurados (20)

C#次世代非同期処理概観 - Task vs Reactive Extensions
C#次世代非同期処理概観 - Task vs Reactive ExtensionsC#次世代非同期処理概観 - Task vs Reactive Extensions
C#次世代非同期処理概観 - Task vs Reactive Extensions
 
GPUをJavaで使う話(Java Casual Talks #1)
GPUをJavaで使う話(Java Casual Talks #1)GPUをJavaで使う話(Java Casual Talks #1)
GPUをJavaで使う話(Java Casual Talks #1)
 
About GStreamer 1.0 application development for beginners
About GStreamer 1.0 application development for beginnersAbout GStreamer 1.0 application development for beginners
About GStreamer 1.0 application development for beginners
 
OSC2015kyoto
OSC2015kyotoOSC2015kyoto
OSC2015kyoto
 
Rx java x retrofit
Rx java x retrofitRx java x retrofit
Rx java x retrofit
 
async/await のしくみ
async/await のしくみasync/await のしくみ
async/await のしくみ
 
Qt Creator を拡張する
Qt Creator を拡張するQt Creator を拡張する
Qt Creator を拡張する
 
片手間MySQLチューニング戦略
片手間MySQLチューニング戦略片手間MySQLチューニング戦略
片手間MySQLチューニング戦略
 
HandlerSocket plugin for MySQL
HandlerSocket plugin for MySQLHandlerSocket plugin for MySQL
HandlerSocket plugin for MySQL
 
PostgreSQLの関数属性を知ろう
PostgreSQLの関数属性を知ろうPostgreSQLの関数属性を知ろう
PostgreSQLの関数属性を知ろう
 
Deep Dive async/await in Unity with UniTask(UniRx.Async)
Deep Dive async/await in Unity with UniTask(UniRx.Async)Deep Dive async/await in Unity with UniTask(UniRx.Async)
Deep Dive async/await in Unity with UniTask(UniRx.Async)
 
Lisp Tutorial for Pythonista : Day 4
Lisp Tutorial for Pythonista : Day 4Lisp Tutorial for Pythonista : Day 4
Lisp Tutorial for Pythonista : Day 4
 
20120721_ishkawa
20120721_ishkawa20120721_ishkawa
20120721_ishkawa
 
History & Practices for UniRx UniRxの歴史、或いは開発(中)タイトルの用例と落とし穴の回避法
History & Practices for UniRx UniRxの歴史、或いは開発(中)タイトルの用例と落とし穴の回避法History & Practices for UniRx UniRxの歴史、或いは開発(中)タイトルの用例と落とし穴の回避法
History & Practices for UniRx UniRxの歴史、或いは開発(中)タイトルの用例と落とし穴の回避法
 
CEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭する
CEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭するCEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭する
CEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭する
 
linq.js - Linq to Objects for JavaScript
linq.js - Linq to Objects for JavaScriptlinq.js - Linq to Objects for JavaScript
linq.js - Linq to Objects for JavaScript
 
GoBGP活用によるSD-WANプラクティス
GoBGP活用によるSD-WANプラクティスGoBGP活用によるSD-WANプラクティス
GoBGP活用によるSD-WANプラクティス
 
20130819 jjugnslt
20130819 jjugnslt20130819 jjugnslt
20130819 jjugnslt
 
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」
「Grails-1.1を斬る!〜Grails-1.1からのチーム開発〜」
 
Stream2の基本
Stream2の基本Stream2の基本
Stream2の基本
 

Semelhante a Custom Scan API - PostgreSQL Unconference #3 (18-Jan-2014)

Azure で Serverless 初心者向けタッチ&トライ
Azure で Serverless 初心者向けタッチ&トライAzure で Serverless 初心者向けタッチ&トライ
Azure で Serverless 初心者向けタッチ&トライMasanobu Sato
 
20170127 JAWS HPC-UG#8
20170127 JAWS HPC-UG#820170127 JAWS HPC-UG#8
20170127 JAWS HPC-UG#8Kohei KaiGai
 
20221111_JPUG_CustomScan_API
20221111_JPUG_CustomScan_API20221111_JPUG_CustomScan_API
20221111_JPUG_CustomScan_APIKohei KaiGai
 
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~normalian
 
T sql の parse と generator
T sql の parse と generatorT sql の parse と generator
T sql の parse と generatorOda Shinsuke
 
20190119 aws-study-pg-extension
20190119 aws-study-pg-extension20190119 aws-study-pg-extension
20190119 aws-study-pg-extensionToshi Harada
 
20181110 fok2018-pg-extension
20181110 fok2018-pg-extension20181110 fok2018-pg-extension
20181110 fok2018-pg-extensionToshi Harada
 
TypeScript 言語処理系ことはじめ
TypeScript 言語処理系ことはじめTypeScript 言語処理系ことはじめ
TypeScript 言語処理系ことはじめYu Nobuoka
 
Next2Dで始めるゲーム開発 - Game Development Starting with Next2D
Next2Dで始めるゲーム開発  - Game Development Starting with Next2DNext2Dで始めるゲーム開発  - Game Development Starting with Next2D
Next2Dで始めるゲーム開発 - Game Development Starting with Next2DToshiyuki Ienaga
 
ソーシャルアプリ勉強会(第一回資料)配布用
ソーシャルアプリ勉強会(第一回資料)配布用ソーシャルアプリ勉強会(第一回資料)配布用
ソーシャルアプリ勉強会(第一回資料)配布用Yatabe Terumasa
 
DTraceによるMySQL解析ことはじめ
DTraceによるMySQL解析ことはじめDTraceによるMySQL解析ことはじめ
DTraceによるMySQL解析ことはじめMikiya Okuno
 
Elasticsearchプラグインの作り方
Elasticsearchプラグインの作り方Elasticsearchプラグインの作り方
Elasticsearchプラグインの作り方Shinsuke Sugaya
 
Apache Torqueについて
Apache TorqueについてApache Torqueについて
Apache Torqueについてtako pons
 
PostgreSQL - C言語によるユーザ定義関数の作り方
PostgreSQL - C言語によるユーザ定義関数の作り方PostgreSQL - C言語によるユーザ定義関数の作り方
PostgreSQL - C言語によるユーザ定義関数の作り方Satoshi Nagayasu
 
20141017 introduce razor
20141017 introduce razor20141017 introduce razor
20141017 introduce razordo_aki
 
Infrastructure as code for azure
Infrastructure as code for azureInfrastructure as code for azure
Infrastructure as code for azureKeiji Kamebuchi
 
20090107 Postgre Sqlチューニング(Sql編)
20090107 Postgre Sqlチューニング(Sql編)20090107 Postgre Sqlチューニング(Sql編)
20090107 Postgre Sqlチューニング(Sql編)Hiromu Shioya
 
Inside mobage platform
Inside mobage platformInside mobage platform
Inside mobage platformToru Yamaguchi
 

Semelhante a Custom Scan API - PostgreSQL Unconference #3 (18-Jan-2014) (20)

Ajax 応用
Ajax 応用Ajax 応用
Ajax 応用
 
Azure で Serverless 初心者向けタッチ&トライ
Azure で Serverless 初心者向けタッチ&トライAzure で Serverless 初心者向けタッチ&トライ
Azure で Serverless 初心者向けタッチ&トライ
 
20170127 JAWS HPC-UG#8
20170127 JAWS HPC-UG#820170127 JAWS HPC-UG#8
20170127 JAWS HPC-UG#8
 
20221111_JPUG_CustomScan_API
20221111_JPUG_CustomScan_API20221111_JPUG_CustomScan_API
20221111_JPUG_CustomScan_API
 
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~
基礎から見直す ASP.NET MVC の単体テスト自動化方法 ~ Windows Azure 関連もあるかも~
 
T sql の parse と generator
T sql の parse と generatorT sql の parse と generator
T sql の parse と generator
 
20190119 aws-study-pg-extension
20190119 aws-study-pg-extension20190119 aws-study-pg-extension
20190119 aws-study-pg-extension
 
20181110 fok2018-pg-extension
20181110 fok2018-pg-extension20181110 fok2018-pg-extension
20181110 fok2018-pg-extension
 
TypeScript 言語処理系ことはじめ
TypeScript 言語処理系ことはじめTypeScript 言語処理系ことはじめ
TypeScript 言語処理系ことはじめ
 
Next2Dで始めるゲーム開発 - Game Development Starting with Next2D
Next2Dで始めるゲーム開発  - Game Development Starting with Next2DNext2Dで始めるゲーム開発  - Game Development Starting with Next2D
Next2Dで始めるゲーム開発 - Game Development Starting with Next2D
 
ソーシャルアプリ勉強会(第一回資料)配布用
ソーシャルアプリ勉強会(第一回資料)配布用ソーシャルアプリ勉強会(第一回資料)配布用
ソーシャルアプリ勉強会(第一回資料)配布用
 
DTraceによるMySQL解析ことはじめ
DTraceによるMySQL解析ことはじめDTraceによるMySQL解析ことはじめ
DTraceによるMySQL解析ことはじめ
 
Elasticsearchプラグインの作り方
Elasticsearchプラグインの作り方Elasticsearchプラグインの作り方
Elasticsearchプラグインの作り方
 
Apache Torqueについて
Apache TorqueについてApache Torqueについて
Apache Torqueについて
 
PostgreSQL - C言語によるユーザ定義関数の作り方
PostgreSQL - C言語によるユーザ定義関数の作り方PostgreSQL - C言語によるユーザ定義関数の作り方
PostgreSQL - C言語によるユーザ定義関数の作り方
 
20141017 introduce razor
20141017 introduce razor20141017 introduce razor
20141017 introduce razor
 
gRPCurlDotNet.pptx
gRPCurlDotNet.pptxgRPCurlDotNet.pptx
gRPCurlDotNet.pptx
 
Infrastructure as code for azure
Infrastructure as code for azureInfrastructure as code for azure
Infrastructure as code for azure
 
20090107 Postgre Sqlチューニング(Sql編)
20090107 Postgre Sqlチューニング(Sql編)20090107 Postgre Sqlチューニング(Sql編)
20090107 Postgre Sqlチューニング(Sql編)
 
Inside mobage platform
Inside mobage platformInside mobage platform
Inside mobage platform
 

Mais de Kohei KaiGai

20221116_DBTS_PGStrom_History
20221116_DBTS_PGStrom_History20221116_DBTS_PGStrom_History
20221116_DBTS_PGStrom_HistoryKohei KaiGai
 
20211112_jpugcon_gpu_and_arrow
20211112_jpugcon_gpu_and_arrow20211112_jpugcon_gpu_and_arrow
20211112_jpugcon_gpu_and_arrowKohei KaiGai
 
20210928_pgunconf_hll_count
20210928_pgunconf_hll_count20210928_pgunconf_hll_count
20210928_pgunconf_hll_countKohei KaiGai
 
20210731_OSC_Kyoto_PGStrom3.0
20210731_OSC_Kyoto_PGStrom3.020210731_OSC_Kyoto_PGStrom3.0
20210731_OSC_Kyoto_PGStrom3.0Kohei KaiGai
 
20210511_PGStrom_GpuCache
20210511_PGStrom_GpuCache20210511_PGStrom_GpuCache
20210511_PGStrom_GpuCacheKohei KaiGai
 
20210301_PGconf_Online_GPU_PostGIS_GiST_Index
20210301_PGconf_Online_GPU_PostGIS_GiST_Index20210301_PGconf_Online_GPU_PostGIS_GiST_Index
20210301_PGconf_Online_GPU_PostGIS_GiST_IndexKohei KaiGai
 
20201128_OSC_Fukuoka_Online_GPUPostGIS
20201128_OSC_Fukuoka_Online_GPUPostGIS20201128_OSC_Fukuoka_Online_GPUPostGIS
20201128_OSC_Fukuoka_Online_GPUPostGISKohei KaiGai
 
20201113_PGconf_Japan_GPU_PostGIS
20201113_PGconf_Japan_GPU_PostGIS20201113_PGconf_Japan_GPU_PostGIS
20201113_PGconf_Japan_GPU_PostGISKohei KaiGai
 
20201006_PGconf_Online_Large_Data_Processing
20201006_PGconf_Online_Large_Data_Processing20201006_PGconf_Online_Large_Data_Processing
20201006_PGconf_Online_Large_Data_ProcessingKohei KaiGai
 
20200828_OSCKyoto_Online
20200828_OSCKyoto_Online20200828_OSCKyoto_Online
20200828_OSCKyoto_OnlineKohei KaiGai
 
20200806_PGStrom_PostGIS_GstoreFdw
20200806_PGStrom_PostGIS_GstoreFdw20200806_PGStrom_PostGIS_GstoreFdw
20200806_PGStrom_PostGIS_GstoreFdwKohei KaiGai
 
20200424_Writable_Arrow_Fdw
20200424_Writable_Arrow_Fdw20200424_Writable_Arrow_Fdw
20200424_Writable_Arrow_FdwKohei KaiGai
 
20191211_Apache_Arrow_Meetup_Tokyo
20191211_Apache_Arrow_Meetup_Tokyo20191211_Apache_Arrow_Meetup_Tokyo
20191211_Apache_Arrow_Meetup_TokyoKohei KaiGai
 
20191115-PGconf.Japan
20191115-PGconf.Japan20191115-PGconf.Japan
20191115-PGconf.JapanKohei KaiGai
 
20190926_Try_RHEL8_NVMEoF_Beta
20190926_Try_RHEL8_NVMEoF_Beta20190926_Try_RHEL8_NVMEoF_Beta
20190926_Try_RHEL8_NVMEoF_BetaKohei KaiGai
 
20190925_DBTS_PGStrom
20190925_DBTS_PGStrom20190925_DBTS_PGStrom
20190925_DBTS_PGStromKohei KaiGai
 
20190909_PGconf.ASIA_KaiGai
20190909_PGconf.ASIA_KaiGai20190909_PGconf.ASIA_KaiGai
20190909_PGconf.ASIA_KaiGaiKohei KaiGai
 
20190516_DLC10_PGStrom
20190516_DLC10_PGStrom20190516_DLC10_PGStrom
20190516_DLC10_PGStromKohei KaiGai
 
20190418_PGStrom_on_ArrowFdw
20190418_PGStrom_on_ArrowFdw20190418_PGStrom_on_ArrowFdw
20190418_PGStrom_on_ArrowFdwKohei KaiGai
 
20190314 PGStrom Arrow_Fdw
20190314 PGStrom Arrow_Fdw20190314 PGStrom Arrow_Fdw
20190314 PGStrom Arrow_FdwKohei KaiGai
 

Mais de Kohei KaiGai (20)

20221116_DBTS_PGStrom_History
20221116_DBTS_PGStrom_History20221116_DBTS_PGStrom_History
20221116_DBTS_PGStrom_History
 
20211112_jpugcon_gpu_and_arrow
20211112_jpugcon_gpu_and_arrow20211112_jpugcon_gpu_and_arrow
20211112_jpugcon_gpu_and_arrow
 
20210928_pgunconf_hll_count
20210928_pgunconf_hll_count20210928_pgunconf_hll_count
20210928_pgunconf_hll_count
 
20210731_OSC_Kyoto_PGStrom3.0
20210731_OSC_Kyoto_PGStrom3.020210731_OSC_Kyoto_PGStrom3.0
20210731_OSC_Kyoto_PGStrom3.0
 
20210511_PGStrom_GpuCache
20210511_PGStrom_GpuCache20210511_PGStrom_GpuCache
20210511_PGStrom_GpuCache
 
20210301_PGconf_Online_GPU_PostGIS_GiST_Index
20210301_PGconf_Online_GPU_PostGIS_GiST_Index20210301_PGconf_Online_GPU_PostGIS_GiST_Index
20210301_PGconf_Online_GPU_PostGIS_GiST_Index
 
20201128_OSC_Fukuoka_Online_GPUPostGIS
20201128_OSC_Fukuoka_Online_GPUPostGIS20201128_OSC_Fukuoka_Online_GPUPostGIS
20201128_OSC_Fukuoka_Online_GPUPostGIS
 
20201113_PGconf_Japan_GPU_PostGIS
20201113_PGconf_Japan_GPU_PostGIS20201113_PGconf_Japan_GPU_PostGIS
20201113_PGconf_Japan_GPU_PostGIS
 
20201006_PGconf_Online_Large_Data_Processing
20201006_PGconf_Online_Large_Data_Processing20201006_PGconf_Online_Large_Data_Processing
20201006_PGconf_Online_Large_Data_Processing
 
20200828_OSCKyoto_Online
20200828_OSCKyoto_Online20200828_OSCKyoto_Online
20200828_OSCKyoto_Online
 
20200806_PGStrom_PostGIS_GstoreFdw
20200806_PGStrom_PostGIS_GstoreFdw20200806_PGStrom_PostGIS_GstoreFdw
20200806_PGStrom_PostGIS_GstoreFdw
 
20200424_Writable_Arrow_Fdw
20200424_Writable_Arrow_Fdw20200424_Writable_Arrow_Fdw
20200424_Writable_Arrow_Fdw
 
20191211_Apache_Arrow_Meetup_Tokyo
20191211_Apache_Arrow_Meetup_Tokyo20191211_Apache_Arrow_Meetup_Tokyo
20191211_Apache_Arrow_Meetup_Tokyo
 
20191115-PGconf.Japan
20191115-PGconf.Japan20191115-PGconf.Japan
20191115-PGconf.Japan
 
20190926_Try_RHEL8_NVMEoF_Beta
20190926_Try_RHEL8_NVMEoF_Beta20190926_Try_RHEL8_NVMEoF_Beta
20190926_Try_RHEL8_NVMEoF_Beta
 
20190925_DBTS_PGStrom
20190925_DBTS_PGStrom20190925_DBTS_PGStrom
20190925_DBTS_PGStrom
 
20190909_PGconf.ASIA_KaiGai
20190909_PGconf.ASIA_KaiGai20190909_PGconf.ASIA_KaiGai
20190909_PGconf.ASIA_KaiGai
 
20190516_DLC10_PGStrom
20190516_DLC10_PGStrom20190516_DLC10_PGStrom
20190516_DLC10_PGStrom
 
20190418_PGStrom_on_ArrowFdw
20190418_PGStrom_on_ArrowFdw20190418_PGStrom_on_ArrowFdw
20190418_PGStrom_on_ArrowFdw
 
20190314 PGStrom Arrow_Fdw
20190314 PGStrom Arrow_Fdw20190314 PGStrom Arrow_Fdw
20190314 PGStrom Arrow_Fdw
 

Último

新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptxsn679259
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Gamesatsushi061452
 
Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsWSO2
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルCRI Japan, Inc.
 
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Hiroshi Tomioka
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...Toru Tamaki
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。iPride Co., Ltd.
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイスCRI Japan, Inc.
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video UnderstandingToru Tamaki
 

Último (11)

新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
知識ゼロの営業マンでもできた!超速で初心者を脱する、悪魔的学習ステップ3選.pptx
 
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
 
Utilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native IntegrationsUtilizing Ballerina for Cloud Native Integrations
Utilizing Ballerina for Cloud Native Integrations
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
 
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
 

Custom Scan API - PostgreSQL Unconference #3 (18-Jan-2014)

  • 1. Custom Scan API KaiGai Kohei <kaigai@kaigai.gr.jp> (Tw: @kkaigai)
  • 2. 自己紹介  海外 浩平 (かいがい こうへい) 最近、国内に戻ってきました。  SE-PostgreSQLやPG-Stromを作っています。 2 PostgreSQL Unconference #3
  • 3. Custom Scan APIとは Extensionがエグゼキュータ処理を乗っ取るAPI 俺様的方法で Scan を実装できる 俺様的方法で Join を実装できる (俺様的方法で Xxxx を実装できる) PostgreSQL v9.4 の標準機能化に向けて議論の途中 3 PostgreSQL Unconference #3
  • 4. ExecutorXXX_hook ではダメなのか?(1/3) /* Hook for plugins to get control in ExecutorStart() */ typedef void (*ExecutorStart_hook_type) (QueryDesc *queryDesc, int eflags); extern PGDLLIMPORT ExecutorStart_hook_type ExecutorStart_hook; /* Hook for plugins to get control in ExecutorRun() */ typedef void (*ExecutorRun_hook_type) (QueryDesc *queryDesc, ScanDirection direction, long count); extern PGDLLIMPORT ExecutorRun_hook_type ExecutorRun_hook; /* Hook for plugins to get control in ExecutorFinish() */ typedef void (*ExecutorFinish_hook_type) (QueryDesc *queryDesc); extern PGDLLIMPORT ExecutorFinish_hook_type ExecutorFinish_hook; /* Hook for plugins to get control in ExecutorEnd() */ typedef void (*ExecutorEnd_hook_type) (QueryDesc *queryDesc); extern PGDLLIMPORT ExecutorEnd_hook_type ExecutorEnd_hook; 4 PostgreSQL Unconference #3
  • 5. ExecutorXXX_hook ではダメなのか?(2/3) postgres=# explain(costs off) select y from l_tbl join r_tbl on a = x group by y,b order by b; QUERY PLAN ------------------------------------------------独自のソート実装を Group エクステンションとし Group Key: l_tbl.b, r_tbl.y て実装できるか? -> Sort Sort Key: l_tbl.b, r_tbl.y -> Merge Join Merge Cond: (l_tbl.a = r_tbl.x) -> Sort Sort Key: l_tbl.a -> Seq Scan on l_tbl -> Materialize -> Sort Sort Key: r_tbl.x -> Seq Scan on r_tbl (13 rows) 5 PostgreSQL Unconference #3
  • 6. ExecutorXXX_hook ではダメなのか?(3/3) TupleTableSlot *ExecProcNode(PlanState *node) { : switch (nodeTag(node)) { : case T_SeqScanState: result = ExecSeqScan((SeqScanState *) node); break; : default: elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node)); result = NULL; break; } 何か 『任意の処理を行う』 ノードを return result; PostgreSQL本体が認識できる } 必要がある。 6 PostgreSQL Unconference #3
  • 7. Custom Scan API (1/3)  オプティマイザへ介入するためのフック /* Hook for plugins to add custom scan path */ typedef void (*add_scan_path_hook_type)(PlannerInfo *root, RelOptInfo *baserel, RangeTblEntry *rte); extern PGDLLIMPORT add_scan_path_hook_type add_scan_path_hook; /* Hook for plugins to add custom join path */ typedef void (*add_join_path_hook_type)(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, JoinType jointype, SpecialJoinInfo *sjinfo, List *restrictlist, List *mergeclause_list, SemiAntiJoinFactors *semafac, Relids param_source_rels, Relids extra_lateral_rels); extern PGDLLIMPORT add_join_path_hook_type add_join_path_hook; 7 PostgreSQL Unconference #3
  • 8. Custom Scan API (2/3) エグゼキュータに介入するためのコールバック#1 typedef void (*InitCustomScanPlan_function) (PlannerInfo *root, CustomScan *cscan_plan, CustomPath *cscan_path, List *tlist, List *scan_clauses); typedef void (*SetPlanRefCustomScan_function) (PlannerInfo *root, CustomScan *cscan_plan, int rtoffset); typedef void (*BeginCustomScan_function) (CustomScanState *csstate, int eflags); typedef TupleTableSlot * (*ExecCustomScan_function)(CustomScanState *csstate); 8 PostgreSQL Unconference #3
  • 9. Custom Scan API (3/3) エグゼキュータに介入するためのコールバック#2 typedef Node *(*MultiExecCustomScan_function) (CustomScanState *csstate); typedef void (*EndCustomScan_function) (CustomScanState *csstate); typedef void (*ReScanCustomScan_function) (CustomScanState *csstate); typedef void (*MarkPosCustomScan_function) (CustomScanState *csstate); typedef void (*RestorePosCustom_function) (CustomScanState *csstate); typedef void (*ExplainCustomScan_function) (CustomScanState *csstate, ExplainState *es); 9 PostgreSQL Unconference #3
  • 10. PostgreSQLクエリ処理の流れ (1/2) SQL IndexScan クエリ・パーサ (構文解析) クエリ・オプティマイザ (最適化) Path Cost=100 IndexPath Cost=5 クエリ・エグゼキュータ(実行) SeqScan IndexScan 結果セット 10 PostgreSQL Unconference #3 TidScan
  • 11. PostgreSQLクエリ処理の流れ (2/3) SQL CustomScan クエリ・パーサ (構文解析) クエリ・オプティマイザ (最適化) Path Cost=100 IndexPath Cost=5 クエリ・エグゼキュータ(実行) SeqScan IndexScan Custom ScanPath Cost=1 Extension モジュール 結果セット 11 TidScan PostgreSQL Unconference #3 Custom Scan
  • 12. PostgreSQLクエリ処理の流れ (3/3) SQL クエリ・パーサ (構文解析) 実行開始 クエリ・オプティマイザ (最適化) 一行を取り出し 実行終了 クエリ・エグゼキュータ(実行) 再帰的な 呼び出しも…。 結果セット 12 Custom Scan API Extension モジュール PostgreSQL Unconference #3
  • 13. FDWとの違い FDW / Foreign Table  参照や更新の対象として使用できる。  “一行を返す”時に、データ型は常にテーブル定義と 一致していなければならない。  オブジェクトを実装する役割 Custom Scan API  参照や更新の対象として使用できない  “一行を返す” 時に、データ型を任意に定める事ができる。 (上位ノードの期待通りである事はモジュールの責任)  メソッドを実装する役割 13 PostgreSQL Unconference #3
  • 14. データ型が変動するとは? SELECT * FROM t1 JOIN t2 ON t1.a = t2.x; HeapTuple JOIN Scan t1 HeapTuple 事前にデータ型は 明らかであるのか? Custom Scan Scan t1 Scan t2 Scan t2  テーブルスキャンを実装する場合、返却されるタプルの型は事前に明らか CREATE TABLEで指定したデータ型  JOINを実装する場合、返却されるタプルの型は毎回変わる JOINされるテーブルの定義による 14 PostgreSQL Unconference #3
  • 15. JoinをCustomScan APIで置き換えた例 Postgres_fdw への機能拡張  Foreign table 同士のJOINで、  同一のForeign serverにホストされており、  結合条件がリモート実行可能なものである場合 postgres=# explain (costs off, verbose) select * from ft1 where b like '%aaa%'; QUERY PLAN ---------------------------------------------------------Foreign Scan on public.ft1 Output: a, b Remote SQL: SELECT a, b FROM public.t1 WHERE ((b ~~ '%aaa%'::text)) (3 rows) 15 PostgreSQL Unconference #3
  • 16. JoinをCustomScan APIで置き換えた例 Postgres_fdw への機能拡張  Foreign table 同士のJOINで、  同一のForeign serverにホストされており、  結合条件がリモート実行可能なものである場合 postgres=# explain (costs off, verbose) select * from ft1 join ft2 on a = x where b like '%aaa%'; QUERY PLAN ---------------------------------------------------------Custom Scan (postgres-fdw) Output: a, b, x, y Remote SQL: SELECT r1.a, r1.b, r2.x, r2.y FROM (public.t1 r1 JOIN public.t2 r2 ON ((r1.a = r2.x))) WHERE ((r1.b ~~ '%aaa%'::text)) (3 rows) 16 PostgreSQL Unconference #3
  • 17. その他の利用例 (1/3) – Cache-only Scan postgres=# EXPLAIN(costs off) SELECT a,b FROM t1 WHERE a > b; QUERY PLAN --------------------------------------Custom Scan (cache scan) on t1 Filter: ((a)::double precision > b) (2 rows) エグゼキュータ 列A、Bのみ キャッシュ キャッシュヒット Custom Scan (cache_scan) ミスヒット 17 heap PostgreSQL Unconference #3
  • 18. その他の利用例 (2/3) – Cache-only Scan postgres=# EXPLAIN(costs off) SELECT a,b FROM t1 WHERE a > b; QUERY PLAN --------------------------------------Custom Scan (cache scan) on t1 Filter: ((a)::double precision > b) (2 rows) エグゼキュータ 列A、Bのみ キャッシュ キャッシュヒット Custom Scan (cache_scan) ミスヒット 18 heap PostgreSQL Unconference #3 キャッシュに載ったデータを GPGPUで”超”並列処理。
  • 19. その他の利用例 (3/3) – Cheat Join !!Just An Idea!! (3,2) (2,4) PostgreSQL Unconference #3 (3,1) (4,3) : 19 (8,2) (2,3) Right Relation (7,3) (2,2) Left Relation (5,1) (2,1) Nest Loop (4,2) (1,5) Custom Scan (cheat join) (7,3) (1,4) Cheat Join Right Tid (1,3) エグゼキュータ Left Tid (1,2) ② カンペを参照 しつつ TidScan : ① カンペを作成
  • 20. Call for your feedback! 20 PostgreSQL Unconference #3