본문 바로가기
DBMS

MPP DBMS Greenplum 테스트

by developer's warehouse 2023. 12. 8.

이 글에서는 Greenplum DBMS를 설치 후 테스트 한 내용에 대해서 설명합니다.

MPP DBMS Greenplum 테스트 썸네일

MPP DBMS Greenplum 컴파일 후 데모 클러스터 테스트

Greenplum을 컴파일 하고 난 후 아래와 같이 GPHOME을 설정해 줍니다.
 
기본으로 설치한 경우 아래와 같이 /usr/local/gpdb/에 설치됩니다. 아래와 같이 .bashrc 파일에 GPHOME을 넣습니다. 아래에 source /usr/local/gpdb/greenplum_path.sh은 이미 .bashrc에 들어가 있었습니다. 해당 스크립트 위에 GPHOME이 설정되어있어야 합니다.
 
export GPHOME=/usr/local/gpdb/
 
source /usr/local/gpdb/greenplum_path.sh
 
build 과정에서 make create-demo-cluster를 수행한 후에 아래 명령을 실행해서 테스트를 할 수 있습니다.
 

Running tests

The default regression tests
make installcheck-world
  • 최상위 타깃인 installcheck-world는 실행 중인 클러스터에 대해 GPDB에서 모든 회귀 테스트를 실행합니다. 개별 부분을 테스트하려면 각 타깃을 별도로 실행할 수 있습니다.
  • PostgreSQL 검사 대상이 작동하지 않습니다. Greenplum 클러스터를 설정하는 것은 단일 노드 PostgreSQL 설치보다 더 복잡하며, 아무도 make check가 클러스터를 생성하도록 하는 작업을 수행하지 않았습니다. 클러스터를 수동으로 생성하거나 gpAux/gpdemo/(아래 예제)를 사용하여 클러스터를 생성하고 이에 대해 최상위 level make installcheck-world를 실행하세요. 패치도 환영합니다!
  • 일부 테스트가 Greenplum에서 실패하는 것으로 알려져 있기 때문에 PostgreSQL installcheck 대상도 작동하지 않습니다. src/test/regress의 installcheck-good 스케줄은 이러한 테스트를 제외합니다.
  • 새 테스트를 추가할 때는 업스트림에서 상속된 PostgreSQL 테스트가 아닌 greenplum_schedule의 GPDB 전용 테스트 중 하나에 추가해 주시기 바랍니다. 최신 PostgreSQL 릴리스와의 병합이 더 쉬워지도록 업스트림 테스트를 업스트림 버전과 동일하게 유지하려고 노력합니다.
 
"make installcheck-world"를 수행하면 테스트가 수행됩니다.
parallel group (10 tests): gp_pullup_expr gp_rules dispatch_encoding motion_gp gpparams indexjoin as_alias transient_types regex_gp with_clause
indexjoin ... ok 714 ms (diff 170 ms)
as_alias ... FAILED 1963 ms (diff 464 ms)
regex_gp ... ok 3102 ms (diff 1215 ms)
gpparams ... ok 657 ms (diff 169 ms)
with_clause ... ok 3172 ms (diff 444 ms)
transient_types ... ok 2208 ms (diff 210 ms)
gp_rules ... ok 263 ms (diff 136 ms)
dispatch_encoding ... ok 568 ms (diff 145 ms)
motion_gp ... ok 626 ms (diff 148 ms)
gp_pullup_expr ... ok 142 ms (diff 136 ms)
parallel group (14 tests): icudp/gp_interconnect_cache_future_packets icudp/gp_interconnect_min_retries_before_timeout icudp/gp_interconnect_fc_method icudp/gp_interconnect_min _rto icudp/gp_interconnect_transmit_timeout icudp/gp_interconnect_snd_queue_depth icudp/gp_interconnect_queue_depth icudp/gp_interconnect_default_rtt icudp/gp_interconnect_timer _period icudp/gp_interconnect_timer_checking_period icudp/queue_depth_combination_loss icudp/queue_depth_combination_capacity icudp/gp_interconnect_queue_depth_longtime icudp/gp _interconnect_snd_queue_depth_longtime
icudp/gp_interconnect_queue_depth ... ok 3520 ms (diff 159 ms)
icudp/gp_interconnect_queue_depth_longtime ... ok 4226 ms (diff 158 ms)
icudp/gp_interconnect_snd_queue_depth ... ok 3515 ms (diff 149 ms)
icudp/gp_interconnect_snd_queue_depth_longtime ... ok 4226 ms (diff 155 ms)
icudp/gp_interconnect_min_retries_before_timeout ... ok 3392 ms (diff 147 ms)
icudp/gp_interconnect_transmit_timeout ... ok 3512 ms (diff 144 ms)
icudp/gp_interconnect_cache_future_packets ... ok 3354 ms (diff 140 ms)
icudp/gp_interconnect_default_rtt ... ok 3519 ms (diff 147 ms)
icudp/gp_interconnect_fc_method ... ok 3438 ms (diff 139 ms)
icudp/gp_interconnect_min_rto ... ok 3483 ms (diff 143 ms)
icudp/gp_interconnect_timer_checking_period ... ok 3535 ms (diff 146 ms)
icudp/gp_interconnect_timer_period ... ok 3523 ms (diff 149 ms)
icudp/queue_depth_combination_loss ... ok 3669 ms (diff 157 ms)
icudp/queue_depth_combination_capacity ... ok 3721 ms (diff 164 ms)
test event_trigger_gp ... ok 123 ms (diff 135 ms)
위와 같이 수행됩니다.
 
Starting and Stopping Greenplum Database
.bashrc에 다음과 같은 내용을 넣어서 환경변수를 설정합니다. gpdemo-env.sh은 위에서 create-demo-cluster를 수행하면 나타나는 sh 파일입니다.
 
export GPHOME=/usr/local/gpdb/
source /usr/local/gpdb/greenplum_path.sh
source ~/gpdb/gpAux/gpdemo/gpdemo-env.sh
 

Database 생성 및 테스트

database를 생성합니다.
gpadmin:~/work/gpdb_src$ createdb
 
gpadmin:~/work/gpdb_src$ psql
 
psql (12.12)
 
Type "help" for help.
 
gpadmin=#
 
위와 같이 createdb를 하면 아무런 프롬프트 없이 바로 떨어지는데 DB는 생성되는 것 같습니다.
 
그 후 psql을 입력하면 gpadmin db에 연결되었다는 의미로 "gpadmin=#" psql 프롬프트가 나타납니다.
 
테스트로 제공하는 아래 구문을 수행해 봅니다.
 
-- Create and populate a Users table
 
CREATE TABLE Users (uid INTEGER PRIMARY KEY,
 
name VARCHAR);
 
INSERT INTO Users
 
SELECT generate_series, md5(random())
 
FROM generate_series(1, 100000);
 
 
 
-- Create and populate a Messages table
 
CREATE TABLE Messages (mid INTEGER PRIMARY KEY,
 
uid INTEGER REFERENCES Users(uid),
 
ptime DATE,
 
message VARCHAR);
 
INSERT INTO Messages
 
SELECT generate_series,
 
round(random()*100000),
 
date(now() - '1 hour'::INTERVAL * round(random()*24*30)),
 
md5(random())::text
 
FROM generate_series(1, 1000000);
 
 
 
-- Report the number of tuples in each table
 
SELECT COUNT(*) FROM Messages;
 
SELECT COUNT(*) FROM Users;
 
 
 
-- Report how many messages were posted on each day
 
SELECT M.ptime, COUNT(*)
 
FROM Users U NATURAL JOIN Messages M
 
GROUP BY M.ptime
 
ORDER BY M.ptime;
아래와 같이 double을 인자로 하는 md5 함수가 없다고 나옵니다.
 
 
 
ERROR: function md5(double precision) does not exist
LINE 3: SELECT generate_series, md5(random())
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
WARNING: referential integrity (FOREIGN KEY) constraints are not supported in Greenplum Database, will not be enforced
CREATE TABLE
ERROR: function md5(double precision) does not exist
LINE 9: md5(random())::text
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
아래와 같이 ::text로 변환해서 삽입하면 성공합니다.
 
