coddingtonbear / django-measurement

Easily store, retrieve, and convert measurements of weight, volume, distance, area and more.
MIT License
145 stars 32 forks source link

Support for PostgreSQL ArrayField #75

Open mcneillj opened 6 years ago

mcneillj commented 6 years ago

When storing large time series fields we are required to model our data with

ArrayField(MeasurementField(measurement=Temperature)), size=1000)

This requires storing data with a unit for each value in the time series. When querying the database we have to loop through each individual measurement to reconstruct the array. It would be very helpful to have the ability to have an array data model similar to this:

MeasurementArrayField(measurement=Temperature), size=1000)

This would allow us to store a single unit value per array and retrieve the data as an array in a single operation.

codingjoe commented 6 years ago

Hi @mcneillj interesting, I'd really like to learn more about your use case.

ArrayField(MeasurementField(measurement=Temperature)), size=1000)

Seems the more intuitive way for me, to create such an array. What precisely do you mean by "looping". What's causing the performance issues?