简体   繁体   English

CouchDB压缩

[英]CouchDB Compression

I have a MySQL database that I wanted to store on an external 4TB drive, but when I copied the database over to it, the server failed to restart. 我有一个要存储在外部4TB驱动器上的MySQL数据库,但是将数据库复制到该数据库时,服务器无法重启。 I found out it had something to do with a sector size issue. 我发现这与扇区大小问题有关。

This gave me reason to make the jump to NoSQL. 这使我有理由跳到NoSQL。 I like CouchDB for its ease of use and HTTP API, but the database is simply not going to work for me without compression. 我喜欢CouchDB的易用性和HTTP API,但如果不进行压缩,该数据库将无法正常工作。 I have a 40GB MySQL database, and the data migration isn't even a tenth of the way complete and it's already over 100GB. 我有一个40GB的MySQL数据库,数据迁移还不到完成的十分之一,并且已经超过100GB。

Is there something I'm missing? 有什么我想念的吗? Do/Can I enable compression? 是否可以压缩?

Thanks! 谢谢!

CouchDB trades disk-space for read/write speed. CouchDB以磁盘空间换取读写速度。 It's very likely a comparable CouchDB database will take up more disk-space than MySQL. 一个可比的CouchDB数据库很可能会比MySQL占用更多的磁盘空间。

That being said, there are a number of things you can do to conserve disk-space: 话虽这么说,您可以做很多事情来节省磁盘空间:

  • Database file compression is available, (as you pointed out) but you should probably experiment with the various algorithms to find out what works best in practice. 数据库文件压缩是可用的(如您所指出的那样),但是您可能应该尝试各种算法,以找出最适合实际的算法。
  • Database compaction periodically throughout your import process, and as part of routine maintenance. 在整个导入过程中,以及作为日常维护的一部分,定期压缩数据库
  • Lastly, when writing your views, do not emit the entire document as part of the index. 最后,在编写视图时, 请勿将整个文档作为索引的一部分emit Instead, use the include_docs=true query-param. 而是使用include_docs=true查询参数。 (see docs for other params) (有关其他参数,请参阅文档

In other words, avoid this: 换句话说,避免这种情况:

function (doc) {
  emit(doc.key, doc);
}

For each view you write like this, each emit means that the document is being duplicated in your database. 对于您这样写的每个视图,每个发射都表示该文档正在数据库中重复。 Thus, you only need to do this: (most of the time, you don't need that 2nd argument) 因此,你只需要做到这一点:(大多数时候,你并不需要的是第二个参数)

function (doc) {
  emit(doc.key);
}

I'm sure there are other things you can do, if I think of more I'll amend this answer. 我确信您还有其他事情可以做,如果我想更多的话,我将修改此答案。 (please comment if you know of anything I missed) (如果您知道我错过的任何事情,请发表评论)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM