Often, a model (table) needs to be queried to see if it’s empty or not. The fastest way to achieve this is …
1 2 3 4 5 |
|
Use this method instead of User.all().count() when testing if any of a specific model exists. This should have better performance in cases where there are lots of the model (e.g. 1000+ Users) since count still needs to access each model in order to count it.