- EDB
- PostgreSQL
新ツール Postgres Workload Report によるパフォーマンス診断~データベース管理の未来を共に創る!~
EDB Postgres Workload Reportsは、Postgresデータベースのパフォーマンス診断とトラブルシューティングを強化する新しいツールです。OracleのAWRに似た詳細なレポートを提供し、データベースの問題を迅速に特定・解決できるようサポートします。本記事では概要と利用手順をご紹介します。
|
Oracle Databaseにはcsv等を高速にデーターベースにロードするSQL*Loaderがあります。
PostgreSQLをベースにOracle互換機能をもたせたEDB Postgres Advanced Server(EPAS)にもSQL*Loaderと互換性があるEDB*Loaderというツールが用意されています。
EDB*LoaderとSQL*Loaderはほぼ同じ形式で使えますが、いくつか注意点もありますので、簡単な利用方法と合わせてご紹介します。
EDB*LoaderはSQL*Loaderと同じく、ロード対象になるデータファイル(csvやtsv等)とロード対象等を指定した制御ファイルを用意します。コマンドライン引数等は接続先の指定を除きSQL*loaderとほぼ同じです。
[root@yamax ~]# edbldr --help edbldr is a DIRECT PATH bulk data loading tool for EnterpriseDB Usage: Data Load : edbldr [-d DBNAME] [-p PORT] userid={dbuser[/dbpass]|/} direct={true|false} parallel={true|false} control=control_file_name log=log_file_name errors=num_errors skip_index_maintenance={true|false} skip=num_skips bad=bad_file_name parfile=par_file_name freeze={true|false} Options for data load: -d DBNAME database name -h HOSTNAME database server to connect to -p PORT port number to connect to If these options are omitted, corresponding environment variables are used. If the environment variables are also not available, this tool tries to use internal default values. Keywords for data load: userid -- username/password direct -- use direct path for data load parallel -- allow parallel data load control -- name of the control file log -- name of the log file data -- name of the data file discard -- name of the discard file errors -- number of errors to tolerate before aborting the load discardmax -- number of discards to tolerate before aborting the load skip_index_maintenance -- skip index maintenance skip -- number of initial input rows to skip during the load bad -- name of the bad file parfile -- name of the parameters file edb_resource_group -- name of the resource group to be associated with freeze -- load the data with rows already frozen Other options: --help, -? show this help information --version, -V show version information
最低限、接続先DBの指定とuseridでのログイン情報、そして制御ファイルを指定するcontrolを指定します。その他のオプションは要件に応じて指定します。各オプションの詳細は以下のマニュアルを御覧ください。
EDB Postgres Advanced Server 9.6 Database Compatibility for Oracle Developers Tools and Utilities Guide
3.4 Invoking EDB*Loader
以下はEMP表へデータをロードする場合のデータファイルと制御ファイルのサンプルです。
edb=# \d emp テーブル "public.emp" 列 | 型 | 修飾語 ----------+-----------------------------+---------- empno | numeric(4,0) | not null ename | character varying(10) | job | character varying(9) | mgr | numeric(4,0) | hiredate | timestamp without time zone | sal | numeric(7,2) | comm | numeric(7,2) | deptno | numeric(2,0) |
LOAD DATA INFILE 'emp.dat' BADFILE 'emp.bad' APPEND INTO TABLE emp FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS ( empno, ename, job, mgr, hiredate, sal, deptno, comm )
9101,ROGERS,CLERK,7902,17-DEC-10,1980.00,20 9102,PETERSON,SALESMAN,7698,20-DEC-10,2600.00,30,2300.00 9103,WARREN,SALESMAN,7698,22-DEC-10,5250.00,30,2500.00 9104,"JONES, JR.",MANAGER,7839,02-APR-09,7975.00,20
[root@yamax ~]# edbldr -d edb userid=enterprisedb/enterprisedb control=/tmp/ctl/emp.ctl EDB*Loader: Copyright (c) 2007-2016, EnterpriseDB Corporation. edbldr error: ERROR: could not open "/tmp/data/emp.dat" 許可がありません
なお、SQL*Loaderとは異なり useridパラメータは省略できません。そのため、SQL*Loaderで使われているedbldr scott/tiger control=xxxx といったログイン情報の指定はできないのでご注意ください。
LOAD DATA INFILE stdin -- 標準入力を指定 BADFILE 'emp.bad' APPEND INTO TABLE emp FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS ( empno, ename, job, mgr, hiredate, sal, deptno, comm )
[root@yamax ~]# edbldr -h DB-SERVER-HOST -p 5444 -d edb userid=enterprisedb/enterprisedb control=emp_stdin.ctl < /tmp/data/emp.dat EDB*Loader: Copyright (c) 2007-2016, EnterpriseDB Corporation. Successfully processed (4) records
[root@yamax ~]# cat /tmp/data/emp.dat|edbldr -h DB-SERVER-HOST -p 5444 -d edb userid=enterprisedb/enterprisedb control=emp_stdin.ctl EDB*Loader: Copyright (c) 2007-2016, EnterpriseDB Corporation. Successfully processed (4) records
■本記事の内容について
本記事に示した定義及び条件は変更される場合があります。あらかじめご了承ください。
■商標に関して
・Oracle®、Java、MySQL及びNetSuiteは、Oracle、その子会社及び関連会社の米国及びその他の国における登録商標です。
・Amazon Web Services、AWS、Powered by AWS ロゴ、[およびかかる資料で使用されるその他の AWS 商標] は、Amazon.com, Inc. またはその関連会社の商標です。
文中の社名、商品名等は各社の商標または登録商標である場合があります。
EDB Postgres Workload Reportsは、Postgresデータベースのパフォーマンス診断とトラブルシューティングを強化する新しいツールです。OracleのAWRに似た詳細なレポートを提供し、データベースの問題を迅速に特定・解決できるようサポートします。本記事では概要と利用手順をご紹介します。
35年以上教育事業を展開しているアシストが新たに取り組み始めた「ポスグレ学園」。連載10回目となる今回の記事では、OSS-DB Gold試験対策問題集 出版の経緯や内容を 新校長 我妻にインタビューしました。
EDB社のAjit Gadge氏を招き「PostgreSQLユーザーに捧ぐ、EDBを使ったDB機能向上とコスト削減の両立」セミナーを開催しました。DB市場の現状やトレンド、EDBの最新動向について紹介しております。アシストセッションのアーカイブ配信の視聴申し込みも可能です。ぜひご覧ください。