Examining PostgreSQL 9.4 – A first look
craigkerstiens.com
craigkerstiens.com
* GIN optimizations for smaller index size and faster search. This should mean faster full text searching
* Time delayed replication standbys.
* CHECK OPTION for auto updatable views, I believe the constraints were slightly relaxed on which views can be updatable too.
* Replication slots looks promising, this should make it easy to setup a replication slave which does not have to be reinitialized on long network failures. No more WAL shipping needed.
* Printing the planning time in the EXPLAIN output (only since I wrote it myself).
Indeed, huge. Mysql has a relatively mature lag replica history now albeit via Percona. Adding delayed replicas to Postgres will be fantastic.
When we start to have slightly larger databases (multi terabyte) then delayed replicas become a very useful backup and recovery strategy. Typically we need to recover databases when there has either been human error (someone deletes a bunch of data they should not have) or a compromise. In these situations rather than restoring for a nightly backup it is _always_ faster to roll a delayed replica forward and promote it to be master then resync all the normal replicas.
[1] http://www.depesz.com/tag/postgresql/
[2] http://www.depesz.com/2014/01/10/waiting-for-9-4-pg_prewarm-...
[3] http://www.depesz.com/2014/01/11/waiting-for-9-4-support-ord...
I've been lugging my RULES/Trigger functions for this feature for years.
Indeed. Postgres has some amazing features, and yet something so basic has been missing for years. I can't wait for a simple UPSERT, especially that most workarounds work correctly only with 1-row inserts.
What it works for really well
Table inheritance works really, really well for enforcing consistent interfaces to repeatedly used pieces of information which are independent for referential integrity purposes. For example, we've all seen horrors involving global notes tables with umpteen join tables.... Inheritance provides a very clean solution to that problem: have an abstract notes table (which can double for query purposes as a global notes table) and worker tables which have foreign keys which attach specifically to other tables.
For example, in LedgerSMB we have a note table, an invoice_note table a eca_note table (notes for customer/vendor agreements), and more. The nice thing is, the tables all have the same structure and can be managed structure-wise as if they were a single table.
For example, an alter table statement on note can affect all sub-tables in many cases (other than unique constraints, primary or foreign keys, etc). If I want to add a virtual column for full text searching, I can do this with a single function as follows:
CREATE OR REPLACE FUNCTION tsvector(note)
RETURNS tsvector
language sql immutable as
$$ SELECT to_tsvector($1.subject || ' ' || $1.note); $$;
Then eca_note.tsvector will just work (subject to limitations of this syntactic feature of PostgreSQL). I could even index the output of the function on any note subtable.What It Does Not Work For
So inheritance is often sold as a way of tracking part/whole relationships and other type/subtype problems. The problem is that these currently break down where you need referential integrity enforcement across an inheritance tree. Consequently, while I see inheritance as a really, really useful feature, it is a feature that is largely useless for the problems it was originally intended to solve. Now, it is getting better (9.2 added NOINHERIT constraints, which allow you to apply different check constraints to parent and child tables, useful if you want to forbid all inserts to the parent table), but the really big problems have to do with the inability to properly inherit unique indexes, and therefore not to referential integrity enforcement against a whole inheritance tree.
In general in these cases, you are better off with a single table, and designing a structure without table inheritance to model the information.
The problem I think is that this is likely to force some significant redesign of indexes. It isn't a trivial problem to solve.