What's New In PostgreSQL 9.4

19
PostgreSQL 9.4 Sneak Peek Pavan Deolasee March 28, 2014 India PostgreSQL User Group Meetup Hyderabad

description

A sneak peek at what's coming in PostgreSQL 9.4. Many more things will be added before the beta is released. But hopefully this will give an idea what's already there.

Transcript of What's New In PostgreSQL 9.4

Page 1: What's New In PostgreSQL 9.4

PostgreSQL 9.4 Sneak PeekPavan DeolaseeMarch 28, 2014

India PostgreSQL User Group MeetupHyderabad

Page 2: What's New In PostgreSQL 9.4

Who am I ? Pavan Deolasee

� http://www.linkedin.com/in/pavandeolasee PostgreSQL/Postgres-XC Consultant Contributor to PostgreSQL and Postgres-XC Global

Development� Best known for development of Heap-Only-Tuple (HOT)

feature� Contributed several other enhancements to PostgreSQL

and derivatives� Contributed to Postgres-XC's architectural design and

implementation of several features Previously worked for EnterpriseDB and Symantec/Veritas

Page 3: What's New In PostgreSQL 9.4

PostgreSQL Recap

• is world's most advanced open source database• is very stable• is fully compliant with ANSI SQL• supports foreign key, check constraints• supports various kinds of indexes• supports inheritance • Is fully extensible (data types, procedural languages

etc)• supports ACID transactions• will recover your database in case of server failure

Page 4: What's New In PostgreSQL 9.4

PostgreSQL Recap• uses write-ahead-logs for durability and recover your

database in case of• server failure• built-in log based streaming

synchronous/asynchronous replication• file system level backups and archive recovery• point-in-time recovery• hot standby• upgrade in place• full-text search• and many more

Page 5: What's New In PostgreSQL 9.4

Configuration/Admin• Read-only GUC to show if data checksum is enabled or not

– Useful to know if the server is initialized with data checksums on/off.

– Previously, user must look at pg_control to get this information

• New autovacuum_work_mem parameter– Separates it from the work_mem parameter

• A GUC to enable WAL-logging of hint bits, even with checksums disabled.– Turn this on if you want to use external tools such as

pg_rewind to quickly get you old master join the replication as a new standby

– More WAL generated, so be aware of the performance impact

Page 6: What's New In PostgreSQL 9.4

Configuration/Admin• A GUC, max_worker_processes, limiting number of

bgworkers.• A GUC, session_preload_libraries, specifying preload

libraries at session startup– Takes effect at backend start– Doesn’t require a full server restart

• A new pg_stat_archiver statistics view.• Improve EXPLAIN to print the grouping columns in Agg

and Group nodes.• Default work_mem and maintenance_work_mem

increased by 4x

Page 7: What's New In PostgreSQL 9.4

SQL Improvements

• Revive line typeCREATE TABLE LINE_TBL (s line);

• Represented by• Equation Ax + By + C = 0

INSERT INTO LINE_TBL VALUES ('{1,-1,1}');

• Two points (x1, y1), (x2, y2) INSERT INTO LINE_TBL VALUES ('(0,0),(6,6)');

Page 8: What's New In PostgreSQL 9.4

SQL Improvements• Allow only some columns of a view to be auto-

updateable.

CREATE TABLE base_tbl(a float);CREATE VIEW rw_view1 AS SELECT ctid, sin(a) s, a, cos(a) c

FROM base_tbl WHERE a != 0;

INSERT INTO rw_view1 VALUES (null, null, 1.1, null); -- should fail

INSERT INTO rw_view1 (a) VALUES (1.1) RETURNING a, s, c;-- OK

UPDATE rw_view1 SET s = s WHERE a = 1.1;-- should fail

Page 9: What's New In PostgreSQL 9.4

SQL Improvements

• Materialized Views - Support for REFRESH CONCURRENTLY– Readers won’t be blocked while a MatView is being

refreshed• WITH CHECK OPTION support for auto-updatable

VIEWs– INSERTs/UPDATEs not satisfying the view visibility will

be rejected– LOCAL CHECK only checks against the current view– CASCADE CHECK checks against all the underlying

views

Page 10: What's New In PostgreSQL 9.4

SQL Improvements• Provide a FORCE NULL option to COPY in CSV mode.

– Forces an input field containing the quoted null string to be returned as a NULL. Without this option, only unquoted null strings behave this way.

– Helps where some CSV producers insist on quoting every field, whether or not it is needed.

– Takes a list of fields, and only applies to those columns.

CREATE TEMP TABLE forcetest (a INT NOT NULL, b TEXT NOT NULL, c TEXT, d TEXT, e TEXT);\pset null NULLCOPY forcetest (a, b, c) FROM STDIN WITH (FORMAT csv, FORCE_NOT_NULL(b), FORCE_NULL(c));

Page 11: What's New In PostgreSQL 9.4

SQL Improvements

• DISCARD SEQUENCES command.– Will discard cached values for sequences

• Allow empty target list in SELECT• WITHIN GROUP and ordered-set aggregates• Support multi-argument UNNEST(), and

TABLE() syntax for multiple functions.

Page 12: What's New In PostgreSQL 9.4

Developer Features

• Improve support for building PGXS modules with VPATH.

• Use an MVCC snapshot, rather than SnapshotNow, for catalog scans.

• Dynamic background worker threads• Allow background workers to be started dynamically.• Single-reader, single-writer, lightweight shared

message queue.• Allow on-detach callbacks for dynamic shared memory

segments.

Page 13: What's New In PostgreSQL 9.4

Security

• SSL: Add configuration option to prefer server cipher order

• SSL: Support ECDH key exchange• Rework SSL renegotiation code

Page 14: What's New In PostgreSQL 9.4

Performance

• Change the way tuples are marked as frozen.– Xmin is preserved for forensic analysis and debugging.– Allows aggressive freezing of tuples without fear of

lossing critical debugging information• Aggressively freeze tables when CLUSTER or VACUUM

FULL rewrites them.• Include planning time in EXPLAIN ANALYZE output.• Improve performance of numeric sum(), avg(),

stddev(), variance(), etc.• Improve performance of COPY with default nextval()

Page 15: What's New In PostgreSQL 9.4

Performance

• Only WAL-log the modified portion in an UPDATE, if possible.

• Improve scalability of WAL insertions.• Allow using huge TLB pages on Linux

(MAP_HUGETLB)• Speed up "rare & frequent" type GIN queries.

Page 16: What's New In PostgreSQL 9.4

Replication

• Allow time delayed standbys and recovery– Set min_recovery_apply_delay to force a delay

in recovery apply– Delay is measured between WAL record time

and local standby time.• If multiple recovery_targets are specified, use

the latest one.

Page 17: What's New In PostgreSQL 9.4

Logical Replication (WIP)

• Introduce logical decoding.– Fine granular replication– Bi-directional replication

• Add new wal_level, logical, sufcient for logical decoding.

• Add the notion of REPLICA IDENTITY for a table.

• Allow logical decoding via the walsender interface.

Page 18: What's New In PostgreSQL 9.4

Resources

• Release Notes• Planet PostgreSQL• Documentation• Source Code

3/30/14 18