Fix issue with postgres and distinct + random order.