Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 1256

db4o-doc-7.4-2.fc13.i686.rpm

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Enable Field Indexes</title>
    <link rel="stylesheet" type="text/css" href="../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Enable Field Indexes</h1><div id="TOC"><div id="TOCinner"><span class="TOCtitle">Contents</span><div class="TOCcontents"><ul><li><a href ="#Advantage">Advantage</a></li><li><a href ="#Alternate Strategies">Alternate Strategies</a></li></ul></li></ul></div></div></div><script>
//We attach this function to a browser object as a variable so that if multiple of these blocks are
//present on the same page, then they will simply over-write eachother with the same function instead
//of generating a naming collision.
window.WikiCodeFormattingCopyToClipboard = function copyToClipboard(sID){
	var sContent = document.getElementById(sID).innerText;
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", sContent);
	}
	else
	{
		alert("You must enable javascript access to your clipboard for this feature to work. Please referr to your browser documentation or Google search for instructions.");
	}
}
</script>

<p>For class Car with field "pilot":</p>


<span name="cs_wiki_filter" csw_filters="cs">
<p>c#:   </p><p><code>Db4oFactory.Configure().ObjectClass(typeof(Car)).ObjectField("pilot").Indexed(true)</code></p>
</span>
<span name="cs_wiki_filter" csw_filters="vb">
<p>VB:   </p><p><code>Db4oFactory.Configure().ObjectClass(GetType(Car)).ObjectField("pilot").Indexed(true)</code></p>
</span>

<a name="Advantage"></a><h2>Advantage</h2>
<p>The fastest way to improve the performance of your queries is to enable indexing on some of your class's key fields. You can read how to do it in <a href="../indexing.html" class="wikiLink">Indexing</a> chapter of this documentation.</p>
<p>
Further step of index tuning is to optimize indexes for Class.Field1.Field2 access. What will give us the best performance:</p>
<ul>
<li>
index on Field1;</li>
<li>index on Field2;</li>
<li>index on both fields?</li>
</ul>
<p>To find the answer let's consider classes Car and Pilot from the previous chapters. In order to see indexing influence we will put 10000 new cars in our storage (note that for db4o version &gt; 5.6 the amount of objects&nbsp; should be much more to see the differences in execution time due to BTree based index optimized for big amounts of data ):</p>



<span name="cs_wiki_filter" csw_filters="cs">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.cs: <span class="fscMemberName">FillUpDB</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> FillUpDB()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_39_250_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_39_250_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_39_250_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_39_250_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_39_250_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_39_250_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_39_250_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_39_250_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_39_250_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_39_250_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      File.Delete(Db4oFileName);
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db</span><span style="color: #000000;">=</span><span style="color: #000000;">Db4oFactory.OpenFile(Db4oFileName);
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_137_212_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_137_212_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_137_212_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_137_212_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_137_212_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_137_212_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_137_212_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_137_212_Open_Text').style.display='inline';"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_137_212_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_137_212_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_175_207_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_175_207_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_175_207_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_175_207_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_175_207_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_175_207_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_175_207_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_175_207_Open_Text').style.display='inline';"/>            </span><span style="color: #0000FF;">for</span><span style="color: #000000;"> (</span><span style="color: #0000FF;">int</span><span style="color: #000000;"> i</span><span style="color: #000000;">=</span><span style="color: #800080;">0</span><span style="color: #000000;">; i</span><span style="color: #000000;">&lt;</span><span style="color: #800080;">10000</span><span style="color: #000000;">;i</span><span style="color: #000000;">++</span><span style="color: #000000;">)</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_175_207_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_175_207_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            AddCar(db,i);
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>          }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_224_246_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_224_246_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_224_246_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_224_246_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_224_246_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_224_246_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_224_246_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_224_246_Open_Text').style.display='inline';"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_224_246_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FillUpDB_1279_54_224_246_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>
<p>[/filter] </p>

<p>[filter=vb]</p>
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.vb: <span class="fscMemberName">FillUpDB</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FillUpDB_1376_54"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FillUpDB_1376_54_15_343_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FillUpDB_1376_54_15_343_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FillUpDB_1376_54_15_343_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FillUpDB_1376_54_15_343_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FillUpDB_1376_54_15_343_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FillUpDB_1376_54_15_343_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FillUpDB_1376_54_15_343_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FillUpDB_1376_54_15_343_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FillUpDB_1376_54_15_343_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub FillUpDB()</span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FillUpDB_1376_54_15_343_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> FillUpDB()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            File.Delete(Db4oFileName)
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">For</span><span style="color: #000000;"> i </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;"> </span><span style="color: #0000FF;">To</span><span style="color: #000000;"> </span><span style="color: #800080;">10000</span><span style="color: #000000;">
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    AddCar(db, i)
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Next</span><span style="color: #000000;">
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>
</span>



