3 ms·
Currently, it doesn't seem so - most of the functions have their volatility declared as stable, not immutable, so you can't simply create an index on the functi
by hannibalhorn 14y ago
Currently, it doesn't seem so - most of the functions have their volatility declared as stable, not immutable, so you can't simply create an index on the function without getting an erorr. I think long term the postgresql guys plan on supporting special GiST indexes for JSON, but that didn't make it into 9.3.
Many of the presentations on using plv8 to access JSON in Postgres 9.2 (e.g., https://wiki.postgresql.org/images/b/b4/Pg-as-nosql-pgday-fosdem-2013.pdf https://wiki.postgresql.org/images/b/b4/Pg-as-nosql-pgday-fo... ) show the use of functional indexes, but they create a plv8 function marked as immutable.
I imagine you could create a wrapper function marked immutable that calls the provided json accessor functions, but I'm not really clear on the implications of doing so.
- hannibalhorn 14y agoAnd it turns out that marking many of the JSON functions stable was an oversight and was corrected in git a few days ago: http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=d788121aba3425b5d52fe20cc9facb6aca1294ce http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;... So now it is indeed possible!