💠

💠 2024-11-06 17:38:41


PostgreSQL Advance

Blog: 励志成为postgresql大神


Query

元数据

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    -- 查询表元数据(唯一性,必填,字段类型)
    select a.attname                             as fieldName,
        d.typname                             as type,
        (case
                when atttypmod - 4 > 0 then atttypmod - 4
                else 0
            end)                                 length,

        (case
                when (select count(*)
                    from pg_constraint
                    where conrelid = a.attrelid and conkey[1] = attnum and contype = 'u') > 0 then 'Y'
                else 'N'
            end)                              as un,
        (case
                when a.attnotnull = true then 'Y'
                else 'N'
            end)                              as nullable,
        col_description(a.attrelid, a.attnum) as comment
    from pg_attribute a
            left join pg_class c on a.attrelid = c.oid
            left join pg_type d on a.atttypid = d.oid
    where attstattarget = -1 and c.relname = 'table_test'

硬解析和软解析

PREPARE

PostgreSQL Prepare


执行计划问题


JOIN

TODO 大表和小表 join顺序是否和MySQL一样有要求


索引

Official Doc

事务

MVCC WAL


集群

创建数据库集群

PostgreSQL—集群方案 – Enmalvi


Explain

Official Doc

TODO 理解