<span name="cs_wiki_filter" csw_filters="cs">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.cs: <span class="fscMemberName">AddCar</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_AddCar_1494_52"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> AddCar(IObjectContainer db, </span><span style="color: #0000FF;">int</span><span style="color: #000000;"> points)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_AddCar_1494_52_62_155_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_AddCar_1494_52_62_155_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_AddCar_1494_52_62_155_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_AddCar_1494_52_62_155_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_AddCar_1494_52_62_155_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_AddCar_1494_52_62_155_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_AddCar_1494_52_62_155_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_AddCar_1494_52_62_155_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_AddCar_1494_52_62_155_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_AddCar_1494_52_62_155_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      Car car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      car.Pilot</span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Tester</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, points);
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      db.Set(car);
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>
</span>

<span name="cs_wiki_filter" csw_filters="vb">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.vb: <span class="fscMemberName">AddCar</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_AddCar_1606_52"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">1</span><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_AddCar_1606_52_15_255_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_AddCar_1606_52_15_255_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_AddCar_1606_52_15_255_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_AddCar_1606_52_15_255_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_AddCar_1606_52_15_255_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_AddCar_1606_52_15_255_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_AddCar_1606_52_15_255_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_AddCar_1606_52_15_255_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_AddCar_1606_52_15_255_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub AddCar()</span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_AddCar_1606_52_15_255_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> AddCar(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer, </span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> points </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;">)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> car </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Car </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Car(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">BMW</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> pilot </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Tester</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">, points)
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            car.Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> pilot
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Set(car)
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>
</span>

<p>Now we have lots of similar cars differing only in the amount of pilots' points - that will be our constraint for the query.</p>



<span name="cs_wiki_filter" csw_filters="cs">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.cs: <span class="fscMemberName">NoIndex</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_30_566_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_30_566_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_30_566_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_30_566_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_30_566_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_30_566_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_30_566_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_30_566_Open_Text').style.display='inline';"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> NoIndex() </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_30_566_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_30_566_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        IObjectContainer db</span><span style="color: #000000;">=</span><span style="color: #000000;">Db4oFactory.OpenFile(Db4oFileName);
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_101_528_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_101_528_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_101_528_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_101_528_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_101_528_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_101_528_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_101_528_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_101_528_Open_Text').style.display='inline';"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_101_528_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_101_528_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          IQuery query </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query();
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        query.Constrain(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car));
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">99</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        DateTime dt1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        IObjectSet  result </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute();
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        DateTime dt2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        TimeSpan  diff </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1;
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Test 1: no indexes</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Execution time=</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">+</span><span style="color: #000000;">diff.TotalMilliseconds </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        ListResult(result);
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_540_562_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_540_562_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_540_562_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_540_562_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_540_562_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_540_562_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_540_562_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_540_562_Open_Text').style.display='inline';"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_540_562_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_NoIndex_1857_53_540_562_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>
</span>

<span name="cs_wiki_filter" csw_filters="vb">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.vb: <span class="fscMemberName">NoIndex</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_NoIndex_1970_53"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_NoIndex_1970_53_15_777_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_NoIndex_1970_53_15_777_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_NoIndex_1970_53_15_777_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_NoIndex_1970_53_15_777_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_NoIndex_1970_53_15_777_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_NoIndex_1970_53_15_777_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_NoIndex_1970_53_15_777_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_NoIndex_1970_53_15_777_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_NoIndex_1970_53_15_777_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub NoIndex()</span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_NoIndex_1970_53_15_777_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> NoIndex()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName)
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> query </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IQuery </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query()
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                query.Constrain(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car))
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">99</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> dt1 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute()
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> dt2 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> diff </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> TimeSpan </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Test 1: no indexes</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Execution time=</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds.ToString() </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(result)
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>
</span>

<p>You can check execution time on your workstation using interactive version of this tutorial.</p>
<p>Let's create index for pilots and their points and test the same query again:</p>



