SQL queries timeout when missing timestamp filter
Last updated: March 2, 2026
Plans: Free, Pro, Enterprise
Deployments: Braintrust Hosted, Hybrid
Scenario: SQL queries on project_logs() without a timestamp filter
Summary
Issue: SQL queries using project_logs() time out when scanning large datasets without timestamp constraints, even with other filters applied.
Cause: Without timestamp filters, queries can scan the entire project history regardless of other WHERE conditions.
Resolution: Add a timestamp filter using created or another timestamp column to limit the scan range.
Resolution Steps
Add timestamp filter to your query
Step 1: Add created timestamp constraint
Add a created filter to your WHERE clause before other conditions.
SELECT *
FROM project_logs('proj_12345678-1234-1234-1234-123456789012')
WHERE
created > now() - interval '7 days' AND
metadata.session_id = 'sess_12345678-1234-1234-1234-123456789012' AND
span_attributes.name = 'Model Call'
LIMIT 100Step 2: Adjust time range as needed
Modify the interval based on your investigation needs: '1 day', '30 days', etc.
Best practices for project_logs queries
Always include timestamp filters
This is a required best practice for acceptable query performance, not an optional optimization.
Start with narrow time ranges
Begin with shorter intervals (e.g., '1 day') and expand only if necessary.
Use specific date ranges for known timeframes
For specific investigations, use explicit date boundaries.
WHERE created BETWEEN '2024-01-01' AND '2024-01-31'