【问题标题】:Checking fillfactor setting for tables and indexes检查表和索引的填充因子设置
【发布时间】:2014-04-23 11:51:47
【问题描述】:

也许有一些函数可以检查索引和表的填充因子?我已经尝试过 \d+ 但只有基本定义,没有填充因子值:

        Index "public.tab1_pkey"
 Column |  Type  | Definition | Storage 
--------+--------+------------+---------
 id     | bigint | id         | plain
primary key, btree, for table "public.tab1"

对于表还没有找到任何东西。如果表是使用非默认填充因子创建的:

CREATE TABLE distributors (
    did     integer,
    name    varchar(40),
    UNIQUE(name) WITH (fillfactor=70)
)
WITH (fillfactor=70);

然后\d+ distributors显示非标准填充因子。

                            Table "public.distributors"                                                                                                                                        
 Column |         Type          | Modifiers | Storage  | Stats target | Description                                                                                                            
--------+-----------------------+-----------+----------+--------------+-------------                                                                                                           
 did    | integer               |           | plain    |              |                                                                                                                        
 name   | character varying(40) |           | extended |              |                                                                                                                        
Indexes:                                                                                                                                                                                       
    "distributors_name_key" UNIQUE CONSTRAINT, btree (name) WITH (fillfactor=70)                                                                                                               
Has OIDs: no
Options: fillfactor=70

但也许有一种方法可以在不解析输出的情况下获取此值?

【问题讨论】:

    标签: postgresql fillfactor


    【解决方案1】:

    需要查询pg_class系统表:

    select t.relname as table_name, 
           t.reloptions
    from pg_class t
      join pg_namespace n on n.oid = t.relnamespace
    where t.relname in ('tab11_pkey', 'tab1')
      and n.nspname = 'public'
    

    reloptions 是一个数组,每个元素包含一个option=value 定义。但对于具有默认选项的关系,它将为空。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-18
      • 1970-01-01
      相关资源
      最近更新 更多