PostgreSQL 9.5: random sample from a table
blog.2ndquadrant.com