Hitting index for multi-db query

Friday, 2 October 2015 · 4 messages · last reply 11 Oct 2015
ML
Marco Lettere2 Oct 2015 23:55 #
Hello all, I have to query all the databases on one server for docs matching a query. I do it with this query for example:
db:list() ! db: open(.)/entry[@about='abc']
This query never hits the available attribute index. I could rewrite the query to something like
db:list() ! attribute(., 'abc', 'about')/..
and in this case it takes advantage of the index of course. The problem is that I have to implement more queries which have much more generic predicate structures where I probably won't be able to use indexes explicitly. Is there any possibility to rewrite this query in order to use the indexes implicitly? Thanks, Marco.
CG
Christian Grün3 Oct 2015 10:27 #
Hi Marco Sorry, not at the moment. To trigger our index optimizations, the addressed database must be opened at compile time. Maybe we could introduce pragma expressions or a new global option that enforces index access whenever possible, but it's getting tricky as soon as a query may be optimizable in different ways (an example /a[@b = 'c']/d[text() ='e']). I'll have some more thoughts. If you have some suggestions on how a good extension could look like, your feedback is welcome! Christian
Quoted text · Marco Lettere · 31 lines
On Fri, Oct 2, 2015 at 11:55 PM, Marco Lettere <marco.lettere at dedalus.eu> wrote: > Hello all, > > I have to query all the databases on one server for docs matching a query. > > I do it with this query for example: > > > db:list() ! db: open(.)/entry[@about='abc'] > > > This query never hits the available attribute index. > > I could rewrite the query to something like > > > db:list() ! attribute(., 'abc', 'about')/.. > > > and in this case it takes advantage of the index of course. > > The problem is that I have to implement more queries which have much more > generic predicate structures where I probably won't be able to use indexes > explicitly. > > Is there any possibility to rewrite this query in order to use the indexes > implicitly? > > Thanks, > > Marco.
ML
Marco Lettere3 Oct 2015 17:24 #
Thanks Christian, It's a bit of a tricky situation since I was splitting my data into multiple databases in order to exploit the advantages of this pattern. Would I possibly solve the issue by importing an .xqm file that I generate offline with all the database names? Maybe one could think of recognizing somehow that a query wants to query ALL the available databases and this should be equivalent of knowing the database names at compile time. Don't have any other clue ... Bye, M.
Quoted text · Christian Grün · 46 lines
From: Christian Grün <christian.gruen at gmail.com> Sent: Saturday, October 3, 2015 10:27 AM To: Marco Lettere Cc: BaseX Subject: Re: [basex-talk] Hitting index for multi-db query Hi Marco Sorry, not at the moment. To trigger our index optimizations, the addressed database must be opened at compile time. Maybe we could introduce pragma expressions or a new global option that enforces index access whenever possible, but it's getting tricky as soon as a query may be optimizable in different ways (an example /a[@b = 'c']/d[text() ='e']). I'll have some more thoughts. If you have some suggestions on how a good extension could look like, your feedback is welcome! Christian On Fri, Oct 2, 2015 at 11:55 PM, Marco Lettere <marco.lettere at dedalus.eu> wrote: > Hello all, > > I have to query all the databases on one server for docs matching a query. > > I do it with this query for example: > > > db:list() ! db: open(.)/entry[@about='abc'] > > > This query never hits the available attribute index. > > I could rewrite the query to something like > > > db:list() ! attribute(., 'abc', 'about')/.. > > > and in this case it takes advantage of the index of course. > > The problem is that I have to implement more queries which have much more > generic predicate structures where I probably won't be able to use indexes > explicitly. > > Is there any possibility to rewrite this query in order to use the indexes > implicitly? > > Thanks, > > Marco.
CG
Christian Grün11 Oct 2015 13:27 #
Hi Marco,
Quoted text · Marco Lettere · 1 line
> Would I possibly solve the issue by importing an .xqm file that I generate offline with all the database names?
Yes, that's surely an option. One more solution is to use xquery:eval for each database. Hope this helps, Christian
Quoted text · Marco Lettere · 57 lines
> Maybe one could think of recognizing somehow that a query wants to query ALL the available databases and this should be equivalent of knowing the database names at compile time. > Don't have any other clue ... > Bye, M. > > ________________________________________ > From: Christian Grün <christian.gruen at gmail.com> > Sent: Saturday, October 3, 2015 10:27 AM > To: Marco Lettere > Cc: BaseX > Subject: Re: [basex-talk] Hitting index for multi-db query > > Hi Marco > > Sorry, not at the moment. To trigger our index optimizations, the > addressed database must be opened at compile time. > > Maybe we could introduce pragma expressions or a new global option > that enforces index access whenever possible, but it's getting tricky > as soon as a query may be optimizable in different ways (an example > /a[@b = 'c']/d[text() ='e']). I'll have some more thoughts. If you > have some suggestions on how a good extension could look like, your > feedback is welcome! > > Christian > > > On Fri, Oct 2, 2015 at 11:55 PM, Marco Lettere <marco.lettere at dedalus.eu> wrote: >> Hello all, >> >> I have to query all the databases on one server for docs matching a query. >> >> I do it with this query for example: >> >> >> db:list() ! db: open(.)/entry[@about='abc'] >> >> >> This query never hits the available attribute index. >> >> I could rewrite the query to something like >> >> >> db:list() ! attribute(., 'abc', 'about')/.. >> >> >> and in this case it takes advantage of the index of course. >> >> The problem is that I have to implement more queries which have much more >> generic predicate structures where I probably won't be able to use indexes >> explicitly. >> >> Is there any possibility to rewrite this query in order to use the indexes >> implicitly? >> >> Thanks, >> >> Marco.

⚡Generated with XQuery