gpadmin=# INSERT INTO Users
SELECT generate_series, md5(random()::text)
FROM generate_series(1, 100000);
INSERT 0 100000
 
 
gpadmin=# INSERT INTO Users
SELECT generate_series, md5(random()::text)
FROM generate_series(1, 100000);
INSERT 0 100000
gpadmin=# INSERT INTO Messages
SELECT generate_series,
round(random()*100000),
date(now() - '1 hour'::INTERVAL * round(random()*24*30)),
md5(random()::text)::text
FROM generate_series(1, 1000000);
INSERT 0 1000000
gpadmin=# SELECT COUNT(*) FROM Messages;
SELECT COUNT(*) FROM Users;
count
---------
1000000
(1 row)
 
count
--------
100000
(1 row)
 
gpadmin=# SELECT M.ptime, COUNT(*)
FROM Users U NATURAL JOIN Messages M
GROUP BY M.ptime
ORDER BY M.ptime;
ptime | count
------------+-------
2023-09-04 | 13141
2023-09-05 | 32997
2023-09-06 | 33713
2023-09-07 | 33174
2023-09-08 | 33259
2023-09-09 | 33511
2023-09-10 | 32877
2023-09-11 | 33588
2023-09-12 | 33243
2023-09-13 | 33454
2023-09-14 | 33172
2023-09-15 | 33526
2023-09-16 | 33393
2023-09-17 | 33265
2023-09-18 | 33148
2023-09-19 | 33279
2023-09-20 | 33321
2023-09-21 | 33790
2023-09-22 | 33382
2023-09-23 | 33345
2023-09-24 | 33680
2023-09-25 | 33316
2023-09-26 | 33253
2023-09-27 | 33252
2023-09-28 | 33151
2023-09-29 | 33114
2023-09-30 | 33381
2023-10-01 | 33058
2023-10-02 | 33354
2023-10-03 | 33553
2023-10-04 | 20305
(31 rows)
 
gpadmin=#

Column store 테스트

 
column store 테이블은 append only만 가능합니다.
gpadmin=# CREATE TABLE sales (
id int,
date date,
amount numeric(10,2),
region text
) WITH (appendonly=true, orientation=column)
DISTRIBUTED BY (id);
CREATE TABLE
gpadmin=# drop table sales;
DROP TABLE
gpadmin=# CREATE TABLE sales (
id int,
date date,
amount numeric(10,2),
region text
) WITH ( orientation=column)
DISTRIBUTED BY (id);
ERROR: invalid option "orientation" for base relation
HINT: Table orientation only valid for Append Optimized relations, create an AO relation to use table orientation.
 
INSERT INTO sales (id, date, amount, region) VALUES (1, '2023-10-27', 100.00, '서울');
 

gpdb의 column store 갱신 Update

gpadmin=# CREATE TABLE sales (
id int,
date date,
amount numeric(10,2),
region text
) WITH (appendonly=true, orientation=column)
DISTRIBUTED BY (id);
CREATE TABLE
gpadmin=# INSERT INTO sales (id, date, amount, region) VALUES (1, '2023-10-27', 100.00, '서울');
INSERT 0 1
 
gpadmin=# update sales set id = 2;
UPDATE 1
gpadmin=# select * from sales;
id | date | amount | region
----+------------+--------+--------
2 | 2023-10-27 | 100.00 | 서울
(1 row)
 
내부적으로 delete/insert로 처리됨.
 

gpdb의 index 제약

gpadmin=# CREATE UNIQUE INDEX amount_unique_index ON sales (amount);
ERROR: UNIQUE index must contain all columns in the table's distribution key
DETAIL: Distribution key column "id" is not included in the constraint.
gpadmin=# CREATE UNIQUE INDEX amount_unique_index ON sales (id, amount);
CREATE INDEX
 

참고:

https://docs.vmware.com/en/VMware-Greenplum/7/greenplum-database/admin_guide-managing-startstop.html
https://github.com/lswhh/gpdb/blob/main/src/tools/vagrant/README.md
facebook twitter kakaoTalk kakaostory naver band shareLink