postgresql 中的 large object

//主要有下面两个系统表,pg_largeobject_metadata主要记录权限的,有用的只有pg_largeobject



CATALOG(pg_largeobject_metadata,2995)
{
	Oid			lomowner;		/* OID of the largeobject owner */
#ifdef CATALOG_VARLEN			/* variable-length fields start here */
	aclitem		lomacl[1];		/* access permissions */
#endif
} FormData_pg_largeobject_metadata;

/*
 * Each "page" (tuple) of a large object can hold this much data
 *
 * We could set this as high as BLCKSZ less some overhead, but it seems
 * better to make it a smaller value, so that not as much space is used
 * up when a page-tuple is updated.  Note that the value is deliberately
 * chosen large enough to trigger the tuple toaster, so that we will
 * attempt to compress page tuples in-line.  (But they won't be moved off
 * unless the user creates a toast-table for pg_largeobject...)
 *
 * Also, it seems to be a smart move to make the page size be a power of 2,
 * since clients will often be written to send data in power-of-2 blocks.
 * This avoids unnecessary tuple updates caused by partial-page writes.
 */
#define LOBLKSIZE  (BLCKSZ / 4)

CATALOG(pg_largeobject,2613) BKI_WITHOUT_OIDS
{
	Oid			loid;			/* Identifier of large object */
	int4		pageno;			/* Page number (starting from 0) */
	/* data has variable length, but we allow direct access; see inv_api.c */
	bytea		data;			/* Data for page (may be zero-length) */
} FormData_pg_largeobject;



所有的大对象全部拆成 LOBLKSIZE  大小,放入 pg_largeobject 之中,通过 loid进行区分, 每个大对象拆分成的各个部分通过 pageno(叫元组序号更合理),进行顺序的关联起来,

pageno是通过 要写入的数据offset / LOBLKSIZE  计算的
 

pg的大对象实现的比较简单,并不适合大数据量的使用,会成为系统的瓶颈.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值