這篇文章主要講解了“PostgreSQL 12 B-tree的改進(jìn)是什么”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“PostgreSQL 12 B-tree的改進(jìn)是什么”吧!

創(chuàng)建數(shù)據(jù)表,創(chuàng)建索引
[local]:5110 xdb@testdb=# drop table rel; DROP TABLE Time: 130.868 ms [local]:5110 xdb@testdb=# CREATE TABLE rel ( xdb@testdb(# aid bigint NOT NULL, xdb@testdb(# bid bigint NOT NULL xdb@testdb(# ); CREATE TABLE Time: 16.041 ms [local]:5110 xdb@testdb=# [local]:5110 xdb@testdb=# ALTER TABLE rel xdb@testdb-# ADD CONSTRAINT rel_pkey PRIMARY KEY (aid, bid); ALTER TABLE Time: 5.236 ms [local]:5110 xdb@testdb=# [local]:5110 xdb@testdb=# CREATE INDEX rel_bid_idx ON rel (bid); CREATE INDEX Time: 1.838 ms [local]:5110 xdb@testdb=# [local]:5110 xdb@testdb=# INSERT INTO rel (aid, bid) xdb@testdb-# SELECT i, i / 10000 xdb@testdb-# FROM generate_series(1, 20000000) AS i; INSERT 0 20000000 Time: 152699.275 ms (02:32.699) [local]:5110 xdb@testdb=# [local]:5110 xdb@testdb=#
查看索引信息
[local]:5110 xdb@testdb=# [local]:5110 xdb@testdb=# \d rel Table "public.rel" Column | Type | Collation | Nullable | Default --------+--------+-----------+----------+--------- aid | bigint | | not null | bid | bigint | | not null | Indexes: "rel_pkey" PRIMARY KEY, btree (aid, bid) "rel_bid_idx" btree (bid) [local]:5110 xdb@testdb=# \di+ rel_pkey List of relations Schema | Name | Type | Owner | Table | Size | Description --------+----------+-------+-------+-------+--------+------------- public | rel_pkey | index | xdb | rel | 602 MB | (1 row) [local]:5110 xdb@testdb=# \di+ rel_bid_idx List of relations Schema | Name | Type | Owner | Table | Size | Description --------+-------------+-------+-------+-------+--------+------------- public | rel_bid_idx | index | xdb | rel | 545 MB | (1 row)
創(chuàng)建數(shù)據(jù)表,創(chuàng)建索引
[local:/run/pg12]:5120 pg12@testdb=# \timing on Timing is on. [local:/run/pg12]:5120 pg12@testdb=# drop table rel; DROP TABLE Time: 279.144 ms [local:/run/pg12]:5120 pg12@testdb=# CREATE TABLE rel ( pg12@testdb(# aid bigint NOT NULL, pg12@testdb(# bid bigint NOT NULL pg12@testdb(# ); CREATE TABLE Time: 1.579 ms [local:/run/pg12]:5120 pg12@testdb=# [local:/run/pg12]:5120 pg12@testdb=# ALTER TABLE rel pg12@testdb-# ADD CONSTRAINT rel_pkey PRIMARY KEY (aid, bid); ALTER TABLE Time: 3.450 ms [local:/run/pg12]:5120 pg12@testdb=# [local:/run/pg12]:5120 pg12@testdb=# CREATE INDEX rel_bid_idx ON rel (bid); CREATE INDEX Time: 1.201 ms [local:/run/pg12]:5120 pg12@testdb=# [local:/run/pg12]:5120 pg12@testdb=# INSERT INTO rel (aid, bid) pg12@testdb-# SELECT i, i / 10000 pg12@testdb-# FROM generate_series(1, 20000000) AS i; INSERT 0 20000000 Time: 124503.212 ms (02:04.503) [local:/run/pg12]:5120 pg12@testdb=#
查看索引信息
[local:/run/pg12]:5120 pg12@testdb=# \di+ rel_pkey List of relations Schema | Name | Type | Owner | Table | Size | Description --------+----------+-------+-------+-------+--------+------------- public | rel_pkey | index | pg12 | rel | 601 MB | (1 row) [local:/run/pg12]:5120 pg12@testdb=# \di+ rel_bid_idx List of relations Schema | Name | Type | Owner | Table | Size | Description --------+-------------+-------+-------+-------+--------+------------- public | rel_bid_idx | index | pg12 | rel | 408 MB | (1 row) [local:/run/pg12]:5120 pg12@testdb=#
可以看到PK沒有太大的變化,但有很多重復(fù)值的bid列索引則有明顯的變化,比PG 11少了25%的空間。
感謝各位的閱讀,以上就是“PostgreSQL 12 B-tree的改進(jìn)是什么”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對(duì)PostgreSQL 12 B-tree的改進(jìn)是什么這一問題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
新聞名稱:PostgreSQL12B-tree的改進(jìn)是什么-創(chuàng)新互聯(lián)
當(dāng)前地址:http://chinadenli.net/article44/hjohe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、標(biāo)簽優(yōu)化、服務(wù)器托管、商城網(wǎng)站、網(wǎng)頁設(shè)計(jì)公司、網(wǎng)站策劃
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容