Hi Serdar (cc to the list),
Your query amounts to more than thousands of index requests, and this eventually makes the query faster than when being executed sequentially.
You can enforce sequential execution for the last for clause by using "eq" instead of "=". Next, you should factor out the content id path; otherwise, it will be evaluated thousands of times as well. The following query will be executed a bit faster:
let $PlCts := //PlCt[environment = 'AIR']/@id for $PlGeTy in //PlGeTy[isOfPlCt/@href = $PlCts] for $PlSpTy in //PlSpTy[isOfPlGeTy/@href = $PlGeTy/@id] let $ContId := $PlSpTy/isOfCont/@href/string() for $Cont in //Cont[@id eq $ContId] return <done>{ $PlGeTy, $PlSpTy, $Cont }</done>
Ideally, the query optimizer would detect that it's counterproductive to rewrite the last for clause to an index expression. However, decisions like this very much depend on the input data, and there are no simple heuristics for that.
Hope this helps, Christian
On Wed, Jun 17, 2015 at 1:39 PM, serdar ceran bsceran@gmail.com wrote:
Hi Christian,
I have also another optimization issue on a query as I mentioned in Update three section. Could you help on this one?
Thanks,
Serdar
On Wed, Jun 17, 2015 at 12:57 PM, Christian Grün christian.gruen@gmail.com wrote:
Hi Serdar,
Thanks for the hint. We have added a new GitHub issue to remember your request.
Best, Christian
[1] https://github.com/BaseXdb/basex/issues/1160
On Wed, Jun 17, 2015 at 11:18 AM, serdar ceran bsceran@gmail.com wrote:
Hi, BaseX team. I have a problem; Performing queries with a local function takes too much time to get the result.
Please have a look at the Stackoverflow for more details.
Best regards;
Serdar CERAN
-- Best regards;
-- B. Serdar CERAN
Yaltes Company Specialist Software Engineer Tel: +905423993073