Database selection question

Status
Not open for further replies.

The_Lynx

Smack-Fu Master, in training
50
Subscriptor++
I have a dataset which I would like to store in a database to allow automatic optimisation of the algorithm we are developing. The dataset is currently about 2GB in size but will rapidly expand over the course of the project.

The data set comprises of a number of experimental occasions lasting 5 minutes with 4 channels of data being collected 2000 times per second. Currently we have approximately 30 occasions recorded and this will shortly expand to well over 100. We need to test our algorithm across all of this dataset. I am therefore looking to store each occasion in its own document. Each document needs to store 3 or 4 channels (in some occasions one of the channels was unobtainable) currently and in the future we would be looking at a number more in each occasion (at least 8)

I was going to use MongoDB or a similar NoSQL database, as the flexibility with the structure of the entries is very appealing, but I'm running up against the JSON document limit (each document is currently about 55mb) . I'm used to SQL (Postgres and Mysql) but it isn't appealing due to its inflexibility and the amount of boilerplate I will need to write.

Should I bite the bullet and switch to one of "traditional" databases or am I just doing it wrong?
 

Apteris

Ars Tribunus Angusticlavius
9,589
Subscriptor
It sounds like Apache Spark could be relevant to your interests, and in particular its machine learning library MLlib. Have you looked at them?

The_Lynx":100yg1vb said:
I have a dataset which I would like to store in a database to allow automatic optimisation of the algorithm we are developing.
Why a database? Do you need concurrent operations and ACID transactions?

Or do you instead just need a powerful query language?

The data set comprises of
Either "comprises" or "is comprised of", not "comprises of". ;)

I'm used to SQL (Postgres and Mysql) but it isn't appealing due to its inflexibility and the amount of boilerplate I will need to write.
I don't know enough about NoSQL to see how it would be more flexible than an SQL database, but regarding boilerplate, you might look at jOOQ. It can be quite elegant in places.
 

The_Lynx

