When using Activerecod for database operations, two SQL statements will be executed to get the data if the associated query for two tables is involved. One gets the data for the primary table, and the other gets the data for the associated table.
So what are the pros and cons of doing a SQL fetch with a direct two-table association in this way?
Reply content:
When using Activerecod for database operations, two SQL statements will be executed to get the data if the associated query for two tables is involved. One gets the data for the primary table, and the other gets the data for the associated table.
So what are the pros and cons of doing a SQL fetch with a direct two-table association in this way?
This situation generally has a form
-
Lazy loading, many frameworks will be lazy loading, only when the associated object is really used, only to query the data, this situation is readable replacement, performance is optimized, this case is two sets of SQL statements
-
Craving load, using an associated query to query the associated data, note that this is actually an SQL statement