作者
digoal
日期
2020-07-20
标签
PostgreSQL , 逻辑订阅 , logical , binary
背景
PostgreSQL 14支持使用binary格式传输逻辑订阅数据. (暂时不包括用户自定义数组和composite类型)
支持内置的订阅接口, create/alter subscription时定义binary选项. 效率更高.
```
Allow logical replication to transfer data in binary format.
author Tom Lane tgl@sss.pgh.pa.us
Sun, 19 Jul 2020 00:44:51 +0800 (12:44 -0400)
committer Tom Lane tgl@sss.pgh.pa.us
Sun, 19 Jul 2020 00:44:51 +0800 (12:44 -0400)
commit 9de77b5453130242654ff0b30a551c9c862ed661
tree 9c48ed25ee4711934006078939a834186c8e9727 tree | snapshot
parent 9add405014f8e47e038af7124528b7601249a2ac commit | diff
Allow logical replication to transfer data in binary format.
This patch adds a "binary" option to CREATE/ALTER SUBSCRIPTION.
When that's set, the publisher will send data using the data type's
typsend function if any, rather than typoutput. This is generally
faster, if slightly less robust.
As committed, we won't try to transfer user-defined array or composite
types in binary, for fear that type OIDs won't match at the subscriber.
This might be changed later, but it seems like fit material for a
follow-on patch.
Dave Cramer, reviewed by Daniel Gustafsson, Petr Jelinek, and others;
adjusted some by me
Discussion: https://postgr.es/m/CADK3HH+R3xMn=8t3Ct+uD+qJ1KD=Hbif5NFMJ+d5DkoCzp6Vgw@mail.gmail.com
```
各种类型的binary格式函数如下
recv
send
```
postgres=# \df .send
List of functions
Schema | Name | Result data type | Argument data types | Type
------------+-------------------------+------------------+-----------------------------+------
pg_catalog | anyarray_send | bytea | anyarray | func
pg_catalog | anycompatiblearray_send | bytea | anycompatiblearray | func
pg_catalog | array_send | bytea | anyarray | func
pg_catalog | bit_send | bytea | bit | func
pg_catalog | boolsend | bytea | boolean | func
pg_catalog | box_send | bytea | box | func
pg_catalog | bpcharsend | bytea | character | func
pg_catalog | byteasend | bytea | bytea | func
pg_catalog | cash_send | bytea | money | func
... ...
postgres=# \df .recv
List of functions
Schema | Name | Result data type | Argument data types | Type
------------+-------------------------+-----------------------------+------------------------+------
pg_catalog | anyarray_recv | anyarray | internal | func
pg_catalog | anycompatiblearray_recv | anycompatiblearray | internal | func
pg_catalog | array_recv | anyarray | internal, oid, integer | func
pg_catalog | bit_recv | bit | internal, oid, integer | func
pg_catalog | boolrecv | boolean | internal | func
pg_catalog | box_recv | box | internal | func
pg_catalog | bpcharrecv | character | internal, oid, integer | func
pg_catalog | bytearecv | bytea | internal | func
pg_catalog | cash_recv | money | internal | func
... ...
```
各种类型的字符格式函数如下
in
out
```
postgres=# \df .out
List of functions
Schema | Name | Result data type | Argument data types | Type
------------+---------------------------+------------------+-----------------------------+------
pg_catalog | aclitemout | cstring | aclitem | func
pg_catalog | any_out | cstring | "any" | func
pg_catalog | anyarray_out | cstring | anyarray | func
pg_catalog | anycompatible_out | cstring | anycompatible | func
pg_catalog | anycompatiblearray_out | cstring | anycompatiblearray | func
pg_catalog | anycompatiblenonarray_out | cstring | anycompatiblenonarray | func
pg_catalog | anycompatiblerange_out | cstring | anycompatiblerange | func
pg_catalog | anyelement_out | cstring | anyelement | func
pg_catalog | anyenum_out | cstring | anyenum | func
pg_catalog | anynonarray_out | cstring | anynonarray | func
pg_catalog | anyrange_out | cstring | anyrange | func
pg_catalog | array_out | cstring | anyarray | func
... ...
postgres=# \df .in
List of functions
Schema | Name | Result data type | Argument data types | Type
------------+-----------------------------------+-----------------------------+----------------------------------------------+------
pg_catalog | aclitemin | aclitem | cstring | func
pg_catalog | any_in | "any" | cstring | func
pg_catalog | anyarray_in | anyarray | cstring | func
pg_catalog | anycompatible_in | anycompatible | cstring | func
pg_catalog | anycompatiblearray_in | anycompatiblearray | cstring | func
pg_catalog | anycompatiblenonarray_in | anycompatiblenonarray | cstring | func
pg_catalog | anycompatiblerange_in | anycompatiblerange | cstring, oid, integer | func
pg_catalog | anyelement_in | anyelement | cstring | func
pg_catalog | anyenum_in | anyenum | cstring | func
pg_catalog | anynonarray_in | anynonarray | cstring | func
pg_catalog | anyrange_in | anyrange | cstring, oid, integer | func
pg_catalog | array_in | anyarray | cstring, oid, integer | func
pg_catalog | asin | double precision | double precision | func
pg_catalog | bit_in | bit | cstring, oid, integer | func
pg_catalog | bittypmodin | integer | cstring[] | func
... ...
```
参考
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=9de77b5453130242654ff0b30a551c9c862ed661
PostgreSQL 许愿链接
您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.
9.9元购买3个月阿里云RDS PostgreSQL实例
PostgreSQL 解决方案集合
德哥 / digoal's github - 公益是一辈子的事.





