首页 > 解决方案 > Efficient NoSQL data model for large collections

问题描述

Scenario:

There are 1,000,000 coordinates (pixels) in an element.

A coordinate consists of x: number, y: number

Users select a single coordinate to 'activate'

Objective to User:

Show a count of unique coordinates activated.

i.e. 247,456 out of 1,000,000 coordinates have been activated

DB Objectives:

How should such a large data set be modeled in NoSQL?

Approach #1 Pre-populate a collection with the possible coordinates and remove them / increment a counter as the coordinates are activated

Searching through the list would be expensive, but only improve as more coordinates are activated.

Approach #2 Have a growing collection of documents as the coordinates are activated and increment.

Reading/writing would become increasingly expensive without an efficient architecture.

标签: angulardatabasefirebasenosqldata-modeling

解决方案


使用第二种方法,只需花时间围绕它构建一个良好的架构,因为这将非常有用并进一步降低文档的读取成本以删除第一种方法中的坐标


推荐阅读