I'm always reluctant to these kinds of ideas, of executing code on/within my database server.
I know it's apparently sandboxed, but that didn't work out too well for ElasticSearch recently: https://jordan-wright.github.io/blog/2015/03/08/elasticsearc....