Great question, yes if you anticipate the statuses table containing lots of rows then some optimisation of the query will be beneficial. The same issue applies wherever the N+1 problem occurs, as even when using $model->with() or $model->load() if the tables being eager loaded have lots of rows or columns this could also lead to performance issues.
Your suggestion is a good one, an alternative approach might be to cache statuses and then refresh the cache whenever the statuses are changed, it all depends upon the table size and the use cases.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Would it be a problem if statuses table contains huge amount of records?
In this solution all statuses are selected each time we need to validate input.
It may be better to limit statuses query result with ids from request.
Great question, yes if you anticipate the statuses table containing lots of rows then some optimisation of the query will be beneficial. The same issue applies wherever the N+1 problem occurs, as even when using
$model->with()
or$model->load()
if the tables being eager loaded have lots of rows or columns this could also lead to performance issues.Your suggestion is a good one, an alternative approach might be to cache statuses and then refresh the cache whenever the statuses are changed, it all depends upon the table size and the use cases.