Example #1
0
/**
@SYMTestCaseID          SYSLIB-DBMS-CT-0579
@SYMTestCaseDesc        Tests the database definition and enquiry functions
@SYMTestPriority        Medium
@SYMTestActions        	Executes the index and bookmark tests
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void BigTestL()
	{
	test.Start(_L(" @SYMTestCaseID:SYSLIB-DBMS-CT-0579 Table "));
	CreateDatabaseL();
	BuildTable(KRecords);
	test(TheTable.Open(TheDatabase,KTableName)==KErrNone);
	TheTable.EndL();
	IterateL(TheTable.EPrevious);
	TheTable.BeginningL();
	IterateL(TheTable.ENext);
	TheTable.EndL();
	IterateL(TheTable.EPrevious);
	TheTable.Close();
	test.Next(_L("Int32 Index"));
	CDbKey *key=CDbKey::NewLC();
	key->AddL(KColumnInt);
	key->MakeUnique();
	TestIndex(KIndexInt,*key);
	test.Next(_L("Text[200] Index"));
	key->Clear();
	key->AddL(KColumnText);
	key->MakeUnique();
	TestIndex(KIndexText,*key);
	test.Next(_L("Bookmarks"));
	TestBookmark();
	test.Next(_L("Int32 Index"));
#ifndef __TOOLS2__
	TheTimer.Start(_L("drop"));
#endif
	test(TheDatabase.DropIndex(KIndexInt,KTableName)==KErrNone);
#ifndef __TOOLS2__
	TheTimer.Stop();
#endif
	key->Clear();
	key->AddL(KColumnInt);
	key->MakeUnique();
	TestIndex(KIndexInt,*key);
	CleanupStack::PopAndDestroy();
	test.Next(_L("Break & Recover"));
	BreakIndex();
	Recover();
	test.Next(_L("Drop Indexes"));
	DropIndexes();
	test.Next(_L("Delete all records"));
	DeleteTable();
	CloseDatabaseL();
	test.End();
	}
void IndexTuner::Analyze(storage::DataTable* table) {

  // Process all samples in table
  auto& samples = table->GetIndexSamples();
  auto sample_count = samples.size();

  // Check if we have sufficient number of samples
  if (sample_count < sample_count_threshold) {
    return;
  }

  // Check write ratio
  auto average_write_ratio = ComputeWorkloadWriteRatio(samples);

  // Determine frequent samples
  auto sample_frequency_entry_list = GetFrequentSamples(samples);

  // Compute suggested indices
  auto suggested_indices = GetSuggestedIndices(sample_frequency_entry_list);

  // Check index storage footprint
  auto max_indexes_allowed = CheckIndexStorageFootprint(table);

  // Drop indexes if needed
  auto index_creation_constraint = (max_indexes_allowed <= 0);
  auto write_intensive_workload = (average_write_ratio > write_ratio_threshold);
  if (index_creation_constraint == true || write_intensive_workload == true) {
    DropIndexes(table);
  }

  // Add indexes if needed
  AddIndexes(table, suggested_indices, max_indexes_allowed);

  // Clear all current samples in table
  table->ClearIndexSamples();

  // Update index utility
  UpdateIndexUtility(table, sample_frequency_entry_list);

  // Display index information
  PrintIndexInformation(table);
}