I would love your help to understand and improve this unexpected long query

Hey folks!

I am currently using Strapi V3 and are struggling with this two specific queries shown by my Postgres statistics:

select distinct "articles".* from "articles" where
("articles" "published_at" is not null) and "articles" "project" in ($1)


select distinct "articles".* from "articles" left join
"defaultdb". "public" "projects" as "projects_1" on
"projects_1" "id" = "articles"."project" where
"projects_1" "id" = $1 limit $2

It seems to also cause Unhandled rejection TimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call? and sometimes even server restarts because of that.

As you can see the average and max query duration is extremely high. My problem is that I am having a hard time understanding which exact query is causing this in my Strapi backend code. I already created an index for ‘project’ (a foreign key) for the articles table (16K rows) but it doesn’t seem to help that much.

Can anyone point me to what this query could potentially refer to? What could the $1 and $2 be in this case?

Basically the only query that can come in my mind is this one where the parameter $1 could be the _limit but I am not sure. This would explain the second shorter query above but not the first one with the extremely long mean and max time.

Would appreciate your help!