Improve inbox SQLs