Function for yield to forward to PostgreSQL with configurable retention period.