Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the settings option of PostgreSQL 12

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "how to use the settings options of PostgreSQL 12". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor learn "how to use the settings option of PostgreSQL 12".

PostgreSQL 12 provides the settings option for the explain command to view setting changes that affect the execution plan.

Test data:

Testdb=# drop table if exists tasking settling: note: table "t_settings" does not exist, skippingDROP TABLEtestdb=# create table t_settings (id int,c1 varchar (20)); CREATE TABLEtestdb=# testdb=# insert into t_settings select x as insert 0 100000testdb=# create index idx_t_settings_id on t_settings (id); CREATE INDEX

PG 11

Testdb=# explain (settings on) select * from t_settings where id = 1bot error: unrecognized EXPLAIN option "settings" LINE 1: explain (settings on) select * from t_settings where id = 1; ^

PG 11 does not support this feature.

PG 12

This feature is added to 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

Modify the parameters to view the execution plan

[local]: 5432 pg12@testdb=# set enable_indexscan=off;SETTime: 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

Note the "Settings: enable_indexscan = 'off'" in the execution plan and print out the parameter changes that affect the execution plan. This is a pretty cool feature that enhances ease of use.

At this point, I believe you have a better understanding of "how to use the settings option of PostgreSQL 12". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report