Performance hack - Possible to Set one BIG State thing to eliminate many "Search for"s?

Trying out an idea, but unclear if it’s a no-go or I’m just not doing it right.

Goal: Reduce page load time by eliminating "Search for"s.

How: Set one BIG set state that instead of storing a single variable, stores a small view or thing worth of data. I’d then reference this set state thing in the actions on the page where today I’m doing separate "Search for"s to get this same data.

Question: Is it possible to run one “Search for” to set a state thing that I can reference in actions throughout the page?

I’ve given this idea a shot and it seems to sort of work, but I cannot seem to reference individual items in what I’m calling my set state thing.

Here’s the set up:

Set a state that holds multiple columns and rows from my database (eg. 3 tickets including name, price, id)

Then, without needing to do another database search, I use the “event-form” state above as the input and call attempt to store item #1 into a new state.
(eg. store ticket #1, using the above multi-item search result)

I can see that the multi-item search found 3 tickets, say, but I cannot seem to call individual items. Eg. the second set state for ticket item #1 is empty :frowning: The debugger tells me so…

If this worked, I anticipate it would greatly speed up page time because we’d eliminate literally 100s of database searches throughout of app and use set state view things instead.

Have you tested with a text element showing the item’s fields?

I’ve found the debugger not always showing things…

You may find you need less records in different sections, so you can :filter the custom state value.

Good luck!

Not sure I follow. The problem is that I’m not able to reference the individual items within the multi-thing state. Can you clarify your idea. I’ll test it out.

The custom state holds a list of things, resulting from the initial search.

This list can have a :filtered operation applied to it, to apply further criteria and/or sorting.

Also, it might matter at what time you set the values in the custom state, on page load may be too early …

Couldn’t get it to work. The issue may be that the multi-thing state is not a list, it’s a mini-table/view. Cannot seem to reference the rows. Happy to entertain any other ideas.

I just tried it, and also failed at runtime, I had a never-ending progress bar when trying to set the custom state to a search result of things. Weird, I’m sure it used to work.

Edit - it worked fine on a new app, something dodgy going on.

The custom state is happy to hold a list of things if I set it from a RG’s list.

Anyway this approach should work if you use a RG instead of a custom state as the main list of things.

Not sure what you mean here, do you define the custom state as type of thing, then tick the list checkbox?

1 Like

Good idea. Will give it a try and see how much of faster the page could be.

Just to summarize this thread/hack:

Pages which have multiple "Search for"s on the same table might benefit from instead storing the data as a one-pixel repeating group and calling the data from that group. This will reduce the number of hits on the database and thus should speed up the page.

This is very interesting (for a hacker like me :slight_smile: )

Do you think having it “in memory” rather than create a composite “reporting” table on the database will be faster ?

Hi Nigel - What do you mean by composite reporting table? Normalize/Flatten multiple tables into one?

Yes, flattening/denormalising for speed of reading.

Okay. I’ll do a few time trials to test it.

This topic was automatically closed after 70 days. New replies are no longer allowed.