Very slow database performance

Thanks @p.colbert

The approach makes a lot of sense. I have tried a few things but the performance has not improved much. Below the current timings. Looking at it real time, it feels like the time from when the server sends data to client receiving data is where the lag is.

calling server function) 2020-09-24 10:13:14.802595
Server function starts) 2020-09-24 06:13:16.809160
Server function ends) 2020-09-24 06:13:16.933067
received data) 2020-09-24 10:13:16.763920

On the server side below is the only code. I am not sure if there is anymore saving to be done with reduction of “import” statements.

import anvil.users
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
import anvil.server
import datetime

@anvil.server.callable 
def get_joblist():
  user = anvil.users.get_user()
  if not user:
    return []
  
  print('Server function in) '+str(datetime.datetime.now()))
  
  jobs = app_tables.jobhistorymaster.search(tables.order_by("jobDate",ascending=False))
  
  print('Server function out) '+str(datetime.datetime.now()))  
  return jobs

As others have suggested i might have to look at returning a better data structure from the server? What would be the best way?

Regards
Rajesh