>>> YieldNull
  • /blog
  • /archives
  • /github
  • /about

Entries tagged with PostgreSQL

  • PostgreSQL Internals: Shared Buffer

    2022-07-09 16:09:43 / PostgreSQL /7330 hits

    当你 INSERT 一行记录到 PostgreSQL 时,数据并不会立即写到磁盘文件中,而是会先写入 Shared Buffer,过一段时间才会落盘。同样的,当你 SELECT 一些数据时,也不会每次都会实时从磁盘文件中读取,很大概率会从 Shared Buffer 直接获取。那么 Shared Buffer 内部的结构是怎样的呢?本文将会介绍 Shared Buffer 的工作原理,逐步揭开其神秘面纱。

    Read more...


  • PostgreSQL字段对齐规则

    2021-10-16 20:16:49 / PostgreSQL /4451 hits

    PostgreSQL在存储一行数据时,会对各个字段进行对齐。在设计表结构时,需要合理安排字段顺序,减少磁盘空间占用。

    postgres=# select typname, typalign, typlen from pg_type where typname in ('int4', 'int8', 'bool', 'float4', 'float8', 'bytea', 'text', 'timestamptz', 'serial', 'json', 'int8[]');
       typname   | typalign | typlen
    -------------+----------+--------
     bool        | c        |      1
     bytea       | i        |     -1
     int8        | d        |      8
     int4        | i        |      4
     text        | i        |     -1
     json        | i        |     -1
     float4      | i        |      4
     float8      | d        |      8
     timestamptz | d        |      8
    (9 rows)postgres=#
    

    Read more...


  • « Previous
  • Next »

About this site © YieldNull,