Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.67k stars 603 forks source link

Storing and searching timeseries data in WatermelonDB #1174

Open readysteadygo2006 opened 3 years ago

readysteadygo2006 commented 3 years ago

Hi,

I new to WatermelonDB and sqllite. I'm reading through the doc on schema.

I need to store timeseries data, which I need to search by timestamp.

I've googled around sqllite which underpins WatermelonDB, it seems ok with indexes based on timestamp.

I may be simplifying things here, please correct my misunderstanding!

Within the WatermelonDB schema doc you write:

"However, you should almost never index date (_at) columns or string columns. "

Given my requirements, will creating an index in Watermelon based on a timestamp break something (or be hopelessly none performant) in watermelon or the underlying sqllite?

I've read the following: https://stackoverflow.com/questions/65422890/how-to-use-time-series-with-sqlite-with-fast-time-range-queries

And I am will to accept a somewhat space wasting index, to get a straightforward and performant means of filtering the db by timestamp.

I'm guessing in this era of IOT, storing and searching timeseries data is a common requirement, to which Watermelon must have been applied, is there a good off-the-shelf approach which I could adopt?

Any help would be much appreciated!

radex commented 3 years ago

instead of asking, you should just check. Indexing in Watermelon is just indexing in sqlite, so if your use case requires indexing a number field, then do it!

readysteadygo2006 commented 3 years ago

Thanks, was intending to do just that! Still going thru setup to get watermelon working in my expo eas app, so just trying clarify points I can, prior to being in a position to test things out for myself BR