Considerations when cleaning up a big table

Without causing downtime or making production slow

Joel Clermont
Joel Clermont

There are multiple reasons we don't recommend running Telescope in production: security, performance, database growth, to name a few.

But let's say you have a project that has been running Telescope in production for a while, and you want to clean up the data. What is the best way to do this without having any negative impacts on your production environment?

First and foremost is to disable Telescope. This might seem obvious, but if you go about trying to clean up the data, and you haven't yet disabled Telescope, you're going to have a bad time. If production requests are trying to write to those same tables you're trying to clean up, you are going to impact real users.

Once that's taken care of, the simplest path is to just drop the tables and recreate them. Then you don't have to worry about a ton of I/O operations, foreign key constraints, or any other internal database housekeeping.

Just to be clear, this sort of database manipulation is not something you should do lightly. You might even consider building a new migration to handle the drop and recreate operations, just to avoid any mishaps in production.

Here to help,


P.S. Speaking of security, have you downloaded our free book on Laravel security yet?

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼

Level up your Laravel skills!

Each 2-minute email has real-world advice you can use.