G
G
GLaDosSystem2019-04-13 18:58:07
PostgreSQL
GLaDosSystem, 2019-04-13 18:58:07

How to thin out values ​​in PostgreSQL?

Hello.
I have a large number of rows in my database that contain a column with a number (>10000000).
I need to somehow process all this data on the server side in such a way as to get a fixed number of rows in which the column with the number will be averaged. At the same time, if the number in one of the rows increases sharply, it would be nice if it affected the average value. How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2019-04-16
@GLaDosSystem

You need to google on SQL moving-average
https://stackoverflow.com/questions/13818524/movin...
And after getting the average values, you can select every Nth value to another table.
If we are talking about metrics, then it would probably be easier to use TimescaleDB .

An open-source time-series SQL database optimized for fast ingest and complex queries. Packaged as a PostgreSQL extension.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question