Reputation: 2093
Is there a significant difference betweeb the following active record queries in Rails:
User.select('*')
User.all
mainly in terms of load on DB, results and performance?
UPDATE: Based on MrYoshiji's response below the most significant difference is that User.select('*') returns an active record result set whereas User.all returns an array of items. Significant if you require built-in active record methods.
Upvotes: 0
Views: 292
Reputation: 4888
There is no difference. The generated SQL query would be almost the same.
In Postgres, using User.select('*')
you would get a query with SELECT * FROM users
.
Using User.all
you would get a query with SELECT users.* FROM users
.
Don't know exactly what would happen in MySQL, but I guess it's the same.
Upvotes: 1