3 ms·
I think that a very few share of Rails programmers need to know the innards of ActiveRecord - I use and abuse it heavily, and never felt that need. When things
by danmaz74 9y ago
I think that a very few share of Rails programmers need to know the innards of ActiveRecord - I use and abuse it heavily, and never felt that need. When things get difficult to optimize, I fall back to hand-written SQL. I spent a thousand times more time studying the innards of PostgreSQL than AR :)
- mercer 9y agoFair enough :). I'm a bit of a control freak, so this lack of insight into the innards makes me (quite possibly unreasonable) uncomfortable. That said, could you perhaps elaborate on how studying the innards of PostgreSQL is relevant in relation to ActiveRecord?
- ryanbrunner 9y agoI think the point is, Active Record (like any orm) is a leaky abstraction that covers a small, but common percentage of what you can do with SQL. Any time I've run into problems fighting the "magic" of Active Record, my time was almost always better spent just taking back to hand written SQL (which isn't terrifically difficult with Rails). Rails absolutely is a framework where you need to abandon some control and trust the framework though. If you need to know exactly how your abstractions work under the hood, it's a poor choice IMO. I doubt there a single person who has comprehensive knowledge of how every single part of Rails works.
- rapind 9y agoCouldn't agree more. Invest a bit of your time gradually learning more SQL and your life will be easier no matter the backend / ORM. SQL is really not going away anytime soon (it's demise has been falsely predicted many many times). It even fits the current language hype in that it's functional!
- danmaz74 9y agoYou nailed it :) I love AR, but there are use cases where you just need to create or optimize your queries manually.
- danmaz74 9y ago> I'm a bit of a control freak, so this lack of insight into the innards makes me (quite possibly unreasonable) uncomfortable Ok, that could be the reason why you don't like Rails :) Regarding postgres, its innards become relevant when you have partitioned tables with billions of rows and need to run queries on them for analytics purposes. In these cases you often need to manually create some complex queries from scratch; other times, you can use ActiveRecord "magic" up to a point, but then you either need to add special indexes (eg partial indexes, that saved my ass many times), or you need to replace the automatically-generated queries that ActiveRecord uses and which are good for small numbers, but become a bottleneck when scaling.