How 'expensive' are DB queries? for example

my opening page has a function that counts all ‘eye doctors’ in each
town ( there are about 20 towns) and displays that number next to the
town name in the view. therefore that is about 20 queries on the given

i was just wondering how expensive is this operation and should i be
finding an alternative?
especially if that town number is increased to lets say 40-60?


if you use eager loading (with :has_many associations) you can reduce
20 or so queries to 1.

Heri R.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs