[MarkLogic Dev General] max function alternatives UPDATED

Danny Sokolsky dsokolsky at marklogic.com
Thu Jan 11 12:03:16 PST 2007


Hi Patrick,
 
In looking again at what you are trying to do, I think perhaps you have
set up the index on the wrong element/attribute conbination.  I may not
have this correct, but based on what it says below, here is what I see.
 
Below, you say you have an index on the following:
  element QName: RootElement
  attribute QName: index  
 
But the query you are trying to perform is this:
 
cts:element-attribute-values(xs:QName("InsurancePolicy"),xs:QName("id"))

        
This query requires the range index on:
  element QName: InsurancePolicy
  attribute QName: id
 
So I guess the thing to verify is exactly what index do you have
created, and exactly what query are you trying to perform. 
 
-Danny
 
-----Original Message-----
From: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] On Behalf Of Patrick
Force
Sent: Thursday, January 11, 2007 11:41 AM
To: general at developer.marklogic.com
Subject: [MarkLogic Dev General] max function alternatives UPDATED



	Thanks Mike.  Attempted the query you suggested and some
variations but it didn't improve performance.  I think I need to
continue along the path to get the index set up correctly.  The problem,
I believe, has something to do in the index setting.  It appears that
I've set it up correctly (even sent a screenshot to Ajay to confirm),
but my query continues to return an error that suggests that the
attribute index doesn't exist.  Ajay recommended that I contact support
in order to assess any issues that might exist with the install/software
etc.  I'd obviously like to figure it out before going that route, but
it might be necessary.

	Danny, I do have the reindexer enabled.  We did not reload data
after setting the attribute index.  We are currently using version
3.1-3.1.  I didn't even realize that we don't have the most current
version running.  Is there a known attribute index bug that was fixed
between 3.1-3.1 and 3.1-4?  Also, we currently have about 30,000
documents in the directory in question, and that is a bulk of the data
in the system as of now.  Overall we have a database of 38,061 documents
at 1,616 MB.

	Thank you all for the quick responses, and let me know about the
above or if you have any other feedback for me.  I will keep you updated
otherwise on the progress.

	Patrick
	
	
	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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xqzone.marklogic.com/pipermail/general/attachments/20070111/9e3a034e/attachment.html


More information about the General mailing list