This is the presentation used at Dec 2014 Meetup event for Postgres User Group, Singapore.
I discussed on key highlight features of v9.4 of PostgreSQL.
2. •JSONB-jsonBinary Storage
•Replication improvements-Replication Slots
•Logical Decoding in WAL log
•Time Lagging Replica
•pg_prewarm
•ALTER SYSTEM Command
•Great new enhancements in aggregation features
3. Wasn’t JSON was introduced in v9.2? Well it just got better
JSONB is much more optimized and faster for lookup
New functions to extract and manipulate the jsondata
You have the flexibility without compromising on Reliability!
Non-relational data with ACID compliance!
4. row_to_json–to convert a row to json
json_object–Create jsonobject out of text array
json_build_object–Create jsonobject out of variadicargument list
array_to_json–to converan array to JSON
json_eachand json_each_text–convert jsonobjects in key-value pair
json_extract_path-Get value of a jsonobject
json_populate_recordand json_populate_recordset-Convert jsonobject to records
5. Operator
Operand Type
Purpose
->
int
Get JSON arraryelement
->
text
Get JSON object field
->>
int
Get JSON array element as text
->>
text
Get JSON object fieldas text
#>
array of text
Get JSONobject at specified path
#>>
array of text
Get JSON object at specified path as text
@>
jsonb
Does the left JSON value contain within it the right value?
<@
jsonb
Is the left JSON value contained within the right value?
?
text
Does the key/elementstringexist within the JSON value?
?|
text[]
Do any of these key/elementstringsexist?
?&
text[]
Do all of these key/elementstringsexist?
7. select data from Table as a jsonobject-
SELECT
JSON_BUILD_OBJECT( 'name',name)
FROM books;
Convert a row to json
SELECT ROW_TO_JSON(my_row)
FROM ( SELECT ROW(books.*)
FROM books )my_row;
8. Select output of join as a jsonobject-
SELECT JSON_BUILD_OBJECT( 'name', name, 'author', name_arr)
FROM(
SELECT ARRAY_AGG( a.name ) AS name_arr, b.name AS name
FROM authors a JOIN author_book_mapab ON a.id=ab.author_id
JOIN books b ON b.id=ab.book_id
GROUP BY b.name ) books_authors_join;
9. Now you need to guess “wal_keep_segment” to avoid walfiles from getting removed
Simply create a replication slot and WAL which are yet not replicated to the slot will not be removed from live WAL location
Time Lagging Replica-You can define a lag period for your replica
This can be used for back-dated reporting
Or recover from a user error –an accidentally dropped table or a truncated table
10. Set WAL level to ‘logical’ to do more verbose recoding in WAL files
This will also record table and relation level details in each WAL entry
These WAL files can be used for logical decoding and logical replication to replicate changes on a particular table
There are commercial and open source solutions which are in beta stage and are based on this approach
11. ALTER SYSTEM Command-Now a DBA can alter the configuration with ALTER SYSTEM command and avoid changing it in postgresql.conf
pg_prewarm-now a DBA can load certain relations and blocks in cache after startup and avoid performance issues due to cold-reboot
12. https://wiki.postgresql.org/wiki/What's_new_in_PostgreSQL_9.4
Hangout Recording for Replication Features in v9.4- https://www.youtube.com/watch?v=-HkrXwaWCb8
EnterpriseDB Whitepaper-http://www.enterprisedb.com/nosql-for-enterprise
http://www.craigkerstiens.com/2014/03/24/Postgres-9.4-Looking-up/
Or just mail me…
sameer.kasi200x@gmail.com
sameer.kumar@ashnik.com