Forum Academy Marketplace Showcase Pricing Features

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…

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