PostgreSQL sending wrong queries responses

时间:2019-01-15 18:16:27

标签: sql node.js postgresql

I have a frontend that keep sending a request to a backend several time per seconds. For the most time it works OK.

But for some reason that I didn't understand Postgres keeps sending queries with a wrong order

Example: I use the same query to retrieve information about 3 different clients, information like users.

I have a table that contains the Users information and one of the info it's the client from what this user came I've create a dashboard to keep track in real time the total users by clients

But sometimes the info from Client A appears on client B, Client C on Client A, Client C on B and the only thing that I do is a select changing the WHERE client = "A" or B or C

So my dashboard keeps flickering, alternating with the right data and wrong ones

My backend is NodeJS with Express that communicates with my Postgres server

Update: The query that I'm using

SELECT COUNT(*) 
FROM trackers 
WHERE "client" = '${Client}'

Update 2: I'm using a pool of connections in my backend, once the back is sent to the front the backend closes the connection.

Maybe because I'm sending too many requests from the same place the pool is mixing the responses

I'm using the NPM pg package

0 个答案:

没有答案