A user reports that their Discourse installation loads slowly due to a remote database, with the homepage taking 2-4 seconds to respond. The issue stems from the layout component executing over 60 SQL queries, each taking around 30ms to transfer, causing significant delays. Switching to a local database resolves the problem. Other users confirm similar performance issues with external databases, suggesting latency or setup problems. One user notes that the slow SQL response times are unusually high compared to standard benchmarks. A key observation is that the server appears to be running in development mode, which may contribute to the performance issues. The discussion highlights concerns about database location, query efficiency, and potential differences in indexing between local and remote setups.
Started GET "/" for 219.144.218.209 at 2025-03-17 18:22:55 +0000
Processing by ListController#latest as HTML
Rendered layout layouts/application.html.erb (Duration: 1932.6ms | GC: 10.6ms)
Completed 200 OK in 2521ms (Views: 1933.4ms | ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 14.9ms)
My server has 2 CPU cores and 8GB of RAM.
The log shows layouts/application.html.erb rendered so slow.
I removed some content in layouts/application.html.erb and it take up to 300-500ms to respond.
I’m having a similar problem.
I think the docker might be doing some kind of magic indexing on internal databases only, which isn’t great as that severely limits how we can scale.
Hmmm … that doesn’t sound right to me. The same migrations should be being applied regardless of where the database is … and that includes the addition of indexes.
It would be good to demonstrate the difference if you can get a query plan on both instances for the same query that is taking much longer on the external instance.
(appreciate that might be a pain for you to gather)
If the query plan is identical, then it surely must be latency or performance of the external database that is at fault?