Deleting Telescope entries in Laravel 8

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Mastering Massive Data: How to Effectively Clear Laravel Telescope Entries

As developers building large-scale applications with Laravel, monitoring tools like Telescope are invaluable for debugging and understanding user flows. However, when those tools accumulate massive amounts of data—like your scenario involving 28 million entries consuming 30GB of space—they transition from being a helpful feature to becoming a performance bottleneck. Trying to use standard Artisan commands like telescope:clear or telescope:prune and hitting timeout errors is a common frustration when dealing with truly enormous datasets.

This post will dive deep into why these commands fail on massive Telescope installations and provide concrete, developer-focused strategies for safely clearing your data without waiting for timeouts. We will explore the underlying mechanisms and best practices for managing large application telemetry.

The Problem: Why Standard Commands Fail

When you attempt to clear or prune Telescope data, the process often involves scanning millions of related entries in the database or file system. For datasets reaching tens of millions of records, this exhaustive scanning process can easily exceed PHP's execution limits or database query timeouts, leading to the errors you are encountering. The commands are designed for regular maintenance but lack the necessary optimization for extreme scale.

The core issue is not that the data exists, but that the method used to process the deletion is inefficient for this scale. We need a solution that bypasses the slow iteration and targets the storage mechanism directly.

Solution 1: Direct Database Pruning (The Advanced Approach)

Since Telescope stores its detailed request/session logs in the underlying database, the most reliable way to handle massive cleanup is often to bypass the application layer commands and interact directly with the relevant tables.

If you are using the default setup, Telescope data is stored within the framework's tables. For large-scale maintenance, a direct SQL query is significantly faster than letting the application layer iterate through millions of rows.

Caution: Always back up your database before running direct deletion queries on production systems.

Here is a conceptual example of how you might approach clearing related data if you know the specific table structure (this assumes Telescope uses standard Eloquent structures):

-- Conceptual SQL for mass deletion (adjust table names based on your actual setup)
DELETE FROM telescope_entries 
WHERE created_at < DATE_SUB(NOW(), INTERVAL 30 DAY); -- Example: Deleting entries older than 30 days

For true, aggressive clearing of old data, you might need to investigate the specific tables Telescope populates. This method shifts the heavy lifting from PHP execution to the highly optimized SQL engine. When architecting large applications, understanding how your ORM interacts with the database is key, much like respecting the principles outlined on sites like laravelcompany.com.

Solution 2: Manual File System Cleanup (For Cached Logs)

In addition to database entries, Telescope often caches logs in the storage/framework/telescope directory. If you are dealing with accumulated log files that are consuming significant disk space, a manual removal of these directories can instantly free up space.

If the data is stored as large JSON or serialized files within this folder, deleting the entire directory (or specific subfolders) forces the operating system to reclaim the space immediately. This is often the fastest way to tackle the 30GB storage issue, even if it doesn't perfectly "clear" the database records themselves.

# WARNING: Use with extreme caution! Ensure you understand what you are deleting.
rm -rf storage/framework/telescope/*

Best Practices for Preventing Future Overload

Dealing with massive data accumulation is less about fixing a single failure and more about implementing robust maintenance practices from the start.

  1. Implement Scheduled Maintenance Jobs: Instead of relying on manual intervention, schedule Telescope pruning as a recurring Artisan command using Laravel's scheduler. Set this job to run nightly or weekly to keep the dataset manageable before it reaches critical mass.
  2. Configure Retention Policies: If possible, configure your application or monitoring tools to enforce data retention policies directly within the system settings rather than relying solely on manual cleanup scripts.
  3. Review Logging Levels: For high-volume applications, consider adjusting logging levels to reduce the sheer volume of entries Telescope has to track in the first place.

Conclusion

Clearing massive Laravel Telescope data requires moving beyond simple command execution. When facing timeouts with large datasets, developers must adopt a multi-layered approach: using direct database interaction for efficient pruning and employing manual file system cleanup for immediate disk space recovery. By integrating scheduled maintenance jobs and proactive retention policies, you can ensure your application remains performant and scalable, adhering to the high standards of development seen at laravelcompany.com.