简体   繁体   English

CouchDB的性能分析

[英]Performance Analysis of CouchDB

I am developing a Discussion Forum for my University. 我正在为我的大学开发一个讨论论坛。 For this to manipulate the data im using CouchDB as database. 为此,使用CouchDB作为数据库来处理数据即时消息。

I m finding difficulty in designing the structure of my db, in order to maximize the performance of my db. 我在设计数据库结构时遇到了困难,以便最大化数据库的性能。

I want to discuss what is the good practice of designing a document database. 我想讨论设计文档数据库的良好实践是什么。

  1. Either we should make only one database as SQL and make 'n' no. 要么我们只使一个数据库作为SQL,然后使“ n”为否。 of documents in the database. 数据库中的文档数量。
  2. Or we can make more no of database in order to flatten my db structure.This also reduce the more no. 或者我们可以增加数据库数量以使我的数据库结构扁平化,这也减少了更多数量。 of documents to be developed. 要开发的文件。

The questions you need to ask are simply this: "How do you want to get data out of your database?" 您只需要问这些问题:“您想如何从数据库中获取数据?”

Database design hinges around the queries to be made, not what is available to be stored. 数据库设计取决于要进行的查询,而不是要存储的内容。

This is especially important for Document DBs like Couch, since, while it does have a flexible schema, it does not have flexible indexing. 这对于像Couch这样的文档数据库特别重要,因为尽管它具有灵活的架构,但是却没有灵活的索引。 By that I mean that because of the granularity of the data, it's quite like that later on, when you need to ask a question that it was not designed to answer, answering that question may well be very expensive. 我的意思是说,由于数据的粒度,因此就像以后,当您需要提出一个并非旨在回答的问题时,回答该问题可能非常昂贵。 It's much, much cheaper to design your views and other constructs early, when there is little data in the data base rather than later after you have thousands or millions of rows. 当数据库中的数据很少时,而不是在拥有成千上万的行之后才进行设计,尽早设计视图和其他构造要便​​宜得多。

RDBMS's, since they tend to have a finer granularity of data, tend to be more nimble to new queries and such later in life. 由于RDBMS倾向于具有更精细的数据粒度,因此对于新的查询以及以后的此类查询而言,它们更加灵活。 Document DBs, not so much. 文档数据库,不是很多。

So think through your use cases up front, and design around those, and design those early on, it's much less painless now than later. 因此,请仔细考虑您的用例,并围绕这些用例进行设计,并尽早进行设计,与现在相比,现在变得更加轻松。

It's hard to tell the right way to approach modeling your data since you don't give much information. 因为您提供的信息不多,所以很难说出正确的方法来对数据建模。 Generally though you want to keep as much data as possible in one database as this allows you to index it together (indexes cannot span more than one database). 通常,尽管您希望在一个数据库中保留尽可能多的数据,因为这样可以使它们一起索引(索引不能跨越一个以上的数据库)。

Also, since there is no schema enforcement in the database, you can create different types of records in each database. 另外,由于数据库中没有架构强制实施,因此您可以在每个数据库中创建不同类型的记录。 For example, there is nothing wrong with have both user information and forum entries in the same database. 例如,将用户信息和论坛条目都放在同一个数据库中没有任何问题。

Last, you will most likely want to keep messages and their replies in different records. 最后,您很可能希望将邮件及其回复保留在不同的记录中。 This is an old but still relevant discussion on this topic: http://www.cmlenz.net/archives/2007/10/couchdb-joins 这是关于该主题的古老但仍然相关的讨论: http : //www.cmlenz.net/archives/2007/10/couchdb-joins

Cheers. 干杯。

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

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