Hacker News .hn (a.k.a HN2)new | past | comments | ask | show | jobs | submitlogin

So, can these be mixed with functional indexes to index on json fields?


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-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.


And 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;...

So now it is indeed possible!


Is there any reason to believe that you would not? I would be very surprised if there was any "pure" expression in PostgreSQL on which you couldn't have an index over comparison.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: