1

I want to delete all data in "Realtime Database", without increasing "Usage Load" in "Realtime Database".

any idea for deleting that data? is 420,000+ data in realtime database

Here is image

If you can help me, its very usefull..

Image Total Data

Image Usage Load

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Azickri
  • 35
  • 5

1 Answers1

4

There is support for deleting large nodes built into the Firebase CLI these days as explained in this blog How to Perform Large Deletes in the Realtime Database:

If you want to delete a large node, the new recommended approach is to use the Firebase CLI (> v6.4.0). The CLI automatically detects a large node and performs a chunked delete efficiently.

$ firebase database:remove /path/to/delete


My initial write-up is below. I'm pretty sure the CLI mentioned above implements precisely this approach, so that's likely a faster way to accomplish this, but I'm still leaving this explanation as it may be useful as background.

Deleting data is a write operation, so it's by definition going to put load on the database. Deleting a lot of data causes a lot of load, either as a spike in a short period or (if you spread it out) as a lifted load for a longer period. Spreading the load out is the best way to minimize impact for your regular users.

The best way to delete a long, flat list of keys (as you seem to have) is to:

  1. Get a list of that keys, either from a backup of your database (which happens out of band), or by using the shallow parameter on the REST API.
  2. Delete the data in reasonable batches, where reasonable depends on the amount of data you store per key. If each key is just a few properties, you could start deleting 100 keys per batch, and check how that impacts the load to determine if you can ramp up to more keys per batch.
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807