The following query is run by an API. Individually it takes almost no time at all to run because the variables are intentionally limited to a single identifier
and a small window. Here is the query:
SELECT
raw_data->'foo'->0->>'time' as timestamp
FROM dbo.raw_data
WHERE raw_data->'foo'->0->>'number' = '${identifier}'
AND raw_data->'foo'->0->>'time' > '${queryStartDateEpoch}'
AND raw_data->'foo'->0->>'time' < '${queryEndDateEpoch}'
ORDER BY raw_data->'foo'->0->>'time' DESC
LIMIT 1
One query will run for every unique system number my API gets supplied.
I expect this API to run this query anywhere from 40 to 100 times at once. The issue I am seeing is that the first few queries run in moments, but then after that point the performance drops off and I end up waiting 20-30 minutes for all 40+ queries to resolve.
Can anyone explain why PostgreSQL would slow down like that? Thank you.
I did not set up the docker server for the PostgreSQL database and have limited background knowledge about that. I imagine there is a limit to the number of queries you can run, but I am not clear how to identify the bottlenecks.