Hi Christian,

On Mon, 8 Apr 2019 at 15:40, Christian Grün <christian.gr...@gmail.com>
wrote:

> 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].
>

Thanks :).


> > 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.


Thanks for providing the examples.


> 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 may just end up outputting the query plan in the XML format that BaseX
provides, like is done in the BaseX GUI.


> > 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).
>

That makes sense.

The MarkLogic profile integration generates results like in
https://plugins.jetbrains.com/files/8612/screenshot_19187.png. It could be
useful to have something similar in BaseX. I would envision that this would
apply the optimization steps first (function call rewriting, constant count
evaluation, index access, etc.) and then profile the resulting query. It
could even be useful in figuring out what queries to rewrite in the BaseX
optimization pass.

>
> Have you already embedded support for the Saxon debugger in IntelliJ?
>

I've had a brief look at them, but nothing in-depth yet. I'm experimenting
with the APIs for integrating debuggers with IntelliJ. I see it can be used
for profiling, so I will investigate using those APIs for profiling Saxon
XPath, XQuery, and XSLT.


> Further questions are welcome. For example, we could think about
> adding dedicated functions to our API for requesting query information
> more elegantly.
>

The current API should be sufficient.

Something that might be interesting/useful is being able to relate the
query plan to the original source. Likewise for the information on applying
indices. That would help when working on more advanced integration, such as
annotating the types that BaseX evaluates variables, expressions, etc. to.

I do have some questions about exceptions. I'm currently using a simple
regex to extract the error information (
https://raw.githubusercontent.com/rhdunn/xquery-intellij-plugin/master/src/plugin-basex/main/uk/co/reecedunn/intellij/plugin/basex/query/session/BaseXQueryError.kt)
so I can standardize the formatting of the errors across the different
vendors and do things like link to the source files.

Q: Is there any documentation on the format that the query errors can take?
Q: How are query errors with function call stacks formatted, including from
other modules?

Kind regards,
Reece


> Christian
>
> [1] http://docs.basex.org/wiki/Integrating_IntelliJ_IDEA
>

Reply via email to