Accelerated Tables will load all linked rows

I am not sure if this is a bug or just how things are supposed to be. But Accelerated Tables load all linked rows completely (including simple objects) when trying to get a row. My app deals with large simple object columns so enabling Accelerated Tables made the speed go worse instead.

I managed to replicate this behavior in a separate app which has a simple object column in ‘table 2’ containing a large list. There is another ‘table 1’ which has a column linked to table 2

https://anvil.works/build#clone:65Y55SNNHQLQCVE2=3WQJFZ6W5LQREZQHG64IQPGK

Here is how the app behaves when :

Getting row from table 1 without using Accelerated Tables

The row loads fairly quickly. But then there is an additional time when trying to access the simple object column from linked table 2 row

Getting row from table 2 with Accelerated Tables

The row takes much more time to load. But after that, there is no additional time when trying to access the simple object column.

Just in case this was confusing, the clone link has everything set up so you just have to run the app after toggling accelerated tables to see the results.

In the Accelerated Tables beta, the default is to fetch everything since there is now an API for granular control over partial fetches.

You’ll need to define a fetch_only spec in order to fetch just what you want.

If you have columns: foo, bar, baz and baz is your large simple object column you should do

import anvil.tables.query as q
from anvill.tables import app_tables

app_tables.my_table.search(q.fetch_only("foo", "bar"))

See the announcement for some more details:

I am already aware of it.

But what if I want to get only some columns from the linked row? I cannot use the fetch_only method for that since it only works on get and search methods

If you have a linked row column then you can still use fetch_only


rows = app_tables.my_table.search(q.fetch_only(linked_row=q.fetch_only("name")))

This will fetch just the linked_row column from my_table and only the name column from those linked rows.
(you can also do linked_row=q.fetch_only() to get a reference to the linked row, without fetching any of its data)

Though, I might have misinterpreted your use case.

4 Likes

No this is just what I needed! The ability to get data from Linked Rows while avoiding some large columns.

Also, does this also work on multiple rows?

Yes it will work the same for a single linked row or multiple linked rows

1 Like

Thanks for the help :grinning:

Now I can finally start using Accelerated Tables properly

1 Like