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
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
See the announcement for some more details:
Do you want:
Faster searching of Data Tables?
More predictable performance?
Fewer round-trips to the server when displaying linked rows?
Control over which columns to fetch from which tables?
Good news – we have just completed a full rewrite of the Data Tables back-end, bringing all of these and more, and we’re launching it as a beta today. This does not change the existing Data Tables API – it will just make your apps faster and smoother! (We’ve also added some extra functionality, …
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
If you have a linked row column then you can still use
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.
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
Thanks for the help
Now I can finally start using Accelerated Tables properly