透过pageinspect了解PostgreSQl中的page

  • 时间:
  • 浏览:1
  • 来源:大发彩神幸运飞艇_大发神彩幸运飞艇官方

    BlockIdData ip_blkid;

    uint8       t_hoff;        

                lp_flags:2,    

        lp_off:tuple在page中的位置。         lp_flags:tuple的flags,具体为 

postgres=# select lp,lp_off,lp_flags,lp_len from heap_page_items(get_raw_page('mvcc', 'main', 0));

PostgreSQL 11 preview - 并行排序、并行索引 (性能线性暴增) 单实例400亿TOP-K仅40秒

    {

#define HEAP_MOVED_OFF          0x4000  /* moved to another place by pre-9.0

 Oid            datum_typeid;  

postgres=# select * from page_header(get_raw_page('mvcc', 'main', 0));

#define HEAP_COMBOCID           0x0020  /* t_cid is a combo cid */

PostgreSQL pageinspect 诊断与优化GIN (倒排) 索引合并延迟原因的查询性能下降难题

typedef struct ItemIdData

 0/400F4D8 |        0 |     0 |    32 |  8128 |    8192 |     8192 |       4 | 

 lp | lp_off | lp_flags | lp_len | t_xmin | t_xmax | t_field3 | t_ctid | t_infom

[postgres@localhost bin]$ ./psql

 *      added the pd_flags field (by stealing some bits from pd_tli),

} BlockIdData;

#define HEAP2_XACT_MASK         0xE000  /* visibility-related bits */

#define PD_HAS_FREE_LINES   0x0001      /* are there any unused line pointers? */

        下面通过例子来对page的PageHeaderDataItemIddata和HeapTupleHeaderData进行说明

        a.建表mvcc

 * Page layout version number 0 is for pre-7.3 Postgres releases.

postgres=# insert into mvcc values (1),(2);

(2 rows)

pageinsepect分析brin索引

    }           t_choice;

 lp | lp_off | lp_flags | lp_len

#define HEAP_KEYS_UPDATED       0x4000  /* tuple was updated and key cols

    PageXLogRecPtr pd_lsn;     

深入浅出PostgreSQL B-Tree索引形态学

{

} ItemIdData;

PostgreSQL 老湿机图解平安科技遇到的垃圾回收"坑"

    uint16      pd_checksum;   

#define HEAP_HASNULL            0x0001  /* has null attribute(s) */

#define LP_DEAD         3       /* dead, may or may not have storage */

PostgreSQL 末尾块收缩(如pg_type pg_attribute)异常和patch

#define HEAP_ONLY_TUPLE         0x40000  /* this is heap-only tuple */

        TransactionId t_xvac;  

                                         * modified, or tuple deleted */

        DatumTupleFields t_datum;

    uint16      bi_hi;

   1 |       2048 |     24 |        |     

    union

 * Release 8.1 uses 3; it redefined HeapTupleHeader infomask bits.

        d.HeapTupleHeaderData

(1 row)

    TransactionId pd_prune_xid;

  1 |   81400 |        1 |     28

#define HEAP_XMAX_IS_MULTI      0x4000  /* t_xmax is a MultiXactId */

    ItemIdData  pd_linp[1];    

                lp_len:15;     

        CommandId   t_cid;     

postgres=# create table mvcc(id int);

} HeapTupleFields;

#define HEAP_XMAX_EXCL_LOCK     0x0040  /* xmax is exclusive locker */

 * Releases 7.3 and 7.4 use 1, denoting a new HeapTupleHeader layout.

struct HeapTupleHeaderData

 * As of Release 9.3, the checksum version must also be considered when

    lsn    | checksum | flags | lower | upper | special | pagesize | version | p

(2 rows)

 * Release 8.3 uses 4; it changed the HeapTupleHeader layout again, and

{

/*

{

  1 |   81400 |        1 |     28 |   1831 |      0 |        0 | (0,1)  |       

 *

psql (9.4.5)

        pg_linp:项指针。

        c.ItemIddata

#define HEAP_XMIN_FROZEN        (HEAP_XMIN_COMMITTED|HEAP_XMIN_INVALID)

#define HEAP_HASOID             0x0008  /* has an object-id field */

Type "help" for help.

#define HEAP_NATTS_MASK         0x07FF  /* 11 bits for number of attributes */

        在此只是我不到了解的名词:

        page,物理文件的单位,默认大小为8K。

        tuple,PG中物理行。

        xid,事务号,执行操作时的顺序id。

 int32      datum_len_;    

    uint16      pd_pagesize_version;

                         HEAP_XMAX_KEYSHR_LOCK)

    OffsetNumber ip_posid;

        pageinspect顶端有好几个 函数是本文用到的,其他同学分别是:

        a.get_raw_page,根据参数表明、数据文件类型(main、fsm、vm)以及page位置,将当前表文件中的page内容返回。还有好几个 函数于此同名,不到好几个 参数,是将第好几个 参数省略,直接使用'main'。

        b.page_header,参数是函数get_raw_page的返回值,返回值是将本page形态学 中的PageHeaderData完全信息

        c.heap_page_items,参数是函数get_raw_page的返回值,返回值是将page内的项指针(ItemIddata)以及HeapTupleHeaderData的完全信息。

