PostgreSQLカンファレンス2014に行ってきました

  • 05 Dec 2014

2014年のPostgreSQLカンファレンスに行ってきました。9.4の改良が気になっていたので一日使って聴きに行ってきました。

ここに書いていあるのは個人の走り書きであり、正確性は保証致しません。あしからず。

NTTDATAとPostgreSQLを使い倒す

笠原辰仁 澤田雅彦

メインのトークは時間の都合で聞けず・・。最後のQAだけメモ。

Q.商用とOSSの棲み分けは?
A.明確なガイドラインはない。今回の事例ではコストの面が優先されている。

Q.PostgreSQLを利用するためのテストはどのように?
A.テストの仕方は堅実に単体テスト~結合テストを愚直にやっている。単純なSQLからJavaから操作する方法まで試す。

Q.1インスタンスで10TBは大きいですがストレージの工夫は?
A.速いディスクと遅いディスクを作っていて、ポスグレの機能を利用して利用先(ディレクトリ)をオブジェクト毎に変えてIOを分散している。バックアップはハードウェアスナップショットをとっている。

Q.SQLのチェックツールについて。型の違うJOINなどをチェックしていると聞いたがどうしてもせざるを得ないこともあるはず。この場合、どこまで上流に戻るのか?
A.大前提、すべてのSQLをチェックするものではない。業務上、どうしてもそうせざるを得ないものはOKしている。一方で、JOINが15などあるケースを検知したら適正化している。

Q.どういう観点でサイジングしているか?
A.メモリであればオンラインマニュアルにセオリーがある。同時接続数・業務処理量などをもとにざっくり計算をしている。ディスクサイズについては、過去の経験測を利用したり関連部署に見積もり取っている。このぐらいのテーブルであればこのぐらいのサイズになるというデータがWEB上にあるので参考に。

New features of postgreSQL 9.4

資料が全部英語。

Michael Paquier Working on Postgres for VMWare Community hacker and blogger Based in TOKYO

ブログに9.5の新しい機能について書いたよ
@michaelpq

planet.postgresql.org

postgres 9.4.0 RC1 released on 20th Nov
Beta period
	6 month!
	Beta1 => 11th May

FILTER and aggregates forget CASE .. THEN NULL > where id < 5 then id else null > FILTER (WHERE id < 5 ) (!!)

WHITHIN GROUP > SELECT mode() WITHIN GROUP (ORDER BY id) FROM modetab; (!!) > SELECT percentile_count(0.3) WITHIN GROUP (ORDER BY id), > percentile_disc(0.3) WITHIN GROUP (ORDER BY id) FROMpercent_tab (!)

unnest() and WITH ORDINALITY > SELECT * FROM unnest(array[1,2], array[3,4,5]) WITH ORDINALITY

GIN indexes improved key lookup (common AND rare) improved compression using delta method Less space, up to 6x Cost come extra CPU ex) pg_trgm on “Les Miserables” 9.3 -> 24MB 9.4 -> 8MB (!!!)

JSONB Binary representation on JSON Key order not preserved Faster than JSON datatype Key uniqueness: last value wins

JSONB- GIN index Lookup to all keys possible with 1 index (!!) no more index per key!! Compact Faster than 9.3 and … MongoDB!!

Auto-updatable views column-base update Automatically detected

WITH CHECK
	LOCAL, on current view only
	CASCADE, with parents (default)

INSERT and UPDATE control for ..

Materialized view Refresh CONCURRENTLY Unique index on relation Share Update Exclusive lock => READ/WRITE OK! save at disc though view !?

ALL IN TABLESPACE Move all objexts of a dataase to new place ALTER TABLE ALTER INDEX ALTER MATERIALIZED VIEW

pg_stat_statements tracking of query ID Hash value Calculated using parse tree Save stat file at shutdown

ALTER SYSTEM Manipulate configuration settings postgresql.auto.conf in PGDATA Takes priority on postgresql.conf SIGHUP params OK, but restart tricky

session_preload_libraries Automatically load library for given session Can be changed with ALTER ROLE Useful for debugging auto_explain local_preload_libraries for all sessions No need to LOAD

pg_prewarm Module in cotrib/pg_prewarm Useful for tests to avoid/reduce ramp-up Preload buffers in OS or Postgres cache

Stacktrace using pl/pgsql Userful for debugging of multiple levels!

Replication slots Block WAL file deletion until consumption Prevent replication conflicts with xmin horizon report Danger: monitoring of pg_xlog partition. wal_keep_segment not needed! Use Replication slots!

TIme delayedstandbys Delayed live backups Can fixunfortunate transactions Not untransactional, like DROP DATABASE WAL replayed, commit delayed

Logical decoding Get logical changed from WAL

Dynamic bgworkers 9.3limitation spawn at server startup connection to only one database Canbe started at will max with max_worker_processes Build your own structure launcher/worker!

wal_log_hints backup features pg_stat_archiver, view archiving activity

And more, far more…

参考

  • http://h50146.www5.hp.com/services/ci/opensource/pdfs/PostgreSQL_9_4%20_Ver_1_0.pdf
  • http://michael.otacoo.com/content/materials/20141205_postgres_94_features.pdf
  • http://www.slideshare.net/InsightTechnology/incoming-postgresql94
  • http://www.atmarkit.co.jp/ait/articles/1409/04/news005_2.html
  • http://www.atmarkit.co.jp/ait/articles/1410/09/news009_3.html
  • http://tyawan080.hatenablog.com/entry/2014/10/27/235630