将 CouchDB 复制到本地沙发会减小大小 - 为什么?

发布于 2024-12-27 02:48:07 字数 589 浏览 2 评论 0原文

我最近开始在我正在开发的一个大型应用程序中使用 Couch。

我的数据库有7907个文件,想重命名数据库。我查了一下,但不知道如何重命名它,所以我想我只需将它复制到我想要的名称的本地数据库中即可。

我第一次尝试时,复制失败,我相信错误是超时。我又试了一次,很快就见效了,这有点令人不安。

复制后,我显示新数据库具有正确的记录数量,但数据库大小约为原始数据库的 1/3。

还有一点奇怪的是,如果我刷新蒲团,原始数据的大小会在 94.6 到 95.5 mb 之间波动,

这给我留下了几个问题:

  1. 第二个数据库是否存储对第一个数据库的引用?如果是这样,我可以删除第一个数据库而不造成损害吗?

  2. 为什么尺寸会如此不同?原来建立的索引是否与新索引最终建立的一样?

  3. 为什么尺寸会波动?

编辑

一些可能有用的事情:

  • 这是在cloudant couchdb安装上
  • 我检查了新数据库的第一个和最后一个记录,它们匹配,所以我不相信futon报告不足。

I recently started using Couch for a large app I'm working on.

I database with 7907 documents, and wanted to rename the database. I poked around for a bit, but couldn't figure out how to rename it, so I figured I would just replicate it to a local database of the name I wanted.

The first time I tried, the replication failed, I believe the error was a timeout. I tried again, and it worked very quickly, which was a little disconcerting.

After the replication, I'm showing that the new database has the correct amount of records, but the database size is about 1/3 of the original.

Also a little odd is that if I refresh futon, the size of the original fluctuates between 94.6 and 95.5 mb

This leaves me with a few questions:

  1. Is the 2nd database storing references to the first? If so, can I delete the first without causing harm?

  2. Why would the size be so different? Had the original built indexes that the new one eventually will?

  3. Why is the size fluctuating?

edit:

A few things that might be helpful:

  • This is on a cloudant couchdb install
  • I checked the first and last record of the new db, and they match, so I don't believe futon is underreporting.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

第七度阳光i 2025-01-03 02:48:07

复制到新数据库类似于压缩。两者都涉及某些副作用(分别是偶然的和有意的),这些副作用会减少新 .couch 文件的大小。

  • B 树索引得到平衡
  • 旧文档修订中的数据被丢弃。
  • 先前对数据库更新的元数据将被丢弃。

复制存储到检查点或从检查点存储,因此如果您从同一源重新复制到同一位置(即重新运行超时的复制),它将从中断处继续。

答案:

  1. 复制不会创建对另一个数据库的引用。您可以删除第一个而不会造成伤害。
  2. 复制(和压缩)通常会减少磁盘使用量。如果您在任何设计文档中有任何视图,这些视图将在您首次查询时重新构建。视图索引使用自己的 .view 文件,该文件也会消耗空间。
  3. 我不确定为什么尺寸会波动。浏览器和代理缓存是 CouchDB(和 Web)开发的祸根。但也许这也是 Cloudant 内部行为的结果(例如,集群中的不同节点报告的大小略有不同)。

Replicating to a new database is similar to compaction. Both involve certain side-effects (incidentally, and intentionally, respectively) which reduce the size of the new .couch file.

  • The b-tree indexes get balanced
  • Data from old document revisions is discarded.
  • Metadata from previous updates to the DB is discarded.

Replications store to/from checkpoints, so if you re-replicate from the same source, to the same location (i.e. re-run a replication that timed out), it will pick up where it left off.

Answers:

  1. Replication does not create a reference to another database. You can delete the first without causing harm.
  2. Replicating (and compacting) generally reduces disk usage. If you have any views in any design documents, those will re-build when you first query them. View indexes use their own .view file which also consumes space.
  3. I am not sure why the size is fluctuating. Browser and proxy caches are the bane of CouchDB (and web) development. But perhaps it is also a result of internal Cloudant behavior (for example, different nodes in the cluster reporting slightly different sizes).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文