Purpose:
Get the number of times when something happened between the two moments when the order of magnitude of the account is 100,000 - 10,000,000.
Current implementation:
- Using PostgreSQL
- Each "incident" is recorded as a separate row in the table
Columns:
- Incident type
- Date when this happened
Request for a counter (pseudo-code):
COUNT rows WHERE time_occurred > <begin_time> AND time_occurred < <end_time>
Problem:
This works, but the request is very inefficient and takes about 40 seconds to respond. As far as I understand, PostgreSQL is not a good database for this type of query.
I sat down and came up with several ways so that this type of query could be indexed and executed in O (log n), so I know that t is possible.
What tools should I use for this? Should we use a different database to store the count lines? Is there a package we could install on top of PostgreSQL to make this easy? What are our options?
Note:
Not sure if I were right. The result of COUNT should be on the order of 100,000 - 10,000,000. This means that the number of rows matching the query will be on the order of 100,000 - 10,000,000. The actual number of rows in the table is an order of magnitude greater.
Many thanks!
Chris dutrow
source share