RECORD() effciency


I’ve got a question about the RECORD function, specifically the idea of adding a column like

= RECORD(rec, expand_refs=1)

as suggested here Prepare Invoices - Grist Help Center

How does this work with respect to data transferred to an embedded custom widget and also potentially over the REST api? I have a table of a large number of rows (many hundreds) each of which references a row in table of far fewer rows (tens of rows) which has quite a few columns and some other references. Both tables are likely to grow in size but remain in the current proportions.

My question is will the data of the smaller table be duplicated many times over in memory when it’s joined to the large table or is it able to use shared object references? Am I heading for a performance problem by using RECORD(rec, expand_refs=1) and would I be better off just fetching each table separately and doing the join in the front-end view as needed?

Apologies if this is just a dumb question I’m really a desktop C++ programmer and I’m new to all this web stuff.


Good question! RECORD returns a plain Python dictionary, not some clever shared object which is sort of what’s there by default. So it absolutely could be a performance problem if those dictionaries are large or there’s many of them.

1 Like

I’ve started to pick this back up this evening. I decided I would try and build a dictionary of the referenced records and manually and lazily resolve and store the referenced row data as I came across them. However I can’t seem to find a call in the plugin api to fetch a single row from a specified (referenced) table which isn’t the selected table for the widget. Am I missing something?