IndexedDB-对象存储vs多个数据库vs索引? [英] IndexedDB - ObjectStores vs multiple databases vs indices?

查看:62
本文介绍了IndexedDB-对象存储vs多个数据库vs索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道一个数据库与一个具有多个对象存储的数据库是否是一个好主意.我已经阅读了网上的大多数教程,并查看了indexedDB的规范,但是找不到比较这些不同概念的好例子.有人针对这种事情有具体的示例(使用多个对象存储和/或代码的设计模型)吗?

I was wondering when it would be a good idea to have a single database vs one database with multiple object stores. I've read most tutorials on the web as well as looked at the specification for indexedDB, but could not find a good example comparing these different concepts. Does anyone have a concrete example (a design model using multiple object stores and/or code) for this sort of thing?

推荐答案

只要对象存储之间没有交叉事务处理,就可以将它们分为多个数据库.我更喜欢使用尽可能多的单独数据库,以便在较小的对象存储数据库中更容易进行模式更改.

As long as there is no cross transactional manipulation among object stores, you can separate them into multiple databases. I prefer to use separate database, as many as possible, so that schema changes are easier in smaller object store database.

在极少数情况下,即使需要交叉交易,我什至也使用单独的数据库.这些情况在用户设置数据库和应用程序数据库之间找到.用户设置和应用程序之间的不一致很好,因为事实是用户设置,并且暂时的不一致无关紧要.

In rare situation, I even use separate database even if cross transaction is require. These cases are found between user setting database and application database. Inconsistency between user setting and application are fine, since the truth is in user setting and temporary inconsistency does not matter.

请注意,与打开数据库相关的成本很高.但是一旦打开,连接就不会消耗任何内存.数据库数量没有限制.

Notice that there is high cost associate with opening a database. But once it is open, there is no memory consume for the connection. There is no limit in number of databases.

多个数据库 的吞吐率要高于具有多个对象存储的单个数据库,因为Firefox的实现会在任何写入事务中锁定整个数据库.

Multiple databases will have higher thourghput than single database with multiple object stores, since implementation of Firefox lock down whole database on any write transaction.

这篇关于IndexedDB-对象存储vs多个数据库vs索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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