Delete all rows of a table

Anyone found a way to delete all rows of a table in the DB?

Hi! :wave:

  1. Create a Backend workflow to delete a list of things;

  2. Go to your database, select all the rows, click in the “Bulk” button, and select the workflow created in step 1.

Yea but it tends to crash and have runtime issues, or be very slow, any other ways?

:thinking: I never had a crash doing this way… but yes, it is slow. I think this is the best way to do it…

It crashes if the amount of rows is more than 10,000 on the server-side and 1000 on the client-side.

You create the recursive workflow.

API workflow “Delete all things”:
1)Delete a thing
2)Schedule API workflow “Delete all things” (Conditional search for things:count>0)

It still will take some time if the DB is big, how many rows do you have?

Some tables are 30-50k some over a million

Over a million…
I definitely advise you to considerate to delete the database itself…

1 Like

That is a functionality im looking into aswell, find a way to wipe the DB clean. Anyone has any idea how to do that?

For databases with volumes over a million, recursive workflows is probably pretty much your only option. You’ll have to experiment with the delay needed between each cycle, but probably something a quarter of a second would work - but that would still mean you’d need about 250 000 seconds (70 hours) to delete everything. 50k would mean about 3,5 hours. You may be able to push the delay even more to speed things up, but keep an eye on your capacity charts. We have an article on recursive workflows here.

If this is a one-time job, I’d consider wiping the DB as well. You’ve got three options for doing that:

  • If the LIVE version DB is still empty, you can copy it into development (only way to pick specific tables)
  • Depending on your plan, you can restore your DB to a time when it was empty
  • You can make a copy of the app and choose not to copy the db

hi, did you find a way ? i have the same problem…

No way still…

This is why Bubble drives me crazy sometimes! A simple operation like this. Any other tool you have this possibility easily. When you are developping, you may do this frequently!!

1 Like

I totally agree. The DB management in Bubble is difficult. I am so tempted to use a different backend.

1 Like

I tried this solution recently mentioned here, and it sucked up all my WUs and the app was taken off the internet. Please do not try this anymore, after Bubbles new WU Tier Pricing. Could get expensive

I’m not certain about the cost with the new WU metrics, but you can also delete records using the Data API and any external tool that allows you to make looped API requests. Essentially, you can create a Python script with ChatGPT and run it in the cloud or on a personal PC. This will likely be faster than using recursive workflows in Bubble. Don’t forget to disable pagination, though.