索引的 IndexedDB 性能:Select 和插入
IndexedDB Performance of Index: Select and Insert
问题 1:
Q1.1
IndexedDB(Javascript 版本)做 select 或插入的复杂度是多少?索引是否被“索引”?它是排序的还是散列的?例如,当我们使用 IDBKeyRange.only 时,它需要 O(1)、O(log(n)) 或 O(n) 时间?
Q1.2
IDBKeyRange.bound怎么样?它是先对索引进行排序,然后再进行 select?
Q1.3
IDBObjectStore.add() 的性能如何?
Q1.4
对于index.openCursor(),索引是否提前排序?
问题 2:
我们正在使用 IDBObjectStore.createIndex() 创建索引。
如果问题 1 中的答案是肯定的(这意味着索引被索引),如何创建带有索引或不索引选项的索引?换句话说,我选择一些索引进行排序或散列,而另一些则不。我们有这个选择吗?
规范不强制要求性能特征。假设使用 B-tree 的实现是合理的,因此操作 O(log n),但您需要在浏览器中测试实现。如果特定浏览器在常见操作上表现不佳,可能值得将其作为问题报告。
Q1.1 What is the complexity of IndexedDB (Javascript version) doing
select or insert? Whether the indexes are "indexed"? Is it sorted or hashed?
索引已排序。 https://w3c.github.io/IndexedDB/#index-construct
Q1.2 How about the IDBKeyRange.bound? Is it sorting the index first and then doing the select?
查找是针对排序的索引。
Q1.3 What is the performance of IDBObjectStore.add()?
假设一个 B 树,O(log n)
Q1.4 For index.openCursor(), is the index sorted in advance?
是的。
尽管从技术上讲,实现可以延迟创建索引——规范不要求特定的性能或实现,只是结果无法区分。
Question 2:... how to create index with options indexed or not indexed? In other words, I choose some indexes to be sorted or hashed, while others not. Do we have this choice?
否 - API 没有提供这样的选项。
问题 1:
Q1.1
IndexedDB(Javascript 版本)做 select 或插入的复杂度是多少?索引是否被“索引”?它是排序的还是散列的?例如,当我们使用 IDBKeyRange.only 时,它需要 O(1)、O(log(n)) 或 O(n) 时间?
Q1.2
IDBKeyRange.bound怎么样?它是先对索引进行排序,然后再进行 select?
Q1.3
IDBObjectStore.add() 的性能如何?
Q1.4
对于index.openCursor(),索引是否提前排序?
问题 2:
我们正在使用 IDBObjectStore.createIndex() 创建索引。 如果问题 1 中的答案是肯定的(这意味着索引被索引),如何创建带有索引或不索引选项的索引?换句话说,我选择一些索引进行排序或散列,而另一些则不。我们有这个选择吗?
规范不强制要求性能特征。假设使用 B-tree 的实现是合理的,因此操作 O(log n),但您需要在浏览器中测试实现。如果特定浏览器在常见操作上表现不佳,可能值得将其作为问题报告。
Q1.1 What is the complexity of IndexedDB (Javascript version) doing select or insert? Whether the indexes are "indexed"? Is it sorted or hashed?
索引已排序。 https://w3c.github.io/IndexedDB/#index-construct
Q1.2 How about the IDBKeyRange.bound? Is it sorting the index first and then doing the select?
查找是针对排序的索引。
Q1.3 What is the performance of IDBObjectStore.add()?
假设一个 B 树,O(log n)
Q1.4 For index.openCursor(), is the index sorted in advance?
是的。
尽管从技术上讲,实现可以延迟创建索引——规范不要求特定的性能或实现,只是结果无法区分。
Question 2:... how to create index with options indexed or not indexed? In other words, I choose some indexes to be sorted or hashed, while others not. Do we have this choice?
否 - API 没有提供这样的选项。