您好,登錄后才能下訂單哦!
本篇內容主要講解“怎么使用PostgreSQL 12的settings選項”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“怎么使用PostgreSQL 12的settings選項”吧!
PostgreSQL 12為explain命令提供了settings選項,可查看影響執行計劃的設置修改.
測試數據:
testdb=# drop table if exists t_settings; NOTICE: table "t_settings" does not exist, skipping DROP TABLE testdb=# create table t_settings(id int,c1 varchar(20)); CREATE TABLE testdb=# testdb=# insert into t_settings select x,'c1'||x from generate_series(1,100000) as x; INSERT 0 100000 testdb=# create index idx_t_settings_id on t_settings(id); CREATE INDEX
PG 11
testdb=# explain (settings on) select * from t_settings where id = 1; ERROR: unrecognized EXPLAIN option "settings" LINE 1: explain (settings on) select * from t_settings where id = 1; ^
PG 11不支持該特性.
PG 12
PG 12新增了該特性
[local]:5432 pg12@testdb=# explain (settings on) select * from t_settings where id = 1; QUERY PLAN ----------------------------------------------------------------------------------- Bitmap Heap Scan on t_settings (cost=12.17..570.66 rows=500 width=62) Recheck Cond: (id = 1) -> Bitmap Index Scan on idx_t_settings_id (cost=0.00..12.04 rows=500 width=0) Index Cond: (id = 1) (4 rows) Time: 5.403 ms
修改參數,查看執行計劃
[local]:5432 pg12@testdb=# set enable_indexscan=off; SET Time: 0.555 ms [local]:5432 pg12@testdb=# explain (settings on) select * from t_settings where id = 1; QUERY PLAN -------------------------------------------------------------------------------- Bitmap Heap Scan on t_settings (cost=4.30..8.31 rows=1 width=11) Recheck Cond: (id = 1) -> Bitmap Index Scan on idx_t_settings_id (cost=0.00..4.30 rows=1 width=0) Index Cond: (id = 1) Settings: enable_indexscan = 'off' (5 rows) Time: 0.759 ms
注意執行計劃中的” Settings: enable_indexscan = ‘off’ “,把影響執行計劃的參數修改打印出來,這是一個pretty cool特性,增強了易用性.
到此,相信大家對“怎么使用PostgreSQL 12的settings選項”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。