Re: [bdbxml] Indexing attributes
John Snelson <[email protected]>
| Newsgroups | gmane.comp.db.dbxml.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Peter,
Peter Hickman wrote:
> I have a simple database and most of the queries have the following
> structure, locate some element by it's id attribute and sort the child
> elements by the their number attribute.
>
> query '
> <div class="paragraphlist">
> {
> for $paragraph in
> collection("books.dbxml")/collection/book/chapter[@id =
> "b4.2.4"]/paragraph order by $paragraph/@number cast as xs:decimal
> return $paragraph
> }
> </div>
> '
>
> I have tried adding indexes to speed things up. An unindexed query took
> around 5.4 seconds, whatever indexes I add only make things worse,
> adding on average another second to the query.
>
> In this situation is it possible to speed things up with an index?
What indexes have you tried? I suggest adding a
"node-attribute-equality-string" index on "id".
What are the documents like in your database. If you only have one
larger document, then indexes do not currently make much of a difference
(they should in a forthcoming version). We currently suggest that people
split larger documents up into several smaller documents, to get the
best performance from DB XML.
Could it be that your paragraphs are always numbered (with @number) in
document order? If so, then you can leave off the "order by" clause, as
this is probably the main reason for the query being slow right now.
I hope this helps,
John
--
John Snelson, Berkeley DB XML Engineer
Sleepycat Software, Inc
http://www.sleepycat.com
Contracted to Sleepycat through Parthenon Computing Ltd
http://blog.parthcomp.com/dbxml
------------------------------------------
To remove yourself from this list, send an
email to [email protected]