LoginSignup
30
32

More than 1 year has passed since last update.

PostgreSQL でちょっとした性能試験や検証で使えるサンプルデータベース

Posted at

概要

  • クラウドサービスから新たなストレージエンジンのサービスが出た時に実際の性能評価やちょっとした検証をある程度作り込まれたデータベースでやりたくなる人も多いのではないでしょうか。
  • 今回そんな時に使えるサンプルのデータがあったのでちょっと紹介します。

PostgreSQL Tutorial

  • PostgreSQL Tutorial にサンプルのデータを用意してくれているので、そちらを利用します。

  • 例えばローカル環境上に構築するとして、一旦コンテナで検証してみます。
> docker run -d --name=postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres
  • 下記よりサンプルをダウンロードします。

スクリーンショット 2022-12-27 1.59.15.png

  • 次に、PostgreSQL 内でサンプルのデータを流すためのデータベースを作成します。
> CREATE DATABASE dvdrental;
  • 次に unzipコマンド を用いてダウンロードしたzipを解凍します。
> unzip dvdrental.zip
  • 次に下記のコマンドを実行します。
> pg_restore -h localhost -U postgres -d dvdrental ./dvdrental.tar
  • これで準備完了です。
  • PostgreSQLに入って状況を確認します。
> psql -h localhost -p 5432 -U postgres -d dvdrental;
> \dt
dvdrental=# \dt
             List of relations
 Schema |     Name      | Type  |  Owner
--------+---------------+-------+----------
 public | actor         | table | postgres
 public | address       | table | postgres
 public | category      | table | postgres
 public | city          | table | postgres
 public | country       | table | postgres
 public | customer      | table | postgres
 public | film          | table | postgres
 public | film_actor    | table | postgres
 public | film_category | table | postgres
 public | inventory     | table | postgres
 public | language      | table | postgres
 public | payment       | table | postgres
 public | rental        | table | postgres
 public | staff         | table | postgres
 public | store         | table | postgres
  • ちなみに作成されるデータベースの ER 図は下記となります。

スクリーンショット 2022-12-27 2.14.19.png

参考資料

30
32
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
30
32