|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TODAY'S TOP SOA & WEBSERVICES LINKS Industry Commentary Open Source Database Special Feature: An Introduction to Berkeley DB XML
Basic concepts, the shell commands, and beyond
By: Selim Mimaroglu
Dec. 20, 2005 11:45 AM
Eager vs Lazy Evaluation 436 objects returned for eager expression Eager is the default query evaluation method. Evaluating a query eagerly means that the BDB will store a result as soon as it finds any. In other words, eager evaluation grabs all of the results and stores them in a data structure, and they are available immediately after query execution. However, this is not the case when queries are evaluated lazily. In lazy evaluation, the database will not keep the results in a data structure. It will know how to get them (using pointers), but it will not do anything until the results are retrieved. Results are stored in sets. To get all of the results we have to iterate through the result set, using the next operator. This is what happens internally when we use the "print" command in the dbxml shell. It iterates through the entire set and gets every element of the result set. Thus, when queries are evaluated eagerly, the result set will be filled immediately after executing the query, as opposed to when the queries are evaluated lazily, and the result set either is empty or it has some of the results but definitely not all of them. It may sound as though lazy query evaluation is never useful, but this is not the case. If you do not need all of the objects returned by the query, using lazy evaluation makes more sense. You can see this with the following query:
dbxml> setLazy on Note that execution time for this query is ignorable (there is no execution time info printed out by the database). That's because the actual results aren't retrieved yet. BDB XML will retrieve the results only after "print" command. We know that there are 436 objects returned by this query. Instead of getting all of the results, let's get only top eight of them. We can do this by using "print n 8" command.
XML Schema Validation This document is assigned an XML Schema. The part that shows this assignment is:
<dictionary xmlns:xsi= This schema is located at www.cs.umb.edu/~smimarog/xmlsample/TCSD1.xsd. XML Schemas and XML documents can be located on the same machine or on different machines. In this example, XML Schema and XML data are located on two different machines.
dbxml> createContainer validate_xbench.dbxml d validate A natural question is whether it's possible to add an XML document into this container without validating. Validation in Berkeley DB XML is very fast, which is a big time-saver. I have found that validating a document in BDB XML takes much less time than some commercial XML editors. However, it may be costly to validate each document when documents are huge. Besides, sometimes XML documents are not assigned to any schema. Listing 9 shows the XML sample (10MB XML sample in the References section) that I am going to put into this container. Within this container we have two documents named dict_10_valid, and dict_10; the first document is validated, but the second is not. In some cases it's desirable to restrict queries to a specific document in the collection. We can achieve this by using the "doc" function.
dbxml> query 'doc("validate_xbench.dbxml/dict_10")//hwg' By saying doc("validate_xbench.dbxml/dict_10"), the queries are restricted to run on only the dict_10 document.
Indexing [unique]-{path type}-{node type}-{key type}-{syntax type} An index in BDB XML is composed of four parts:
Uniqueness indicates that the value being indexed is unique in the XML document. For example, in an employees data set, employee number will be unique, along with the social security number. YOUR FEEDBACK
XML JOURNAL LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING XML NEWS
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||