-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize performance of index create, bulk extend and so on.
- Loading branch information
1 parent
85d1c8d
commit ed5505d
Showing
128 changed files
with
3,738 additions
and
2,223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
create schema test_index_bulk_extend; | ||
set search_path to test_index_bulk_extend; | ||
set client_min_messages to error; | ||
create extension if not exists pageinspect; | ||
show polar_index_bulk_extend_size; | ||
polar_index_bulk_extend_size | ||
------------------------------ | ||
1MB | ||
(1 row) | ||
|
||
drop table if exists p; | ||
create table p(a int, b varchar, c numeric,d int8); | ||
-- INSERT DATA | ||
insert into p select | ||
i, | ||
md5(i::text), | ||
i / 982.0, | ||
i * -1 | ||
from | ||
generate_series(0,100000 - 1)i; | ||
-- INIT INDEX | ||
create index p_c_d_idx on p(c,d); | ||
-- DML | ||
insert into p select | ||
i, | ||
i::text || 'sdha&$#*&', | ||
i / 160.0, | ||
i / 32 | ||
from | ||
generate_series(0,100000 - 1)i; | ||
-- For index bulk extend expansion | ||
select pg_relation_size('p_c_d_idx') < 3 * pg_relation_size('p'); | ||
?column? | ||
---------- | ||
t | ||
(1 row) | ||
|
||
-- For index bulk extend core | ||
select count(*) from generate_series(1, pg_relation_size('p_c_d_idx') / current_setting('block_size')::bigint - 1) AS blkno,bt_page_items('p_c_d_idx', blkno); | ||
count | ||
-------- | ||
202716 | ||
(1 row) | ||
|
||
drop schema test_index_bulk_extend cascade; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
create schema test_index_bulk_extend; | ||
set search_path to test_index_bulk_extend; | ||
set client_min_messages to error; | ||
|
||
create extension if not exists pageinspect; | ||
|
||
show polar_index_bulk_extend_size; | ||
|
||
drop table if exists p; | ||
create table p(a int, b varchar, c numeric,d int8); | ||
|
||
|
||
-- INSERT DATA | ||
insert into p select | ||
i, | ||
md5(i::text), | ||
i / 982.0, | ||
i * -1 | ||
from | ||
generate_series(0,100000 - 1)i; | ||
-- INIT INDEX | ||
create index p_c_d_idx on p(c,d); | ||
|
||
-- DML | ||
insert into p select | ||
i, | ||
i::text || 'sdha&$#*&', | ||
i / 160.0, | ||
i / 32 | ||
from | ||
generate_series(0,100000 - 1)i; | ||
|
||
-- For index bulk extend expansion | ||
select pg_relation_size('p_c_d_idx') < 3 * pg_relation_size('p'); | ||
-- For index bulk extend core | ||
select count(*) from generate_series(1, pg_relation_size('p_c_d_idx') / current_setting('block_size')::bigint - 1) AS blkno,bt_page_items('p_c_d_idx', blkno); | ||
|
||
drop schema test_index_bulk_extend cascade; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated subdirectories | ||
/log/ | ||
/results/ | ||
/tmp_check/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# external/polar_smgrperf/Makefile | ||
|
||
MODULE_big = polar_smgrperf | ||
OBJS = polar_smgrperf.o $(WIN32RES) | ||
|
||
EXTENSION = polar_smgrperf | ||
DATA = polar_smgrperf--1.0.sql | ||
PGFILEDESC = "polar_smgrperf - perf test on smgr" | ||
|
||
TAP_TESTS = 1 | ||
|
||
ifdef USE_PGXS | ||
PG_CONFIG = pg_config | ||
PGXS := $(shell $(PG_CONFIG) --pgxs) | ||
include $(PGXS) | ||
else | ||
subdir = external/polar_smgrperf | ||
top_builddir = ../.. | ||
include $(top_builddir)/src/Makefile.global | ||
include $(top_srcdir)/contrib/contrib-global.mk | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION | ||
\echo Use "CREATE EXTENSION polar_smgrperf" to load this file. \quit | ||
|
||
CREATE FUNCTION polar_smgrperf_prepare( | ||
nblocks INT DEFAULT 131072) | ||
RETURNS VOID | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C STRICT; | ||
|
||
CREATE FUNCTION polar_smgrperf_cleanup() | ||
RETURNS VOID | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C STRICT; | ||
|
||
CREATE FUNCTION polar_smgrperf_read( | ||
bs INT DEFAULT 1, | ||
begin_blkno INT DEFAULT 0, | ||
end_blkno INT DEFAULT 131072, | ||
sequential BOOLEAN DEFAULT TRUE) | ||
RETURNS VOID | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C STRICT; | ||
|
||
CREATE FUNCTION polar_smgrperf_write( | ||
bs INT DEFAULT 1, | ||
begin_blkno INT DEFAULT 0, | ||
end_blkno INT DEFAULT 131072, | ||
sequential BOOLEAN DEFAULT TRUE) | ||
RETURNS VOID | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C STRICT; | ||
|
||
CREATE FUNCTION polar_smgrperf_extend( | ||
bs INT DEFAULT 1) | ||
RETURNS VOID | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C STRICT; | ||
|
||
CREATE FUNCTION polar_smgrperf_nblocks( | ||
relnumber OID DEFAULT 1, | ||
nblocks_cached BOOLEAN DEFAULT FALSE, | ||
fd_cached BOOLEAN DEFAULT TRUE | ||
) RETURNS VOID | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C STRICT; |
Oops, something went wrong.