第1页
PostgreSQL 9.4
JSON, Analytics, and More
Japan PostgreSQL Users Group Satoshi Nagayasu @pgcon china 2014
第2页
你好!
• 我叫永安悟史。
• 我来自日本。 • 请多多关照。
第3页
Satoshi Nagayasu
• 2004
– NTT DATA
• 2005
– JPUG PR Director
• 2009
– Uptime Technologies
• 2010
– JPUG Chairperson
• 2013
第4页
Satoshi Nagayasu
• Database Engineer • Data Center Engineer • ITSM Specialist • Data Steward • System Architect • Co-founder • CTO
第5页
What I Did in PostgreSQL
• pgstatindex • pageinspect • xlogdump
– ... and lots of rejected patches!
• Patch review • PostgresForest, Postgres-XC
第6页
China and Me
• My Father was born in 青岛. • Had a project with a few engineers
from 北京 at NTT DATA China. • Love 四川菜 and 白酒.
第7页
Thanks to...
• Magnus Hagander • Michael Paquier • Toshi Harada • Noriyoshi Shinoda
• ... and many pg guys!
第8页
Agenda
• 9.4 Overview • NoSQL (JSON and GIN Index) • Analytics (Aggregation & Mat.View) • Replication and Beyond (Logical
Decoding) • Administration (ALTER SYSTEM) • Infrastructure (For Parallelization)
第9页
9.4 Overview
第10页
9.4 Overview - Status
• Current Status
– RC1 released on 20th November
• Officially announced 9.4 to be released on 18th December (the next Thursday)
第11页
9.4 Overview - Statistics
• As of beta2 (by Magnus Hagander)
– 2222 files changed – 131,805 insertions (+) – 59,333 deletions(-)
• As of RC1 (by Michael Paquier)
– 2183 files changed – 374,421 insertions (+)
第12页
9.4 Overview - Changes
第13页
9.4 Overview - Changes
Server Indexes General Performance Monitoring SSL Server Settings Replication and Recovery Logical Decoding Queries Utility Commands EXPLAIN Views Object Manipulation Data Types JSON Functions System Information Functions Aggregates Server-Side Languages PL/pgSQL Server-Side Language libpq Client Applications psql Backslash Commands pg_dump pg_basebackup Source Code Additional Modules pgbench pg_stat_statements
第14页
Categories of Enhancements
• NoSQL (JSON and GIN Index) • Analytics (Aggregation & Mat.View) • Replication+ (Logical Decoding) • Administration (ALTER SYSTEM) • Basic Infrastructure (Parallelization)
第15页
NoSQL
(JSON and GIN Index)
第16页
NoSQL - JSONB
• JSON vs. JSONB
第17页
NoSQL - JSONB
• “Binary JSON”
– Different from JSON, a text representation
– Faster for searching
• With JSONB...
– No duplicated keys allowed. Last wins. – Key order not preserved.
第18页
NoSQL - GIN Index
• JSON+btree vs. JSONB+GIN
– Btree indexes vs. GIN index Table Index Size Comparison
http://www.slideshare.net/toshiharada/jpug-studyjsonbdatatype20141011-40103981
第19页
Analytics
(Aggregation & Materialized View)
第20页
Analytics - Aggregation
• FILTER replaces CASE WHEN.
第21页
Analytics - Aggregation
• New Aggregate Functions
– percentile_cont() – percentile_disc() – mode() – rank() – dense_rank() – percent_rank() – cume_dist()
第22页
Analytics - Aggregation
• Ordered-set aggregates
– mode(), most common value in a subset
第23页
Analytics - Aggregation
• Ordered-set aggregates
– rank(), rank of a value in a subset
第24页
Analytics – Materialized Views
• REFRESH MATERIALIZED VIEW CONCURRENTLY myview
• Allows refreshing a MV concurrently without taking exclusive lock.
• Refreshing a large MV can benefit from CONCURRENTLY in terms of
第25页
Replication and Beyond
(Logical Decoding)
第26页
Replication and Beyond – Logical Decoding
• “Logical” representation from replication stream
– INSERT/UPDATE/DELETE operations – Can be replayed on different version/platform
• pg_recvlogical command
– It shows how it works
• Replication can be more flexible
– BDR (Bi-Directional Rep.), Slony, and more ...
第27页
pg_recvlogical (contrib)
第28页
Administration
(ALTER SYSTEM)
第29页
Administration - ALTER SYSTEM
• ALTER SYSTEM SET
– puts new value in postgresql.auto.conf – pg_reload_conf() reloads them. – postgresql.auto.conf takes priority over
postgresql.conf.
• ALTER SYSTEM RESET
– Remove values from
第30页
Infrastructure
(For Parallelization)
第31页
Dynamic Background Workers
• In 9.3, background workers must start at the postmaster startup.
• After 9.4, they can be launched “ondemand” basis.
• From parallelization point of view...
– It allows to launch multiple background processes to execute child queries in
第32页
Dynamic Shared Memory
• Shared memory can be allocated “ondemand” basis
– Cf.) by background workers
• Main segment (ex. shared_buffers) still fixed at startup
• Also supports lightweight message queue
• From parallelization point of view...
– It allows to share data and communicate with
第33页
My Tiny Favorite
(pl/pgsql stacktrace)
第34页
pl/pgsql stacktrace
http://h50146.www5.hp.com/services/ci/opensource/pdfs/PostgreSQL_9_4%20_Ver_1_0.pdf
第35页
Many other enhancements, so please try it asap.
第36页
Any Question? 有什么问题吗?
第37页
Thank you! 谢谢!