Hi Reece,
First of all, thanks for your marvellous and always up-to-date XQuery/BaseX plugin for IntelliJ. We have included it in our Wiki just recently [1].
I could display the timings, like in the BaseX GUI. Is there a way to get this information using the org.basex.api.client interfaces? Is there a way to get the query plan, pre-evaluation mapping, and optimized query for the given query?
I have attached a little Java example (QueryInfoExample.java) that uses the session API (the API can be used locally or with a running server instance). It demonstrates how the GUI timings can be requested via the client interface. The second code snippet (QueryPlanExample.java) goes one level deeper; it illustrates how the internal query plan can be accessed. While the format of the query plan has been modified in the past quite frequently, the structure of the textual output hasn’t changed for a longer time now, so it may be safer to work with the output of the first example.
I'm wondering how you would go about profiling a query in BaseX to determine how long various query statements take, so you can look at the places where you need to modify the query to be faster. I have added MarkLogic's profiling support into my XQuery plugin that does this and am wondering how this can be done in BaseX.
The current version of BaseX has no built-in features for debugging and profiling code in a programmatical way. We had developed some prototypical code in the past; so far, it hasn’t been included in the official version due to performance concerns, and the fact that profiled code cannot be rewritten that aggressively (profiled code will often yield other timings than fully optimized code).
Have you already embedded support for the Saxon debugger in IntelliJ?
Further questions are welcome. For example, we could think about adding dedicated functions to our API for requesting query information more elegantly.
Christian