// Group By Costs // /// <summary> /// Represents the cost to group data from an ordered stream /// </summary> /// <param name="RecordCount"></param> /// <param name="BuildIndex"></param> /// <returns></returns> public static double OrderedGroupByCost(long RecordCount, bool BuildIndex) { return((double)RecordCount + (BuildIndex ? CostCalculator.IndexBuildCost(RecordCount) : 0)); }
/// <summary> /// /// </summary> /// <param name="ARecordCount"></param> /// <param name="BRecordCount"></param> /// <param name="BuildLeftIndex"></param> /// <param name="BuildRightIndex"></param> /// <returns></returns> public static double SortMergeNestedLoopJoinCost(long ARecordCount, long BRecordCount, bool BuildLeftIndex, bool BuildRightIndex) { return((double)Math.Max(ARecordCount, BRecordCount) + (BuildLeftIndex ? CostCalculator.IndexBuildCost(ARecordCount) : 0) + (BuildRightIndex ? CostCalculator.IndexBuildCost(BRecordCount) : 0)); }
/// <summary> /// Returns the cost for performing a quasi-nested loop join /// </summary> /// <param name="ARecordCount"></param> /// <param name="BRecordCount"></param> /// <param name="BuildRightIndex"></param> /// <returns></returns> public static double QuasiNestedLoopJoinCost(long ARecordCount, long BRecordCount, bool BuildRightIndex) { return(ARecordCount * CostCalculator.LogN(BRecordCount) + (BuildRightIndex ? CostCalculator.IndexBuildCost(BRecordCount) : 0)); }
/// <summary> /// Returns the cost for building an index /// </summary> /// <param name="RecordCount"></param> /// <returns></returns> public static double IndexBuildCost(long RecordCount) { return(CostCalculator.SumLogI(RecordCount)); }
// Index Costs // /// <summary> /// Returns the cost for searching an index /// </summary> /// <param name="RecordCount"></param> /// <returns></returns> public static double IndexSeekCost(long RecordCount) { return(CostCalculator.LogN(RecordCount)); }
/// <summary> /// Represents the cost to group by using a dictionary /// </summary> /// <param name="RecordCount"></param> /// <returns></returns> public static double DictionaryGroupByCost(long RecordCount) { return((double)RecordCount + CostCalculator.IndexBuildCost(RecordCount)); }