Use of attribute index
Thursday, 30 January 2014 · 3 messages · last reply 31 Jan 2014
RS
Robert schlichtner30 Jan 2014 15:25 #
Hello,
I found that a number of similar queries have quite different performance:
xquery doc('mcev_temp_5/20140130_11_55_40.xml')//column[@name='KLV_m1_rdr']/v takes only 0.68ms, which is great.
But xquery doc('mcev_temp_5/20140130_11_55_40.xml')//column[@name='KLV_m1_rdr']/v[1] takes 1479.81ms.
If I change this to the equivalent (for my data) xquery (doc('mcev_temp_5/20140130_11_55_40.xml')//column[@name='KLV_m1_rdr'])/v[1] it runs fast again (0.53ms)
Checking the query execution plan I found that only query 1 and 3 utilize the attribute index.
I find this rather surprising, and I would like to ask if there is some general reason/rule why the second can not use the index, so I can avoid such 'bad' queries in the future.
Thanks!
(I am using BaseX 7.7.2 on Windows XP.)
Regards,
Robert
CG
Christian Grün30 Jan 2014 21:54 #
Hi Robert,
thanks for your precise observations. I agree that the second query should have been optimized as well, and is now rewritten in the latest snapshot [1] (the optimizer was bold enough to reject all path expressions that contained any positional predicates).
Hope this helps,
Christian
[1] http://files.basex.org/releases/latest/
Quoted text · Robert schlichtner · 38 lines
On Thu, Jan 30, 2014 at 3:25 PM, Robert schlichtner <r_schlichtner at hotmail.com> wrote: > Hello, > > I found that a number of similar queries have quite different performance: > > xquery > doc('mcev_temp_5/20140130_11_55_40.xml')//column[@name='KLV_m1_rdr']/v takes > only 0.68ms, which is great. > > But xquery > doc('mcev_temp_5/20140130_11_55_40.xml')//column[@name='KLV_m1_rdr']/v[1] > takes 1479.81ms. > > If I change this to the equivalent (for my data) xquery > (doc('mcev_temp_5/20140130_11_55_40.xml')//column[@name='KLV_m1_rdr'])/v[1] > it runs fast again (0.53ms) > > Checking the query execution plan I found that only query 1 and 3 utilize > the attribute index. > > I find this rather surprising, and I would like to ask if there is some > general reason/rule why the second can not use the index, so I can avoid > such 'bad' queries in the future. > > Thanks! > > (I am using BaseX 7.7.2 on Windows XP.) > > Regards, > > Robert > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
RS
Robert schlichtner31 Jan 2014 11:18 #
Thank you for your quick response, with the snapshot everything works perfectly.
Regards,
Robert
Quoted text · Christian Grün · 58 lines
> From: christian.gruen at gmail.com > Date: Thu, 30 Jan 2014 21:54:06 +0100 > Subject: Re: [basex-talk] Use of attribute index > To: r_schlichtner at hotmail.com > CC: basex-talk at mailman.uni-konstanz.de > > Hi Robert, > > thanks for your precise observations. I agree that the second query > should have been optimized as well, and is now rewritten in the latest > snapshot [1] (the optimizer was bold enough to reject all path > expressions that contained any positional predicates). > > Hope this helps, > Christian > > [1] http://files.basex.org/releases/latest/ > > > > On Thu, Jan 30, 2014 at 3:25 PM, Robert schlichtner > <r_schlichtner at hotmail.com> wrote: > > Hello, > > > > I found that a number of similar queries have quite different performance: > > > > xquery > > doc('mcev_temp_5/20140130_11_55_40.xml')//column[@name='KLV_m1_rdr']/v takes > > only 0.68ms, which is great. > > > > But xquery > > doc('mcev_temp_5/20140130_11_55_40.xml')//column[@name='KLV_m1_rdr']/v[1] > > takes 1479.81ms. > > > > If I change this to the equivalent (for my data) xquery > > (doc('mcev_temp_5/20140130_11_55_40.xml')//column[@name='KLV_m1_rdr'])/v[1] > > it runs fast again (0.53ms) > > > > Checking the query execution plan I found that only query 1 and 3 utilize > > the attribute index. > > > > I find this rather surprising, and I would like to ask if there is some > > general reason/rule why the second can not use the index, so I can avoid > > such 'bad' queries in the future. > > > > Thanks! > > > > (I am using BaseX 7.7.2 on Windows XP.) > > > > Regards, > > > > Robert > > > > _______________________________________________ > > BaseX-Talk mailing list > > BaseX-Talk at mailman.uni-konstanz.de > > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
Written for BaseX 7.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery