Best practice to determine if query was executed

If there are multiple interlocking table components, an error may occur when the web page is initially displayed depending on the execution timing and speed of the queries set in the tables.

I'm building my own JS and handling errors, but I'd like to know the best practice to do the following in consideration of future development stability.

  1. How to determine if a query has been executed
  2. How to determine if a query results in more than one record

@jhoshito This is a very broad question without a lot of context - if you can provide more details, I am sure the forum will provide a lot of ways to achieve what you are looking for.