query plan / basex:index usage
Wednesday, 20 October 2010 · 2 messages
FE
Fabrice Etanchaud20 Oct 2010 10:26 #
Dear BaseX Team,
First, could you tell me how I can get only the query plan of a query, without running it ?
Last, is there a way to call, in a same cross db/collection query, basex:index function on each of the dbs/collections ?
Thank you for sharing your wonderful native database.
Best regards,
Fabrice Etanchaud
CG
Christian Grün20 Oct 2010 18:51 #
Dear Fabrice,
Quoted text · Fabrice Etanchaud · 2 lines
> First, could you tell me how I can get only the query plan of a query, > without running it ?
You can modify the "serialize" option to deactive the serialization of your query, using the following database commands:
set serialize off; xquery <your query>
Alternatively, to avoid evaluation for all queries, you need to get one level deeper, using e.g. the following code snippets (didn't test this, but I think it's correct):
// create database context
Context ctx = new Context();
// activate query info
ctx.prop.set(Prop.QUERYINFO, true);
// alternative for activating query info
// new Set("serialize", false).execute(ctx);
// create query processor instance
QueryProcessor qp = new QueryProcessor("your query", ctx);
// compile query
qp.compile();
// close instance
qp.close();
// dump query info
System.out.println(qp.info());
// close database context
ctx.close();Quoted text · Fabrice Etanchaud · 2 lines
> Last, is there a way to call, in a same cross db/collection query, > basex:index function on each of the dbs/collections ?
Yes, that's possible – but (as I just noticed) not in all cases. I've modified our code to support queries of the following kind (please get the latest version from our SVN or wait for basex-6.3.jar, which will be online in a few days):
for $i in 1 to 10
let $n := concat('database', $i)
return doc($n)/basex:index('and', 'text')Christian
Written for BaseX 6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery