Avoid ORM querys at Global Scope

Because …
(1) The query runs every time the application comes up
Elastic applications that scale with load, result in an unnecessary DB hits when new instances are added. The effect is multiplicative for each process of your application per pod or container.
(2) The connection associated with instance will be closed
More importantly, using this long lived, stale ORM object will result in an server has gone away error on usage. The default setting CONN_MAX_AGE is 0 where:
0closes connection / request;Nonepersistent connection;0< keep alive in seconds;
Move the query into the respective view or method. You could cache the object too.




