Selena Deckelmann - PLV8

JSConf US 2013

31 May 2013

Schema design & JSON didn’t get on before plv8 and JSON datatype

Schema liberation: modelling documents/schemas so they closely resemble application-level objects (MongoDB has flexible schema for this reason so it’s popular with developers)

JSON far more friendly to the developer than a set of SQL statements

Can Postgres be flexible?

9.3 Postgres + plv8 (9.2 postgres + json_enhancements works too)

v8 = js engine plv8 = v8 embedded in Postgres

    select * from reports;
    select row_to_json(*) from reports (doesn't work - need subselect to achieve it)
    create table liberated as (
      // subselect here

2 mins to run this on huge db

JSON datatype is a First class datatype

    create table birds (sighting json);
    insert into birds values (
      // json object here
    INSERT 0 1;

create indexes, compare, join against, use JSON columns like any other Postgres column, etc.

plv8 trusted - don’t need to be a superuser to run (python is untrusted for instance, need to be superuser) - plv8 can be run by users

supports running raw SQL, prepared statements, cursors

direct JS injection (if you’re crazy enough to want to…!)

why use postgres to store JSON vs NoSQL DB?

  1. use “bulkbag” schema design + schema evolution - JSON to start, normalize to optimize. I.e. store the data at first, work out best way to normalize it later once true structure known·

  2. easily scale to multi-TB DBs, write/read heavy loads, non-cloud storage, etc

  3. manage your data with a language you love

9.3 beta is available now -

Twitter: @selenamarie


JSConf 2013

This is a quick summary of a talk I attended at JSConf 2013. You can see a list of all those I've summarized notes from here. There's also a General thoughts during JSConf 2013 post for all the non-talk bits and pieces.

There were 3 concurrent tracks at the conference, so only those I attended myself are summarized here. Other attendees have summarized some of the talks I didn't get to due to scheduling conflicts - you can find those at (James Long) and Toby Ho's github repo.