0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

jdbcRunnerでPostgresql性能検証(チュートリアル)

Posted at

目的

jdbcRunnerを使ってPostgresqlの性能検証のための手順を作成。
jdbcRunnerドキュメントのチュートリアルとおりの手順。

前提条件

Postgresql環境
jdbcRunnerダウンロード

目次

  1. DB準備
  2. jdbcRunner準備
  3. チュートリアル実行

1. DB準備

  • 検証用データベース作成
postgres=# create database tutorial;
CREATE DATABASE
  • jdbcRunner用ユーザ作成
postgres=# create role jdbc_runner with login password '******';
CREATE ROLE
  • 権限付与
postgres=# grant all on database tutorial to jdbc_runner;
GRANT
  • ログインしなおす
Server [localhost]:
Database [postgres]: tutorial
Port [5432]:
Username [postgres]: jdbc_runner
Client Encoding [SJIS]:
ユーザー jdbc_runner のパスワード:
psql (10.4)
"help" でヘルプを表示します。

tutorial=>
  • テーブル作成
tutorial=> CREATE TABLE sample (id INT PRIMARY KEY, data VARCHAR(10));
CREATE TABLE
tutorial=>  INSERT INTO sample (id, data) VALUES (1, 'aaaaaaaaaa');
INSERT 0 1
tutorial=> INSERT INTO sample (id, data) VALUES (2, 'bbbbbbbbbb');
INSERT 0 1
tutorial=> INSERT INTO sample (id, data) VALUES (3, 'cccccccccc');
INSERT 0 1
tutorial=> INSERT INTO sample (id, data) VALUES (4, 'dddddddddd');
INSERT 0 1
tutorial=> INSERT INTO sample (id, data) VALUES (5, 'eeeeeeeeee');
INSERT 0 1

2. jdbcRunner準備

  • ダウンロードしたjdbcRunnerを任意の場所に解凍し、環境変数CLASSPATHにjarファイルを設定する。
$ export CLASSPATH=jdbcrunner-1.3.jar
  • 実行確認
$ java JR
JdbcRunner 1.3
スクリプトファイルが指定されていません

...

3. チュートリアル実行

  • 以下のスクリプトをtest.jsファイルとして保存する。
function run() {
    var param = random(1, 5);
    query("SELECT data FROM sample WHERE id = $int", param);
}
  • スクリプトを実行する
$ java JR test.js -jdbcUrl jdbc:postgresql://localhost:5432/tutorial -jdbcUser jdbc_runner -jdbcPass jdbc_runner
12:43:46 [INFO ] > JdbcRunner 1.3
12:43:46 [INFO ] [Config]
Program start time   : 20180913-124346
Script filename      : test.js
JDBC driver          : -
JDBC URL             : jdbc:postgresql://localhost:5432/tutorial
JDBC user            : jdbc_runner
Warmup time          : 10 sec
Measurement time     : 60 sec
...

参考内容

jdbcRunnerチュートリアル

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?