typedef struct BlockIdData

}

                                         * everyone */

         b.PageHeaderData

#define HEAP_XMAX_INVALID       0x04000  /* t_xmax invalid/aborted */

 *      as well as adding the pd_prune_xid field (which enlarges the header).

                                         * tuple? */

postgres=# select * from heap_page_items(get_raw_page('mvcc', 'main', 0));

    uint16      t_infomask2;   

rune_xid

#define HEAP_XMAX_KEYSHR_LOCK   0x0010  /* xmax is a key-shared locker */

#define HEAP_XMAX_SHR_LOCK  (HEAP_XMAX_EXCL_LOCK | HEAP_XMAX_KEYSHR_LOCK)

  2 |   8128 |        1 |     28

#define PD_PAGE_FULL        0x0002      /* not enough free space for new

#define LP_REDIRECT     2       /* HOT redirect (should have lp_len=0) */

PostgreSQL 当有多个索引可选时,优化器怎么能能选择

#define HEAP_XMAX_COMMITTED     0x0400  /* t_xmax committed */

 * Release 8.0 uses 2; it changed the HeapTupleHeader layout again.

pageinspect分析btree索引形态学

    bits8       t_bits[1];     

#define LP_NORMAL       1       /* used (should always have lp_len>0) */

 * handling pages.

 */

理解原理的重要性 - 论PostgreSQL merge join 成本评估陷阱 含case

#define HEAP_UPDATED            0x4000  /* this is UPDATEd version of row */

    TransactionId t_xmin;      

  2 |   8128 |        1 |     28 |   1831 |      0 |        0 | (0,2)  |       

#define HEAP_LOCK_MASK  (HEAP_XMAX_SHR_LOCK | HEAP_XMAX_EXCL_LOCK | \

#define LP_UNUSED       0       /* unused (should always have lp_len=0) */

    unsigned    lp_off:15,     

    uint16      bi_lo;

PostgreSQL 存储智慧 - 空间聚集存储

PostgreSQL 垃圾版本引入的索引扫描性能下降诊断

typedef struct ItemPointerData

} DatumTupleFields;

进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。

震精 - PostgreSQL 10.0 preview 性能增强 - WARM提升一倍性能

怎么能能从PostgreSQL源码分析那此操作不到超级用户权限 - 阿里云rds superuser提供了那此权限

    TransactionId t_xmax;      

下拉加载更多

typedef struct HeapTupleFields

    ItemPointerData t_ctid;    

怎么能能从零学习PostgreSQL Page形态学

PostgreSQL 违反唯一约束的插入操作会产品HEAP垃圾吗?

版权声明:本文内容由互联网用户自发贡献,版权归作者所有,本社区不拥有所有权,什么都有我承担相关法律责任。原因您发现本社区含有涉嫌抄袭的内容,欢迎发送邮件至:

#define PD_VALID_FLAG_BITS  0x0007      /* OR of all valid pd_flags bits */

} PageHeaderData;

    }           t_field3;

};

#define HEAP_XMIN_INVALID       0x0400  /* t_xmin invalid/aborted */

    LocationIndex pd_upper;    

INSERT 0 2

#define PD_ALL_VISIBLE      0x0004      /* all tuples on page are visible to

    uint16      t_infomask;    

#define HEAP_HOT_UPDATED        0x4000  /* tuple was HOT-updated */

PostgreSQL GIN multi-key search 优化

    LocationIndex pd_lower;    

    uint16      pd_flags;      

        HeapTupleFields t_heap;

#define HEAP_XMIN_COMMITTED     0x0400  /* t_xmin committed */

    {

        t_cid:這個是指好几个 事务内的命令ID,每个事务不是从0现在结束。         t_ctid:這個是指物理ID,形态学 如下: 

#define HEAP_HASVARWIDTH        0x0002  /* has variable-width attribute(s) */

CREATE TABLE

#define HEAP_HASEXTERNAL        0x0004  /* has external stored attribute(s) */

typedef struct DatumTupleFields

    LocationIndex pd_special;  

typedef struct PageHeaderData

{

#define HEAP_XMAX_LOCK_ONLY     0x00400  /* xmax, if valid, is only a locker */

{

PostgreSQL 数据库多列复合索引的字段顺序选择原理

{

 int32      datum_typmod;  

ask2 | t_infomask | t_hoff | t_bits | t_oid

   1 |       2048 |     24 |        |     

    union

pageinspect介绍

{

        t_infomask2:表字段的个数以及什么都有有flags,flags如下: