Hi Christian,
Thanks, that reduces the difference in times to ~30ms.
I was not expecting the lack of typing to have such a bad effect.
I MUST remember to always declare types from now on :-)
/Andy
Hi Andy,
you can speed up the function by adding the data type of the $id argument:
declare function local:myid1($id as xs:string*) {
...
};
Otherwise, the query compiler won't know if the incoming ids will be
strings, numbers, or of any other type.
Hope this helps,
Christian
___________________________
> _______________________________________________
On Mon, Nov 21, 2011 at 11:39 PM, Andy Bunce <bunce.andy@gmail.com> wrote:
> Hi
> Using Basex 7.0.2 and the factbook.xml database, I observe the following:
>
>> declare variable $data:=db:open("factbook");
>>
>> declare function local:myid1($id){
>> $data//*[@id=$id]
>> };
>> (: get a 1000 ids to test :)
>> let $ids:=subsequence($data//@province/string(.),1,1000)
>>
>> for $s in $ids return local:myid1($s)
>
>
> Takes 30 seconds!
>
> Replacing the final line with
>>
>> for $s in $ids return $data//*[@id=$s]
>
> The time is 123ms.
>
> /Andy
>
> BaseX-Talk mailing list
> BaseX-Talk@mailman.uni-konstanz.de
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>
>