- Formatted the query to meet SQL coding styles - Add index on {files} to prevent performance regression - Fork the SQL query based on DB family based on support