<span name="cs_wiki_filter" csw_filters="cs">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.cs: <span class="fscMemberName">FullIndex</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> FullIndex()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_40_868_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_40_868_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_40_868_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_40_868_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_40_868_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_40_868_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_40_868_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_40_868_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_40_868_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_40_868_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IConfiguration configuration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration();
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">true</span><span style="color: #000000;">);
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Pilot)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">true</span><span style="color: #000000;">);
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(configuration, Db4oFileName);
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_388_830_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_388_830_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_388_830_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_388_830_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_388_830_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_388_830_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_388_830_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_388_830_Open_Text').style.display='inline';"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_388_830_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_388_830_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          IQuery query </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query();
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        query.Constrain(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car));
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">99</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        DateTime dt1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        IObjectSet  result </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute();
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        DateTime dt2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        TimeSpan  diff </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1;
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Test 2: index on pilot and points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Execution time=</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">+</span><span style="color: #000000;">diff.TotalMilliseconds </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        ListResult(result);
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_842_864_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_842_864_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_842_864_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_842_864_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_842_864_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_842_864_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_842_864_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_842_864_Open_Text').style.display='inline';"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_842_864_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_FullIndex_2276_55_842_864_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>
</span>

<span name="cs_wiki_filter" csw_filters="vb">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.vb: <span class="fscMemberName">FullIndex</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FullIndex_2391_55"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FullIndex_2391_55_15_1069_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FullIndex_2391_55_15_1069_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FullIndex_2391_55_15_1069_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FullIndex_2391_55_15_1069_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FullIndex_2391_55_15_1069_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FullIndex_2391_55_15_1069_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FullIndex_2391_55_15_1069_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FullIndex_2391_55_15_1069_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FullIndex_2391_55_15_1069_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub FullIndex()</span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_FullIndex_2391_55_15_1069_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> FullIndex()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> configuration </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IConfiguration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration()
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">True</span><span style="color: #000000;">)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Pilot)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">True</span><span style="color: #000000;">)
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(configuration, Db4oFileName)
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> query </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IQuery </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query()
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                query.Constrain(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car))
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">99</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> dt1 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute()
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> dt2 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> diff </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> TimeSpan </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Test 2: index on pilot and points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Execution time=</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds.ToString() </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(result)
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>
</span>

<p>That result is considerably better and proves the power of indexing.</p>
<p>
But do we really need 2 indexes? Will single pilot or points index suffice? Let's test this as well:</p>



<span name="cs_wiki_filter" csw_filters="cs">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.cs: <span class="fscMemberName">PilotIndex</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> PilotIndex()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_41_848_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_41_848_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_41_848_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_41_848_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_41_848_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_41_848_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_41_848_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_41_848_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_41_848_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_41_848_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IConfiguration configuration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration();
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">true</span><span style="color: #000000;">);
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Pilot)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">false</span><span style="color: #000000;">);
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db</span><span style="color: #000000;">=</span><span style="color: #000000;">Db4oFactory.OpenFile(configuration, Db4oFileName);
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_379_810_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_379_810_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_379_810_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_379_810_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_379_810_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_379_810_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_379_810_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_379_810_Open_Text').style.display='inline';"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_379_810_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_379_810_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          IQuery query </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query();
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        query.Constrain(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car));
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">99</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        DateTime dt1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        IObjectSet  result </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute();
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        DateTime dt2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        TimeSpan  diff </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1;
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Test 3: index on pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Execution time=</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">+</span><span style="color: #000000;">diff.TotalMilliseconds </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        ListResult(result);
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_822_844_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_822_844_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_822_844_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_822_844_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_822_844_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_822_844_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_822_844_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_822_844_Open_Text').style.display='inline';"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_822_844_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PilotIndex_2700_56_822_844_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>
</span>

