[MarkLogic Dev General] max function alternatives
Mike Sokolov
sokolov at ifactory.com
Wed Jan 10 12:22:37 PST 2007
Have you tried:
(for $i in /RootElement
order by xs:int($i/@index) descending)[ 1 ]/@index
?
If you aren't using namespaces at all (sounds like) just leave those
fields blank.
If you get the index set up that query should be OK - we solved exactly
this problem yesterday in this way.
Of course it'd be nice if the database had a sequence construct or an
autoincrement property like every SQL database in the universe, but it's
not impossible to make one yourself given a range index and transactions.
-Mike
Patrick Force wrote:
> I'm attempting to find some alternatives in MarkLogic for improving
> the speed of a max XQuery call we currently have in place. I believe
> the solution exists, for my case, in setting an attribute index, but
> I've been unsuccessful in my attempts so far. The help docs for the
> administration interface don't seem to explain the meaning and exact
> use of the namespace uri values of a range index. I believe I might
> be mixing XPath concepts into the namespace values erroneously. A
> more detailed explanation of the scenario:
>
> 1) We have multiple documents that exist at the uri like:
> /c/database/documents
> 2) Each document contains a root element like: <RootElement
> id="HPX_9876" index="9876">...etc.
> 3) Our current XQuery call in question: max(/RootElement/@index)
> 4) I've attempted to set up an attribute index via the administration
> console:
> a) scalar type: string
> b) parent namespace uri: ??? I've attempted a uri-type value like
> /c/database/documents/RootElement but I haven't found a good
> explanation of what this value should be
> c) parent localname: RootElement
> d) namespace uri: ??? again, not sure how to set this one but have
> tried uri-type value of /c/database/documents/RootElement/@index
> e) localname: index
> 5) Set the above attribute index in efforts to make the following
> XQuery perform a faster max call:
> max(for $i in
> cts:element-attribute-values(xs:QName(“InsurancePolicy”),xs:QName(“id”))
> return xs:int($i))
>
> Any ideas/suggestions would be greatly appreciated.
>
> Patrick_______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
More information about the General
mailing list