PostgreSQL 9.2 released
postgresql.org
postgresql.org
- Allow libpq connection strings to have the format of a URI
- Add a JSON data type
- Allow the planner to generate custom plans for specific parameter values even when using prepared statements
- Add the SP-GiST (Space-Partitioned GiST) index access method
- Add support for range data types
- Cancel queries if clients get disconnected
- Add CONCURRENTLY option to DROP INDEX
- Add a tcn (triggered change notification) module to generate NOTIFY events on table changes
- Allow pg_stat_statements to aggregate similar queries via SQL
- text normalization. Users with applications that use non-parameterized SQL will now be able to monitor query performance without detailed log analysis.
Who needs CouchDB or Node.js when you can just say CREATE EXTENSION 'couchnodegres.js'
"With PostgreSQL 9.2, query results can be returned as JSON data types."
It also supports the PL/V8 stored procedure format, which is Javascript http://code.google.com/p/plv8js/wiki/PLV8
It's very, very close.
spc_handle_request(req_headers, req_body, http_method, ...)
stored procedure does simple routing and does something like insert into table (a, b, c) values (to_json(req_body).a, to_json(req_body).b, to_json(req_body).c);
or to_json(select * from emp);
Time to implement simple crud app: 10 minutes.* having written more than my share of press releases in my time
I happen to know the guy that AFAIK was in charge of preparing the press release and he's actually a major contributor to the codebase, a geek par excellence and have been nagging people to get him quotes on the development mailing list.
The fact that apart from hacking C code he also knows how to write a catchy press release just makes him all the awesomer :)
It's reminiscent of IBM, which is a huge compliment in this context.
Nobody's holding back anything. It would be wonderful if someone wanted to contribute their design skills to the web page or documentation -- talking to the mailing list pgsql-www is probably the way to do that. I am positive such a person would receive profuse appreciation, and maybe can parlay that into personal advantage if the fulfillment of the impact such improvements would have is not quite material enough by itself.
The project runs its own web site infrastructure (many regimes have come and went in Postgres' history, only semi-recently was pgfoundary decommissioned for the purpose of new projects), and it's a little arcane -- but if someone really wanted to take ownership to move things beyond maintenance into progress, perhaps changes could be made.
There really isn't much to it yet, it's basically a varchar field with JSON validation, it's not like you can query or index it.
I actually find the `row_to_json` and `array_to_json` functions more interesting for now (though strangely enough there's no `hstore_to_json`)
Hence, instead of waiting for that, JSON support in un-adorned Postgres to solve a common use case in the interceding years.
The jargon for what this gives you is "a stable oid". Also more or less equivalent to a "system OID" at this time. These "Object IDentifiers" in Postgres are unsigned int32s that are (almost?) never reused (only accrued, or removed), and are all under the number 10000, and all assigned statically by hand. A-priori knowledge of these numbers can simplify writing extensions dramatically, but clearly this is not scalable for a future with dependency chains in extensions.
What you can do right now though is use PL/V8 to query the JSON fields. Then you can use functional indexes to still being able to speed up queries. Yes. You could that before but now there's a guarantee that a field of type json contains just that, meaning that your application logic will get simpler.
Or the insertion/conversion routine can assert that the JSON object is a string:string mapping only.
Since hstore only handles string:string mapping, the choice is either to silently corrupt data by stringifying all values in the json->hstore encoding, or erroring out if the input data is anything other than string:string.
The latter would be what I'd prefer, and more in line with usual Postgres behavior.
Still, there's no reason why you couldn't write a function to index JSON however you like.
Having said that, hstore is perfect when storing simple key/values. It's been battle tested and used for years and has some powerful and native indexing possibilities.
PostreSQL can't horizontally scale easily or properly handle JSON right now compared to MongoDB. It also has a fixed schema which makes database migrations a necessary evil again. Sorry but the idea that PostgreSQL is a feature by feature replacement is pretty laughable.
Sure you can. Skype did it, Hitachi¹ did it.
¹http://www.pgcon.org/2008/schedule/events/57.en.html
> properly handle JSON right now
Well it has V8 running on it.
> It also has a fixed schema
You don't need to use it like that if you don't want to.
And again V8 is nice and all but it is rather bolted on as opposed to something that is was built from scratch to support JSON. This shows in terms of feature support and most importantly ease of use. I can't just annotate HashMaps, Lists etc in my Java classes and have them serialized to PostgreSQL in JSON format.
I am just saying that PostgreSQL is a great and all but it is not a proper JSON document store style database anymore than hacking SQL on top of MonogDB would make it a RDBMS.
The first is SECURITY BARRIER and LEAKPROOF which gives us an ability to rethink how to multi-tenant applications. This is a game changer and will get even better in future versions I am sure.
The second is NO INHERIT constraints, which I will certainly be making good use of. It is also a complete game changer when it comes to table inheritance and partitioning, and my main use will be things like CHECK (false) NOINHERIT to ensure that a table in fact never has rows of its own.
There is an amazing amount of good stuff going on around Postgres right now. Postgres-XC was recently released, and more. It is an amazing data modelling platform and ORDBMS.
One area where Oracle is ahead is in multi-tenant applications. They have an approach where you can build filters on data based on specific criteria. You can do this on PostgreSQL too but the way you have to do it before this either involves add-ons or actual partitions of data, or tweaks to prevent building functions altogether.
Security barriers are important in catching up to Oracle in this regard and they allow us to build more integrated multi-tenant applications with greater access to the db by the tenants.
NO INHERIT constraints open up a fairly large area of PostgreSQL for use or misuse, because you can now partition a primary key between parent and child declaratively. My own use will be to prevent inserts into the parent table directly. Table inheritance is a really neat feature if you use it in non-traditional ways. It is not particularly useful for its advertised use (set/subset stuff outside of partitioning). However what it allows you to do is to compose your tables out of smaller re-usable pieces each of which can have complex derivations of data attached. For example, if you want full text search on comments on a lot of your tables, you can create a consistent, centralized interface for this using table inheritance.
http://ledgersmbdev.blogspot.com/2012/08/intro-to-postgresql...
(though he should provide forward/backward links in the posts -- as it stands you need to find the other parts in the archive links on the right)
It doesn't really let us re-think it does it? It just closes a hole in how you would have typically done it anyways. Is there any way to solve the problem of having to create a new connection as company_X_user for every single request?
The problem is that there are performance and tooling issues when you have that many database objects, so those people can end up sad, even though the model was one they basically were happy with.
So I think adding database features for lucid multi-tenant work while reducing the risk of cross-tenant leakage is a movement in a good direction.
Yes you can accomplish that with Veil, but I agree, it would be nice if it was built in, but an add-on is ok too.
Personally, I'm excited about the range types and I can see immediate usefulness for them. My own applications aside, anything that helps developers create schemas that are better able to handle temporal data is a good thing.
Example of adding such a constraint:
ALTER TABLE reservation ADD EXCLUDE USING gist (room WITH =, during WITH &&);
In this example a room cannot be double booked.EDIT: This is a feature entirely unique to PostgreSQL.
Jonathan S. Katz will also be presenting on Range Types.
select * from coupons
where start_at < now() and (end_at is null or end_at > now())
Now, you can have a single column that represents the range of time that the coupon is active. select * from coupons where now() <@ duration;
Plus, exclusion contraints. So you could prevent the database from storing a coupon that was active at the same time as another coupon.User-extensible spacial index types. This makes Postgres perfect for online machine learning.
I am a huge fan of Postgres, it's never let me down. But data exploration, ad hoc querying and such is a pain in psql. These tools are badly needed.
I'm not sure about Sequel Pro, but being able to [reverse] incremental search on \d and \dt is a blessing.
If for some reason you want to eyeball sample data for a table with a ton of columns that won't fit in one screen, then a GUI's resizable columns are nice. But usually I just type of the columns of interest — us programmers are usually good typists.
Just found this: http://wiki.postgresql.org/wiki/Community_Guide_to_PostgreSQ...
Normal result:
column1 | column2 | column3
---------+---------+---------
1 | a | 9.9
2 | b | 19.9
(2 rows)
Using \x: -[ RECORD 1 ]-
column1 | 1
column2 | a
column3 | 9.9
-[ RECORD 2 ]-
column1 | 2
column2 | b
column3 | 19.9
The first form is tabular and works well for a few columns; but doesn't work well when there are many columns, because the lines start to wrap. So you use \x for wide tables to make the result readable (but, obviously, fewer rows are shown at a time).Using "\x auto" automatically chooses which format to use based on your terminal width.
I tried using it for a result that contains really wide columns. I'm seeing a screen full of hyphens separating the rows.
You'd think that the hyphens would stretch across just one line of the screen, instead of across the whole result set. See https://img.skitch.com/20120910-fn1abpp3w94yhg63hc8yemt4a4.p...
That's a problem for very wide fields, which aren't going to be handled very well even using \x.
\x was meant to handle large numbers of fields, or slightly wider fields.
But you're right, maybe that could be cleaned up a little more.
Of the small fixes in 9.1 my personal favorite is probably the cleanup of pg_stat_activity. There are also many other nice small fixes like improved tab completion for some commands and the ability to set environment variables in psql.