Smack-Fu Master, in training
50
Subscriptor++
[url=http:/civis/viewtopic.php?p=31407611#p31407611:wh6uweja said:
rain shadow[/url]":wh6uweja]on what basis did you dismiss just storing the data in a flat file?

I initially rejected it because eventually we will end up with thousands of occasions with hours of data for each one. I realise I have tried to optimise too early and for the time being flat files are ok. I can always convert them later.

Good to be told I'm going it wrong.
 

Fruity Pebbles

Ars Praetorian
595
Subscriptor
[url=http:/civis/viewtopic.php?p=31410793#p31410793:1ht2azzt said:
The_Lynx[/url]":1ht2azzt]
[url=http:/civis/viewtopic.php?p=31407611#p31407611:1ht2azzt said:
rain shadow[/url]":1ht2azzt]on what basis did you dismiss just storing the data in a flat file?

I initially rejected it because eventually we will end up with thousands of occasions with hours of data for each one. I realise I have tried to optimise too early and for the time being flat files are ok. I can always convert them later.

Good to be told I'm going it wrong.

Perhaps a hybrid approach would be helpful. Use a database to store the metadata about each occasion, including the filename, and leave the actual data in flat files. This isn't an ideal approach - you have to deal with the fact that the filenames tie your database data into your filesystem structure (i.e. if you pick up the database and move it to another server you may need to fixup the filenames to match your new location).
 
[url=http:/civis/viewtopic.php?p=31406579#p31406579:23aa7oqb said:
The_Lynx[/url]":23aa7oqb]I have a dataset which I would like to store in a database to allow automatic optimisation of the algorithm we are developing. The dataset is currently about 2GB in size but will rapidly expand over the course of the project.

The data set comprises of a number of experimental occasions lasting 5 minutes with 4 channels of data being collected 2000 times per second. Currently we have approximately 30 occasions recorded and this will shortly expand to well over 100. We need to test our algorithm across all of this dataset. I am therefore looking to store each occasion in its own document. Each document needs to store 3 or 4 channels (in some occasions one of the channels was unobtainable) currently and in the future we would be looking at a number more in each occasion (at least 8)

Can you expand a bit on what you're storing?. 5 minutes * 60 seconds/minute * 4 channels * 2000 points/sec = 2.4 million data points. You currently have 30 occasions, so that's 30 * 2.4e6 = 72 million data points. Is this the same dataset that is currently 2GB? That's roughly 28 bytes per data point, so is it correct to assume that you're currently storing a very verbose timestamp with each data point? Or are your data points larger than something like a 64-bit integer or float?

Also, what are your use cases for the data store? Do you just need some way to store the data points and then re-load an entire dataset at a later time? Flat files are awesome for this scenario.

[url=http:/civis/viewtopic.php?p=31406579#p31406579:23aa7oqb said:
The_Lynx[/url]":23aa7oqb]I was going to use MongoDB or a similar NoSQL database, as the flexibility with the structure of the entries is very appealing, but I'm running up against the JSON document limit (each document is currently about 55mb) . I'm used to SQL (Postgres and Mysql) but it isn't appealing due to its inflexibility and the amount of boilerplate I will need to write.

:confused: Are you trying to insert the entire dataset as a single row in your MongoDB database? That kind of defeats the purpose of using a database to store the data in the first place. If you're just looking to store/retrieve the entire dataset, there's no reason to stuff those files in to a database. Just put them on disk.

A database would be useful if you had a reason to query the data points individually or according to criteria, but it's counter-productive if you're just trying to catalog 30-100 files.
 

rain shadow

Ars Tribunus Angusticlavius
6,680
Subscriptor++
[url=http:/civis/viewtopic.php?p=31410793#p31410793:3rk2ah1i said:
The_Lynx[/url]":3rk2ah1i]
[url=http:/civis/viewtopic.php?p=31407611#p31407611:3rk2ah1i said:
rain shadow[/url]":3rk2ah1i]on what basis did you dismiss just storing the data in a flat file?

I initially rejected it because eventually we will end up with thousands of occasions with hours of data for each one. I realise I have tried to optimise too early and for the time being flat files are ok. I can always convert them later.

Good to be told I'm going it wrong.
I wouldn't quite say you're doing it wrong...premature optimization is a good way to put it.

It also depends on the pattern of accessing the data that your algorithm uses. If it has to read the whole dataset to do its processing then flatfile is fine for that.

If the algorithm's outputs have any relational aspect to them, possibly that is a candidate for storing in a db.
 

fitten

Ars Legatus Legionis
55,634
Subscriptor++
[url=http:/civis/viewtopic.php?p=31412351#p31412351:1hvktdmp said:
AgentQ[/url]":1hvktdmp]:confused: Are you trying to insert the entire dataset as a single row in your MongoDB database?

Reminded me of this: http://thedailywtf.com/articles/the-mainframe-database

Saw this thread the other day... just shook my head at massive JSON documents.
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
Use a timeseries database/file format.

They come in all sorts of flavours, and some can be very expensive (e.g. kdb) but plenty are free too. The basic dataframe approach of S+ (and R) should work fine for you for example.

What platform/language are you targeting? There are some very nice libraries for some of these things (I know of python and f# implementations of the dataframe approach for example) but they are often not language agnostic.
 
A time series database would be a good fit if the database functionality was used/needed.

If they're just looking for a place to stash chunks of data and load those datasets back all at once, a database is a step in the wrong direction.

Flat files all the way until you're actually doing something more complex than writing to a file and reading 100% of that file back in to memory.
 

Faramir

Ars Legatus Legionis
36,356
Subscriptor
[url=http:/civis/viewtopic.php?p=31410793#p31410793:2r0ngt38 said:
The_Lynx[/url]":2r0ngt38]
[url=http:/civis/viewtopic.php?p=31407611#p31407611:2r0ngt38 said:
rain shadow[/url]":2r0ngt38]on what basis did you dismiss just storing the data in a flat file?

I initially rejected it because eventually we will end up with thousands of occasions with hours of data for each one. I realise I have tried to optimise too early and for the time being flat files are ok. I can always convert them later.

Good to be told I'm going it wrong.
Not to pile on, but it isn't clear what it is exactly you think an database will get you. You can store a lot of data in a plain old file system. You can get file systems with great read performance, with redundancy, etc.

Only if you need random access to data points across multiple occasions and channels would I think that flat files would start to look suboptimal.
 

CUclimber

Ars Legatus Legionis
19,626
Subscriptor
[url=http:/civis/viewtopic.php?p=31418375#p31418375:3dlrttet said:
fitten[/url]":3dlrttet]
[url=http:/civis/viewtopic.php?p=31412351#p31412351:3dlrttet said:
AgentQ[/url]":3dlrttet]:confused: Are you trying to insert the entire dataset as a single row in your MongoDB database?

Reminded me of this: http://thedailywtf.com/articles/the-mainframe-database

Saw this thread the other day... just shook my head at massive JSON documents.
I don't even understand the thought process that would lead you to doing something like that. I've explained the basics of relational databases in just a few minutes to people who have no programming experience whatsoever. How could someone get it so wrong?
 
Status
Not open for further replies.