You are currently viewing the new Anvil Editor Docs.
Switch to the Classic Editor Docs main page
You are currently viewing the Classic Editor Docs.
Switch to the new Anvil Editor Docs

Accelerated Tables

In May 2022, Anvil announced a beta release of Accelerated Tables. This is a new back-end architecture for Data Tables, bringing increased speed, scalability and flexibility. The Data Tables API does not change, but as this is a major change we are rolling this out slowly. Accelerated Tables is currently an opt-in beta program.

Enabling the Accelerated Tables Beta

Accelerated Tables can only be enabled from the Beta Editor.

In order to enable Accelerated Tables for your app, open Settings, then choose Data Tables, then check the Accelerated Tables option. You do not need to change your app’s code.

Click here to enable Accelerated Tables

Click here to enable Accelerated Tables

Testing safely

The switch to enable Accelerated Tables is stored as a configuration option in your app’s source code. This means that if you have published a version of your app, you can safely experiment with the development version of your application without affecting production users.

Data written using Accelerated Tables can be read by the original Data Tables implementation, and vice versa, so it is safe to switch this option on and off.

New Features

Accelerated Tables improves speed for most access to your Data Tables. It also gives you extra benefits and control over:

Linked rows

Loading linked rows is significantly faster when using Accelerated Tables, particularly “Link to Multiple” rows. If you have previously avoided data architectures with these links, now might be the time to try them again.

Column-restricted views

With Accelerated Tables, you can control which columns are accessible from a view, by passing q.only_cols(). For example, the following code will return a view of the users table that contains only the email and enabled columns:

@anvil.server.callable
def get_users():
    return app_tables.users.client_readable(q.only_cols("email", "enabled"))

Explicit cache control

With Accelerated Tables, you can control which columns are loaded from a table search, using the new fetch_only search modifier.

For example, if you are querying the users table, but only need the values of the "email" and "enabled" columns, you can write:

from anvil.tables import query as q

rows = app_tables.users.search(q.fetch_only("email", "enabled"))

This will speed up the query, by only fetching the data you need. It is possible to access other columns in rows returned from this search, but it requires a round-trip to fetch that data from the database.

You can also control what data is fetched from linked rows, by using nested fetch_only specifications. For example, if your users table had a link column called group, and you only want the "name" column from those columns, you can write:

rows = app_tables.users.search(q.fetch_only("email", group=q.fetch_only("name")))

Feedback

All code that works with Data Tables should work with Accelerated Tables, please post in the Anvil forum with a description of the issue.


Do you still have questions?

Our Community Forum is full of helpful information and Anvil experts.