We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Lailson Bandeira • 4 years ago

On this very same topic, I also recommend: https://goiabada.blog/to-jo...

disqussucks • 4 years ago

" If we have 1000 builds, we'll need to connect to the database 1001 times. Remote database connections are not free, and each connection introduces a heavy performance penalty."

That's not true. Rails uses a connection pool, and in the same process all queries will use the same connection. The performance penalty is coming from doing multiple queries instead of one.

Igor Sarcevic • 4 years ago

You are correct, saying 'connecting' is not the right choice of words.

Yug Shende • 4 years ago

Is this the case even with latest builds of Rails 5? I think I read/heard a specific Rails community person say the're trying to do away with N+1. Or I am guessing .includes(:branches) IS the solution that they've baked in.

Igor Sarcevic • 4 years ago

Good question. We'll need to look into the latest Rails 5.x release.

But my best guess is that this is not possible to resolve completely. Using includes every time has the opposite risk of loading too much data.

Bibin Venugopal • 3 years ago

True loading too much data will end up more RAM consumption.

Plus how do they do a eager loading in first query? How do they know that the data going to end up in a N+1 situation in later code?