Timeout issue: Your question took too long

I'm getting this error for some queries. However, when I run the same query with an sql client, I don't face this issue. How can I solve this? We have installed metabase on docker using caprover.

Typically this error is caused by a proxy or some other network configuration between Metabase and the database server. This thread is probably a good starting point: How to increase query timeout - Your question took too long

Typically, though not always, we've configured timeout settings quite high at both the Metabase and load balancer levels. However, we still encounter this issue intermittently. It seems to be related to something else as well.

With PostgreSQL, adding LIMIT to a query can change the query plan and thus the execution time. I assume it rearranges the query so it can apply the LIMIT.

I should have saved it, but at one point one of my dashboards had a query that would time out, but the same query run in psql without the LIMIT clause would complete in under a second. The query returned like 13 rows.

Metabase adds LIMIT on queries even if no limit is specified.