<span name="cs_wiki_filter" csw_filters="vb">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.vb: <span class="fscMemberName">PilotIndex</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PilotIndex_2816_56"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PilotIndex_2816_56_15_1060_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PilotIndex_2816_56_15_1060_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PilotIndex_2816_56_15_1060_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PilotIndex_2816_56_15_1060_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PilotIndex_2816_56_15_1060_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PilotIndex_2816_56_15_1060_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PilotIndex_2816_56_15_1060_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PilotIndex_2816_56_15_1060_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PilotIndex_2816_56_15_1060_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub PilotIndex()</span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PilotIndex_2816_56_15_1060_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> PilotIndex()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> configuration </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IConfiguration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration()
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">True</span><span style="color: #000000;">)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Pilot)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">False</span><span style="color: #000000;">)
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(configuration, Db4oFileName)
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> query </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IQuery </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query()
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                query.Constrain(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car))
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">99</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> dt1 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute()
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> dt2 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> diff </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> TimeSpan </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Test 3: index on pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Execution time=</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds.ToString() </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(result)
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>
</span>



<span name="cs_wiki_filter" csw_filters="cs">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.cs: <span class="fscMemberName">PointsIndex</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> PointsIndex()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_42_850_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_42_850_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_42_850_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_42_850_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_42_850_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_42_850_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_42_850_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_42_850_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_42_850_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_42_850_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IConfiguration configuration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration();
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">false</span><span style="color: #000000;">);
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Pilot)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">true</span><span style="color: #000000;">);
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db</span><span style="color: #000000;">=</span><span style="color: #000000;">Db4oFactory.OpenFile(configuration, Db4oFileName);
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_380_812_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_380_812_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_380_812_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_380_812_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_380_812_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_380_812_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_380_812_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_380_812_Open_Text').style.display='inline';"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_380_812_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_380_812_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          IQuery query </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query();
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        query.Constrain(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car));
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">99</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        DateTime dt1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        IObjectSet  result </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute();
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        DateTime dt2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        TimeSpan  diff </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1;
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Test 4: index on points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Execution time=</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">+</span><span style="color: #000000;">diff.TotalMilliseconds </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        ListResult(result);
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_824_846_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_824_846_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_824_846_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_824_846_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_824_846_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_824_846_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_824_846_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_824_846_Open_Text').style.display='inline';"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_824_846_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceTuningPerformance_HintsindexesCS.ZipsIndexedExample.Cs_IndexedExample.Cs_PointsIndex_2936_57_824_846_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>
</span>

<span name="cs_wiki_filter" csw_filters="vb">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IndexedExample.vb: <span class="fscMemberName">PointsIndex</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PointsIndex_3053_57"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PointsIndex_3053_57_15_1062_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PointsIndex_3053_57_15_1062_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PointsIndex_3053_57_15_1062_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PointsIndex_3053_57_15_1062_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PointsIndex_3053_57_15_1062_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PointsIndex_3053_57_15_1062_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PointsIndex_3053_57_15_1062_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PointsIndex_3053_57_15_1062_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PointsIndex_3053_57_15_1062_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub PointsIndex()</span><span id="ResourcesReferenceTuningPerformance_HintsindexesVB.ZipsIndexedExample.Vb_IndexedExample.Vb_PointsIndex_3053_57_15_1062_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> PointsIndex()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> configuration </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IConfiguration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration()
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">False</span><span style="color: #000000;">)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.ObjectClass(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Pilot)).ObjectField(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Indexed(</span><span style="color: #0000FF;">True</span><span style="color: #000000;">)
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(configuration, Db4oFileName)
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> query </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IQuery </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Query()
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                query.Constrain(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car))
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                query.Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_pilot</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Descend(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">_points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">).Constrain(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">99</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> dt1 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> query.Execute()
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> dt2 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> diff </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> TimeSpan </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Test 4: index on points</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Execution time=</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds.ToString() </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(result)
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>
</span>

<p>Single index does not increase query performance on second level fields.</p>
<p>
To maximize retrieval performance on encapsulated fields of different levels of enclosure</p>
<p>Class.Field1.Field2.Field3(.FieldN)</p>
<p>indexes for each field level should be created:</p>
<p>Class.Field1.Indexed(true) </p>
<p>Field1Class.Field2.Indexed(true)</p>
<p>Field2Class.Field3.Indexed(true)</p>
<p>. . .</p>
<p>Field(N-1)Class.FieldN.Indexed(true)</p>
<a name="Alternate Strategies"></a><h2>Alternate Strategies</h2>
<p>Field indexes dramatically improve query performance but they may considerably reduce storage and update performance. The best way to decide where to put the indexes is to test them on completed application with typical typical data load.</p></div>
    </div>
    <div id="footer">
					This revision (12) was last Modified 2007-07-11T06:51:13 by Tetyana.
				</div>
  </body>
</html>