I came from non-computer-science background and Now I am working as a Ruby on rails developer who using active_record to fetch values from database.While I reading rails scalability issues, many places I found 'N query' 'N + 1 queries' 'N log N' which I am not familiar with.I want you people to help me by explaining what all these and where I could get a nice blog or website which explaining all these terms.
I came from non-computer-science background and Now I am working as a Ruby on
Share
There are 2 separate things here:
The term N + 1 queries refers to a very specific issue. Assume that you have your standard blogging example app, with Post and Author as models. I might choose to collect all the names of the authors who have actually written something:
names = Post.all.collect { |post| post.author.name}
This triggers one extra SQL query for each post, so if you had N posts then you’d end up doing N+1 queries. All those extra ones would be very fast query but the overhead/latency adds up quickly so it can slow stuff right down
The Rails active record guide explains this and the mitigations rails makes available.