Topic: Query Performance
I come from a background of writing my own DB queries for web applications, and I'm still not entirely comfortable with Rails doing SELECT * on everything.
A couple questions:
* If I know in advance that I will only be using a specific column or two from a model, is there a find() syntax that allows that without resorting to custom SQL? I'd also be curious to know if there's a way to grab just one column from a second table through eager loading. Or will a model freak out if it is only partially populated with data?
* MySQL caches queries. So if two of the same query are submitted in a short time, the second query result will come out of the cache. Has anyone done any testing/experimentation to see if a complicated join query created by eager loading is really faster than multiple simple queries without eager loading? Eager loading could be faster for the first query, but might not be advantageous if other pages would execute the same simple queries, but a completely different eager loading-style query.
I was thinking it would be cool if Rails had some sort of built-in optimizer which would examine controller/model/view code to see which data columns are being used and only query the DB for those columns.
I'm just thinking out loud. My Rails app is too new for me to worry about much optimization, but I'm starting to look where I might be hitting the DB too hard.