在Cloud Firestore数据库中删除集合时,可以使用哪些推荐参数? [英] Which are the recomended arguments to use when deleting a Collection within a Cloud Firestore database?

查看:49
本文介绍了在Cloud Firestore数据库中删除集合时,可以使用哪些推荐参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下方法删除Cloud Firestore集合,如

I'm using the following method to delete a Cloud Firestore collection as explained here.

deleteCollection(
    final CollectionReference collection,
    final int batchSize,
    Executor executor)

我尝试使用以下三个Executors中的每一个,并且可以与其中之一正常工作.

I have tried to use each one of the following three Executors and it works fine with which one of them.

ExecutorService executorService = Executors.newFixedThreadPool(5);
ExecutorService executorService = Executors.newCachedThreadPool();
ExecutorService executorService = Executors.newSingleThreadExecutor();

建议在调用deleteCollection()方法时使用哪种效率更高?还是有更好的选择? 为避免内存不足错误,建议使用什么推荐的batchSize?

Which one is recomended to be more efficient and used when calling deleteCollection() method? Or is there a better one? What is the recommended batchSize we need to use to avoid out-of-memory errors?

提前打招呼!

推荐答案

您在此处看到的用于Android的示例代码直接来自

The sample code you see there for Android comes directly from this code in GitHub. Digging around in there, you can see that the sample coded uses the following Executor:

private static final ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(2, 4,
    60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());

这是否是您的特定情况的最佳案例,这实际上是不可能的.

Whether or not that's the best possible case for your particular situation, that's not really possible to say.

关于批量大小,文档还建议您需要进行判断:

Regarding the batch size, the documentation also suggests that you need to make a judgement call:

如果您有更大的收藏夹,则可能要删除文档 批量较小,以避免内存不足错误.

If you have larger collections, you may want to delete the documents in smaller batches to avoid out-of-memory errors.

鉴于我们并不十分了解您的具体情况,因此不可能给出绝对可以为您提供最佳解决方案的答案.

Given that we don't really know your specific situation, it's not really possible to give an answer that definitively gives you a best-possible solution.

这篇关于在Cloud Firestore数据库中删除集合时,可以使用哪些推荐参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