For the indexes see http://clarkdave.net/2013/06/what-can-you-do-with-postgresql-and-json/ and/or http://www.postgresql.org/docs/9.3/static/indexes-expressional.html