Skip to main content
December 17, 2025
Question

returning unexpected error while querying DB table

  • December 17, 2025
  • 8 replies
  • 0 views

I am using a!queryEntity() to query a DB table where I am only using 2 filters to fetch the results. I am also using pagination for it. Also, this issue is not occurring for all the records. It just occurs intermittently and it also resolves the moment we try to re query using same data. does anyone knows what could be the reason for it?

This is the complete error: An error occurred while evaluating expression: XXXXX (Expression evaluation error in rule XXXX at function a!queryEntity [line 4]: An error occurred while retrieving the data. Details: Unexpected error executing query

I doubt if the batch i set might be causing it? I have set the batch size to -1? Does it have any impact in query performance?

    8 replies

    shubhama926776
    December 17, 2025

    BatchSize: -1 is causing it. It fetches unlimited records causing intermittent timeouts/resource issues.
    Set reasonable batch size like batchSize: 1000 -> pagination will handle the rest.

    harshas2775
    December 17, 2025

    When querying data you should always query in batch rather than using -1. Sometimes when memory/server load is high the query can fail as resources are deficient.  Alter your design to query data in batches, that should resolve this.

    stefanhelzle0001
    December 17, 2025

    -1 as batch size means to fetch ALL rows. Depending on the data volume in your table this leads to a timeout or memory issues. Just do not do that.

    January 5, 2026

    Thanks for the response. I have updated the batch size. Also, I would like to update the process model a bit by checking if the script task node that uses a!queryEntity() logic is unattended, then i am aiming to set a second flow with timer which should still continue even if the existing flow errors. If the existing flow errors for some other reason, then the timer flow checks if the first flow managed to get past the DB query node and try again. But I am unable to update the configuration of existing script task node to execute the alternative timer flow if its unattended. Can i get some suggestions around this as well please?

    stefanhelzle0001
    January 6, 2026
    But I am unable to update the configuration of existing script task node to execute the alternative timer flow if its unattended.

    Please explain in more detail what you mean by that.

    The pattern you describe is dangerous as it looks like a save way to handle this scenario, but in the end will result in increased support effort when your queries become slower with a growing data volume.

    January 6, 2026

    Sorry for the confusion. Let me make it clear. I have a process model with start node followed by Script node. The script node has the logic of querying the DB via a!queryEntity() using an expression rule. Currently, if the query errors then the script node is errored and the process does not move forward. The workaround we are doing is to restart the script node. Now that I have updated the batch size, we might catch the query error but I also want to address the issue 100%. I want to create an alternate flow using a timer option that executes even if the script node is errored for some reason. Basically all i want to achieve in alternate flow is to check if the query is executed successfully? If yes, the flow proceeds further, otherwise it will again use the same query logic to fetch the results. This is just to handle manual workarounds.