반응형

PostgreSQL설치 기본으로 제공 되는 벤치 마크 .

source 컴파일 해서 설치 하면 기본으로 설치

 

초기 데이터 생성

    테스트 데이터 베이스를 생성해 -i 옵션을 이용하여 테스트 데이터 만듦

    -i : 초기 데이터 생성

    -s : 초기 데이터 사이즈가 작으므로 데이터 사이즈를 크게 하기 위한 옵션

        -s 10 기본 데이터 사이즈의 10배를 만들라는 .

         기본 데이터가 100,000 row 이었으면, -s 10 10 * 100,000 = 1,000,000 rows

    

    pgbench -h localhost -p 5493 -U postgres -i -s 5 test

 

부하 테스트 방법

    -c : DB 접속하는 가상의 client 수를 설정

    -j : -c에서 설정한 client 개의 thread 걸쳐 동작시킬 것인지 설정. (j CPU thread수에 맞춰서 수행 하면 된다.)

         -c 항상 -j 값보다 크거나 같아야 한다. 그렇지 않으면 -j값은 무시되고 -c 값으로 대체 된다.

         -c -j 배수이어야 한다.

    -t : transaction

    

    pgbench -h localhost -p 5493 -c 8 -j 4 -t 10000 test

 

 

테스트

    1. 테스트 데이터 베이스 생성

    

        echo "create database test;" | psql -p 5493 -d postgres

 

    2. 테스트 데이터 생성

 

        pgbench -h localhost -p 5493 -U postgres -i -s 5 test

 

        psql -p 5493 -d postgres

        postgres=# \l+

                                                                            List of databases

           Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   |  Size   | Tablespace |                Description 

        -----------+----------+----------+-------------+-------------+-----------------------+---------+------------+--------------------------------------------

         postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 6602 kB | pg_default | default administrative connection database

         template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +| 6481 kB | pg_default | unmodifiable empty database

         template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +| 6481 kB | pg_default | default template for new databases

         test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 81 MB   | pg_default |

        (4 rows)

        

        postgres=# \c test

        

        test=# \dt+

                                  List of relations

         Schema |       Name       | Type  |  Owner   |  Size   | Description

        --------+------------------+-------+----------+---------+-------------

        public | pgbench_accounts | table | postgres | 64 MB   |

        public | pgbench_branches | table | postgres | 40 kB   |

        public | pgbench_history  | table | postgres | 0 bytes |

        public | pgbench_tellers  | table | postgres | 40 kB   |

        (4 rows)

        

        test=# select schemaname , relname , seq_scan, idx_scan , n_live_tup from pg_stat_user_tables ;

         schemaname |     relname      | seq_scan | idx_scan | n_live_tup

        ------------+------------------+----------+----------+------------

         public     | pgbench_branches |        1 |        0 |          5

         public     | pgbench_history  |        0 |          |          0

         public     | pgbench_tellers  |        1 |        0 |         50

         public     | pgbench_accounts |        1 |        0 |     500000

        (4 rows)

        

    3. 성능 테스트

 

        pgbench -h localhost -p 5493 -c 8 -j 4 -t 10000 test

    

        starting vacuum...end.

        transaction type: TPC-B (sort of)

        scaling factor: 5

        query mode: simple

        number of clients: 8

        number of threads: 4

        number of transactions per client: 10000

        number of transactions actually processed: 80000/80000

        tps = 1512.535602 (including connections establishing)

        tps = 1512.750661 (excluding connections establishing)

 

        postgres=# \l+
                                                                            List of databases
           Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   |  Size   | Tablespace |                Description                
         
        -----------+----------+----------+-------------+-------------+-----------------------+---------+------------+--------------------------------------------
         postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 6602 kB | pg_default | default administrative connection database
         template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +| 6481 kB | pg_default | unmodifiable empty database
         template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +| 6481 kB | pg_default | default template for new databases
         test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |                       | 87 MB   | pg_default | 
        (4 rows)
        
        test=# select schemaname , relname , seq_scan, idx_scan , n_live_tup from pg_stat_user_tables ;
         schemaname |     relname      | seq_scan | idx_scan | n_live_tup 
        ------------+------------------+----------+----------+------------
         public     | pgbench_branches |   259213 |        0 |          5
         public     | pgbench_history  |        0 |          |      80000
         public     | pgbench_tellers  |   178421 |        0 |         50
         public     | pgbench_accounts |        1 |   320000 |     500000
        (4 rows)

반응형

+ Recent posts