You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gorm gives the ability to enable query optimization in a couple of different ways.
When we consider that running a typical Gorm query might look something like this;
// Get the first record ordered by primary key
db.First(&user)
// SELECT * FROM users ORDER BY id LIMIT 1;
What's going on under the hood might be a full table pull, e.g., that * means, "grab the whole table," which increases I/O. This may not matter when the database is small. But if we're talking about having a million bets on a platform (e.g. you have 1000 users making 3 or 4 bets per day on average, so 100 bets per month, for a year, you would have 1.2 million bets), then pulling the whole table becomes horribly intensive.
However, index hints might be a way to just search a single index for something, rather than the entire table.
Gorm gives the ability to enable query optimization in a couple of different ways.
When we consider that running a typical Gorm query might look something like this;
What's going on under the hood might be a full table pull, e.g., that
*
means, "grab the whole table," which increases I/O. This may not matter when the database is small. But if we're talking about having a million bets on a platform (e.g. you have 1000 users making 3 or 4 bets per day on average, so 100 bets per month, for a year, you would have 1.2 million bets), then pulling the whole table becomes horribly intensive.However, index hints might be a way to just search a single index for something, rather than the entire table.
https://gorm.io/docs/advanced_query.html#Index-Hints
The text was updated successfully, but these errors were encountered: