Re: Indexing techniques for hierarchies

From: James <>
Date: 3 Jan 2002 14:23:39 -0800
Message-ID: <>

> After having reviewed a bit more of your site, I regret even making
> the attempt to compare SQL Server to your XDb product. Comparing
> performance is invalid for several reasons, the primary one being that
> XDb is solely RAM-based and apparently doesn't interact with the disk
> at all. It seems obvious to me that a single-user, RAM-only C++
> library will sometimes be able to outperform a general-purpose,
> commercial multi-user RDBMS with transaction control, concurrency
> control and recovery features, particularly on benchmarks custom-built
> to play to XDb's strengths, such as iterating over a linked list.

Yes I agree it is an apple-to-orange comparision.

> You have not convinced me that what you did cannot be represented as
> an adjacency list.

The following creates 1000 classes, each with properties of various data types. The properties of each class have are different name. An instance is made of each class.
Each instance is the child of the previous. The time to traverse 1000 instances starting from the last child and copy the properties to local variables was approximately 4 ms (4176ms / 1000 Loops).
See for details.

void CXDbView::MenuTools_Benchmark_8_click() {
  // Create MAX classes
    const int MAX = 1000;
    int x = 0;
    TCHAR fName_s[kObjTxtLenMax_g] = _T("");     for(x=0; x < MAX; ++x){

      // Create objPkg for Test Class
        _stprintf(fName_s, _T("Test%d"), x);
        pTest[x] = pO_m->InstPkg_add_(pRoot_g,          // Cls
                                        pFldrMyData_g,  // Parent
                                        fName_s);       // Inst name

      // Create cls for property pPBool
        _stprintf(fName_s, _T("PBool%d"), x);
        pPBool[x] = pO_m->InstPkg_add_(pRoot_g,         // Cls
                                        pFldrMyData_g,  // Parent
                                        fName_s);       // Inst name
        pPBoolAlias[x] = pO_m->AliasDef_get_(pPBool[x]);

      // Create cls for property pPDbl
        _stprintf(fName_s, _T("PDbl%d"), x);
        pPDbl[x] = pO_m->InstPkg_add_(pRoot_g,          // Cls
                                        pFldrMyData_g,  // Parent
                                        fName_s);       // Inst name
        pPDblAlias[x] = pO_m->AliasDef_get_(pPDbl[x]);

      // Create cls for property pPDate
        _stprintf(fName_s, _T("PDate%d"), x);
        pPDate[x] = pO_m->InstPkg_add_(pRoot_g,         // Cls
                                        pFldrMyData_g,  // Parent
                                        fName_s);       // Inst name
        pPDateAlias[x] = pO_m->AliasDef_get_(pPDate[x]);

      // Create cls for property pPStr
        _stprintf(fName_s, _T("PStr%d"), x);
        pPStr[x] = pO_m->InstPkg_add_(pRoot_g,          // Cls
                                        pFldrMyData_g,  // Parent
                                        fName_s);       // Inst name
        pPStrAlias[x] = pO_m->AliasDef_get_(pPStr[x]);

      // Attach as properties of Test Cls and set default values
        pO_m->Prop_childFirst_set_(pTest[x], pPBoolAlias[x],
        pO_m->Prop_childFirst_set_(pTest[x], pPDblAlias[x],
        pO_m->Prop_childFirst_set_(pTest[x], pPDateAlias[x], 
                                   _T("1/1/2001 12:00 P"));
        pO_m->Prop_childFirst_set_(pTest[x], pPStrAlias[x], 



  // Create 1 instance each classes, each instance a child of previous     oSt* pNew = pFldrMyData_g;
    for (x=0; x < MAX; x++){

      pNew = pO_m->Inst_add_(pTest[x],  // cls
                              pNew);    // parent
      if (!pNew)


  // Get start time
    DWORD timeStart = GetTickCount();

  // Loop thru all instances starting from last child     const int LOOPS = 1000;
    for (int y=0; y < LOOPS; y++){

      pX = pNew;
      x = MAX - 1;
      while (pX->cls() != pTest[0]){
        // Get pX's props and put in local vars
          // Int
            id = pX->id();

          // Bool
            pPBoolX = pO_m->Prop_get_(pX, pPBoolAlias[x]);
            bol = pO_m->DataBool_get_(pPBoolX->childFirst()->cls());

          // Dbl
            pPDblX = pO_m->Prop_get_(pX, pPDblAlias[x]);
            dbl = pO_m->DataDecimalPrecise_get_(pPDblX->childFirst()->cls());

          // Date
            pPDateX = pO_m->Prop_get_(pX, pPDateAlias[x]);
            dt = pO_m->DataDateTime_get_(pPDateX->childFirst()->cls());

          // Str
            pPStrX = pO_m->Prop_get_(pX, pPStrAlias[x]);
            pO_m->Data_getAsStr_(pPStrX->childFirst()->cls(), str);

        // Move to parent
          pX = pX->parent();


  // Get end time
    DWORD timeEnd = GetTickCount();

  // Calc time elapsed
    DWORD timeElapsed = timeEnd - timeStart;

  // Async flush memory to disk

  // Display results
    CString sResults;
    sResults.Format(_T("Benchmark 8\n

                    Accessed props of %d hierarchal objs 
                    %d times 
                    in %d msec."),
                    MAX, LOOPS, timeElapsed);

} Received on Thu Jan 03 2002 - 23:23:39 CET

Original text of this message