作者
digoal
日期
2018-03-22
标签
PostgreSQL , postgrespro
背景
postgrespro支持in-memory插件,实际上是位于内存中的索引组织表。 并且支持在standby节点中写入数据, 例如用于存储standby分析业务逻辑的中间结果。
https://postgrespro.com/docs/enterprise/11/in-memory
https://postgrespro.com/docs/enterprise/12/in-memory
目标场景:
基于索引KEY值查询非常频繁的场景。
原理:
1、使用了索引组织存储。
2、内存表使用固定PAGE大小,1KB。考虑到数据是索引组织一条记录不能跨页存储,所以行的最大长度为三分之一页大小,也就是304字节。
3、不能使用toast特性。
使用限制:
1、最高隔离级别为repetable read模式
2、不支持二级索引
3、当tuple被删除时,不会修改in-memory表,所以数据还残留。不适合大量更新或删除。适合read only的情况。
in-memory插件相关参数和函数
F.22.3. Reference
F.22.3.1. Configuration Variables
```
in_memory.shared_pool_size (integer)
Defines the size of the shared memory segment allocated for in-memory tables.
Default: 8MB
in_memory.undo_size (integer)
Defines the size of the undo log.
Default: 1MB
```
F.22.3.2. Functions
in_memory.in_memory_page_stats()
Displays statistics on pages of in-memory tables:
used_pages — in-memory pages containing any data.
free_pages — empty in-memory pages. This number includes all the initially allocated pages to which no data has been written yet, as well as the pages from which all data has been deleted.
all_pages — the total number of in-memory pages allocated on this server.
PostgreSQL 许愿链接
您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.