這篇文章主要講解了“PostgreSQL 12 B-tree的改進(jìn)是什么”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“PostgreSQL 12 B-tree的改進(jìn)是什么”吧!
大祥網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、APP開(kāi)發(fā)、響應(yīng)式網(wǎng)站開(kāi)發(fā)等網(wǎng)站項(xiàng)目制作,到程序開(kāi)發(fā),運(yùn)營(yíng)維護(hù)。創(chuàng)新互聯(lián)從2013年開(kāi)始到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來(lái)保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(liá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沒(méi)有太大的變化,但有很多重復(fù)值的bid列索引則有明顯的變化,比PG 11少了25%的空間。
感謝各位的閱讀,以上就是“PostgreSQL 12 B-tree的改進(jìn)是什么”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)PostgreSQL 12 B-tree的改進(jìn)是什么這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!