Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define the time accuracy of written timestamp #274

Open
Kopierwichtel opened this issue Oct 24, 2022 · 1 comment
Open

Define the time accuracy of written timestamp #274

Kopierwichtel opened this issue Oct 24, 2022 · 1 comment

Comments

@Kopierwichtel
Copy link

Is your feature request related to a problem? Please describe.
I'm using iobroker with a postgresql db to store the history. To visualize the data i'm using grafana. The sql adapter is storing the timestamp as ms. When querying for a timeframe of data in grafana (e.g. last 3 hours), grafana is only able to filter for seconds or nanosec. I solved this by deviding the saved timestamp by 1000. But This leads to a huge performance issue: The query takes 9 seconds instead of 60ms due to the conversion. This is becoming a problem because the DB is growing.

Describe the solution you'd like
My idea is that the SQL adapter provides a setting to define the accuracy of the timestamp, Seconds, Milliseconds, NanoSeconds

Describe alternatives you've considered

  • Maybe providing a text field to store a formula like "/1000" to calculate the timestamp
  • Also any workaround on DB level is appreciated, I was thinking about a trigger while saving the value to directly convert it
@Kopierwichtel
Copy link
Author

I found a nice workaround which is fine for me but maybe not possible to normal users: I created a Generated Column in Postgresql which converts the timestamp to seconds directly when the DB entry is created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants