Server-Side Actions: What happens when an input is a Search?

This may be an “obvious” question, but I’m just trying to confirm observed behavior here… Let us say that we have a server-side action that takes several LISTS of things as inputs. For example, we might have Data Source 1 and Data Source 2, both specified as lists of some app type.

This server-side action will allow the Bubble programmer to specify the sources for both of these lists as searches, e.g., Data Source 1 is “Do a Search for Foos, with no constraints” and Data Source 2 is "Do a Search for Foos, with constraint field Bar (a boolean) is “yes”.

When used in an on-page workflow, the following seems to be true:

  1. The presence of these Searches in the inputs of the plug-in does not cause those searches to be run in the page.

  2. When that workflow (however it may be triggered) is triggered, those Searches are not executed in the page. (And, thus, no data of type Foo is downloaded to the browser – which is good.)

  3. It would seem that the Searches specified as inputs to Data Source 1 and Data Source 2 are only executed on the server… But when?

Now, what I’m wondering is the following:

  1. Are both searches always executed as part of instantiating the code for the server-side action?

  2. Since the results of these searches become properties.data_source_1 and properties.data_source_2, does that imply that both searches are conducted before the plug_in code for run_server begins running?

  3. … OR is there an optimization here such that the searches are only conducted if the executed code requires evaluation of either properties.data_source_1 or properties.data_source_2?

… Let us say that the code does some calculation and – depending upon the results of that calculation – conditionally branches in such a way that only one of properties.data_source_1 OR properties.data_source_2 is ever evaluated.

In that case, is the “other” search never executed? Or were both executed on our way into run_server?

@marca? Anybody done any mad science experiments to examine this?

The searches—getting whatever data you specified in the arguments of your function—happen on the server before invocation of the server side action function itself. The results are not loaded by the browser, but the database queries themselves take a nontrivial amount of time, especially if they are large.