Repeating Panels loading Slowly

Rule number one to speed up a form is to make sure you only have one round trip when the form appears and one round trip per user action.

Unfortunately Anvil doesn’t tell you when round trips happen, I would love to see them all, but for now you will need to use your imagination.

Your form starts with two server calls:

  def __init__(self, **properties):
    [...]
    self.caseContent.items = anvil.server.call('get_active_cases')
    [...]
    self.leadParaInput.items = anvil.server.call('getParalegals')

You can make it faster by creating one server function that returns a dictionary with two lists of items, then make one server call only:

  def __init__(self, **properties):
    [...]
    all_items = anvil.server.call('get_active_cases_and_paralegals')
    self.caseContent.items = all_items['active_cases']
    [...]
    self.leadParaInput.items = all_items['paralegals']

You may also have unintentional round trips triggered by the row objects. Some column types are loaded lazily, that is, rather than being sent to the client when the server function is called, they are fetched the first time they are accessed. So when the forms in the repeating panel are rendered, they may trigger a bunch of round trips.

You can manage this by enabling accelerated tables and using fetch_only to fine tune what’s sent to the client immediately because you know you will need it, and what shouldn’t be sent because you know you will not need it.

1 Like