Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 2e9c43658e374d290a2de15d25134ac8 > files > 671

db4o-doc-8.0-1.fc15.i686.rpm

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="2" MadCap:lastHeight="120" MadCap:lastWidth="624" MadCap:disableMasterStylesheet="true" MadCap:tocPath="Configuration|Common Configuration|Query Modes" MadCap:InPreviewMode="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" MadCap:PathToHelpSystem="../../../../" MadCap:HelpSystemFileName="index.xml" MadCap:SearchType="Stem">
    <head><title>Lazy Queries	</title>
        <script type="text/javascript">/* <![CDATA[ */
window.onload = function(){
	var pathToFlash = $('html').attr('MadCap:PathToHelpSystem') + 'Content/Resources/Code/ZeroClipboard.swf';
	ZeroClipboard.setMoviePath(pathToFlash);
			
	function bindToClipBord(element,content){
		var clip = new ZeroClipboard.Client();
		clip.setText(content);
		clip.glue(element);
	};
		
	if(location.protocol==='file:'){
		$('.copylink-marker').remove();
	} else{
			$('.copylink-marker').each(function(){
				var text = $(this).parent().parent().children('.prettyprint').html();
				$(this).hover(function(){
					bindToClipBord(this,text);
				},
				function(){});
			});	
	}		
	prettyPrint();	
};
                /* ]]> */</script>
        <link href="../../../SkinSupport/MadCap.css" rel="stylesheet" />
        <link href="../../../Resources/Stylesheets/OnlineStyle.css" rel="stylesheet" />
        <script src="../../../Resources/Code/prettify.js">
        </script>
        <script src="../../../Resources/Code/lang-vb.js">
        </script>
        <script src="../../../Resources/Code/jquery.min.js">
        </script>
        <script src="../../../Resources/Code/ZeroClipboard.js">
        </script>
        <script src="../../../SkinSupport/MadCapAll.js" type="text/javascript">
        </script>
    </head>
    <body>
        <p class="MCWebHelpFramesetLink" style="display: none;"><a href="../../../../index_CSH.html#configuration/common/query_modes/lazy_queries.htm" style="">Open topic with navigation</a>
        </p>
        <div class="MCBreadcrumbsBox"><span class="MCBreadcrumbsPrefix">You are here: </span><a class="MCBreadcrumbsLink" href="../../../configuration.htm">Configuration</a><span class="MCBreadcrumbsDivider"> &gt; </span><a class="MCBreadcrumbsLink" href="../../common_configuration.htm">Common Configuration</a><span class="MCBreadcrumbsDivider"> &gt; </span><a class="MCBreadcrumbsLink" href="../query_modes.htm">Query Modes</a><span class="MCBreadcrumbsDivider"> &gt; </span><span class="MCBreadcrumbs">Lazy Queries</span>
        </div>
        <p>
            <script type="text/javascript">/*<![CDATA[*/document.write('<a href="' + location.href +'">');
				document.write("Direct Link");
			document.write('</a>');/*]]>*/</script>
        </p>
        <p>
        </p>
        <h1><a name="kanchor40"></a>Lazy Queries</h1>
        <P>With the Lazy Querying no criteria evaluated at all. Instead  an iterator is created against the best index found. Further query processing, including all index processing, will happen when the application iterates through the result. This allows you to get the first query results almost immediately.</P>
        <P>In addition to the very fast execution this method also ensures very small memory consumption. Because lazy queries do not need an intermediate representation as a set of IDs in memory. With this approach it does not have to cache a single object or ID. The memory consumption for a query is practically zero, no matter how large the result set is going to be.</P>
        <P>There are some interesting effects appearing due to the fact that the objects are getting evaluated only on a request. It means that all the committed modifications from the other transactions and uncommitted modifications from the same transaction will be taken into account when delivering the result objects.</P>
        <H2>Advantages</H2>
        <UL>
            <LI value="1">The call to <CODE>Query.execute()</CODE> will return very fast. First results can be made available to the application before the query is fully processed.</LI>
            <LI value="2">A query will consume hardly any memory at all because no intermediate ID representation is ever created.</LI>
        </UL>
        <h2>Disadvantages</h2>
        <UL>
            <LI value="1">Lazy queries check candidates when iterating through the 'result'. In doing so the query processor takes changes into account that may have happened since the Query.execute() call: committed changes from other transactions, <B>and uncommitted changes from the calling transaction</B>. There is a wide range of possible side effects:</LI>
            <UL>
                <LI value="1">The underlying index may have changed. </LI>
                <LI value="2">Objects themselves may have changed in the meanwhile. </LI>
                <LI value="3">There even is a chance of creating an endless loop. If the caller iterates through the <CODE>ObjectSet</CODE> and changes each object in a way that it is placed at the end of the index, the same objects can be revisited over and over. </LI>
            </UL>
            <B>In lazy mode it can make sense to work in same ways as with collections to avoid concurrent modification exceptions.</B> For instance one could iterate through the <CODE>ObjectSet</CODE> first and store all the objects to a temporary collection representation before changing objects and storing them back to db4o. 
<LI value="2">Some method calls against a lazy <CODE>ObjectSet</CODE> will require the query processor to create a snapshot or to evaluate the query fully. An example of such a call is <CODE>ObjectSet.size()</CODE>.</LI></UL>
        <P>Lazy mode can be an excellent choice for single transaction read use, to keep memory consumption as low as possible.</P>
        <script type="text/javascript" src="../../../SkinSupport/MadCapBodyEnd.js">
        </script>
    </body>
</html>