1
1

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 3 years have passed since last update.

実行SQLをログ出力

Posted at

postgresql.confを修正して実行SQLをログ出力する設定をします。

# vi /var/lib/pgsql/data/postgresql.conf

下記の行を"mod" に指定

log_statement = 'mod'                   # none, ddl, mod, all

restartします。

# /etc/init.d/pgsql restart

すると[INSERT、UPDATE]のSQLが出力され、allにするとSELECT含めのログ【/var/log/postgresql.log】が出力されます。

select文を出したい場合

log_statement = 'all'   
log_min_duration_statement = 0

※log_min_duration_statementはスロークエリを本来検出するもので、200msなどが設定されてると思います。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?