博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PostgreSQL 11 preview - 表达式索引柱状图buckets\STATISTICS\default_statistics_target可设置...
阅读量:5905 次
发布时间:2019-06-19

本文共 2307 字,大约阅读时间需要 7 分钟。

标签

PostgreSQL , 表达式索引 , 柱状图 , buckets , 增强 , 11


背景

PostgreSQL 支持表达式索引,优化器支持CBO,对于普通字段,我们有默认统计信息bucket控制,也可以通过alter table alter column来设置bucket,提高或降低字段级的统计精度。

ALTER TABLE [ IF EXISTS ] [ ONLY ] name [ * ]      action [, ... ]        ALTER [ COLUMN ] column_name SET STATISTICS integer

SET STATISTICS

This form sets the per-column statistics-gathering target for subsequent ANALYZE operations. The target can be set in the range 0 to 10000; alternatively, set it to -1 to revert to using the system default statistics target (default_statistics_target). For more information on the use of statistics by the PostgreSQL query planner, refer to Section 14.2.

SET STATISTICS acquires a SHARE UPDATE EXCLUSIVE lock.

但是对于表达式索引,它可能是多列,它可能内嵌表达式,因为表达式它没有列名,只有第几列(或表达式),怎么调整表达式索引的统计信息bucket数呢?

PostgreSQL 将这个设置功能放到了alter index中。

ALTER INDEX [ IF EXISTS ] name ALTER [ COLUMN ] column_number      SET STATISTICS integer    ALTER [ COLUMN ] column_number SET STATISTICS integer
This form sets the per-column statistics-gathering target for subsequent [ANALYZE](https://www.postgresql.org/docs/devel/static/sql-analyze.html) operations, though can be used only on index columns that are defined as an expression. Since expressions lack a unique name, we refer to them using the ordinal number of the index column. The target can be set in the range 0 to 10000; alternatively, set it to -1 to revert to using the system default statistics target ([default_statistics_target](https://www.postgresql.org/docs/devel/static/runtime-config-query.html#GUC-DEFAULT-STATISTICS-TARGET)). For more information on the use of statistics by the PostgreSQL query planner, refer to [Section 14.2](https://www.postgresql.org/docs/devel/static/planner-stats.html).

例子

create table measured (x text, y text, z int, t int);CREATE INDEX coord_idx ON measured (x, y, (z + t));    -- 将(z + t)的统计信息柱状图设置为1000    ALTER INDEX coord_idx ALTER COLUMN 3 SET STATISTICS 1000;    -- psql 可以看到这个统计信息柱状图的设置值postgres=# \d+ coord_idx                Index "public.coord_idx" Column |  Type   | Definition | Storage  | Stats target --------+---------+------------+----------+-------------- x      | text    | x          | extended |  y      | text    | y          | extended |  expr   | integer | (z + t)    | plain    | 1000btree, for table "public.measured"

转载地址:http://ndjpx.baihongyu.com/

你可能感兴趣的文章
django base (1)
查看>>
iRedMail调整附件大小 & Postfix的bcc(自动转发/邮件备份/监控/归档) 在同一个服务器是有压力...
查看>>
唯识相链由来
查看>>
linux系统的负载与CPU、内存、硬盘、用户数监控shell脚本
查看>>
Percona Toolkit 安装
查看>>
元学习法 - XDITE -Xdite 郑伊廷
查看>>
Firewall之iptables篇
查看>>
sed 语法
查看>>
RHEL6入门系列之二十二,quota磁盘配额管理
查看>>
费用登记系统(小结)
查看>>
Windows Group Policy Startup script is not executed at startup
查看>>
智能指针
查看>>
AIX修改用户密码登录不成功案例分享
查看>>
openstack组件使用的默认端口
查看>>
c语言简单版坦克大战(AllenEnemyTrank文件)
查看>>
Java私塾: 研磨设计之备忘录模式(Memento)
查看>>
理解call和apply方法
查看>>
异步加载(延迟加载)与同步加载
查看>>
机器学习瓶颈 - 从黑盒白盒之争说起
查看>>
小程序图片上传七牛
查看>>