QUERY VS VARIABLE Performance

Hi,
I was watching the tutorial Dynamic collection pages | WeWeb Documentation in order to create my dynamic pages. And I started off with using query, but after watching this video, was wondering, if there is a difference in performance with

  1. Using the variable method, carrying the data to the next page and loading it. (One disadvantage, not possible to save the link for later)

  2. Using a query method adding the data id in the query and then pulling the data in the page via another API call (able to save the link for later)

In one we store the data for the next page in weweb, in the other one we pull the details via API.

I made tests and of course method 1 is faster since it does not need to make an extra API call, but does this make an extra server effort for weweb using 1st scenario?

This is considering a high traffic website. Thank you very much.

Choosing between the 2 methods depends on the use-case.
I would recommend method 2 for all the benefirs you listed. And to optimize it more, when you are displaying your collection list, you should only fetch the data that you need from your database. And then on the detail page, you can fetch your item with everything you need :slight_smile:

1 Like

It’s the same, the variables might take a tiny bit longer, because it’s no-code actions. I had a tad weaker performance with Workflows vs plain JS when changing variables - at high frequencies for example.

  1. Is just an abstraction of the 2. though
1 Like

Thanks @jptrinh, @Broberto , that is what I usually do with XANO, defining the proper endpoints to only bring the data needed. In my particular case, these are APIs where I don’t control the schema of the endpoint. So the initial API call will have the same exact response as the second API call once in the detail page. But the url also needs to be available for later, which makes the query necessary. I will make some tests just out of curiosity. Thanks for the inputs.