Used CollectionBox on Flutter Web seems to be slower than regular Hive.openBox
- Dominant language
- Dart
- Stars
- 4.4k
- Forks
- 449
- PR merge metrics
- No merged PRs in 30d
Description
**Question**
According to the recommendation in the Readme, I used BoxCollection in my Flutter Web app however it appears to be much slower than regular Hive.openBox which goes against what it says in the readme (at least for fetching small amounts of data, which is normal in my app).
Is there a negative to using Hive.openBox on Flutter Web that I don't know about?
Retrieval time for 10 Maps is about 10ms on CollectionBox and 0ms with regular Box. (maybe there is a speedup when retrieving thousands of Maps although that far less common in my use case so I'm less worried about it)
**Code sample**
```dart
late Box> blocksBox;
@override
void onInit() async {
blocksBox = await Hive.openBox>('blocks');
super.onInit();
}
Future addToBox(Map> blocks) async {
await blocksBox.putAll(blocks);
}
Future?>> getBlockMaps(List ids) async {
Map?> blockMaps = {};
for (String id in ids) {
Map? map = blocksBox.get(id);
if (map == null) {
blockMaps[id] = null;
} else {
blockMaps[id] = map;
}
}
return blockMaps;
}
```
**Version**
- Platform: Web
- Flutter version: Channel beta, 3.12.0, on macOS 13.3.1 22E772610a darwin-arm64, locale en-AU
- Hive version:
hive:
git:
url: https://github.com/hivedb/hive.git
path: hive
ref: b35d2e4
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the README guidance for BoxCollection and compare its Flutter Web retrieval path with Hive.openBox using the supplied getBlockMaps example. Reproduce the timing difference for 10 maps, then determine whether the behavior reflects an implementation issue or expected overhead and document the result or required change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- databases, performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100