Skip to content

Instantly share code, notes, and snippets.

@XPerianer
Created April 1, 2020 15:40
Show Gist options
  • Save XPerianer/47faa74e7933566eb73148d1468f43d3 to your computer and use it in GitHub Desktop.
Save XPerianer/47faa74e7933566eb73148d1468f43d3 to your computer and use it in GitHub Desktop.
Performance of PosList pointing into index
BENCHMARK_F(TPCHDataMicroBenchmarkFixture, BM_TPCHQ6IndexScan)(benchmark::State& state) {
auto& sm = Hyrise::get().storage_manager;
auto lineitem_table = sm.get_table("lineitem");
std::vector<ColumnID> index_column_ids = {ColumnID{10}};
lineitem_table->create_index<GroupKeyIndex>(index_column_ids);
// Similar to the less predicate used in tpchq6 on l_shipdate.
const std::vector<ColumnID> left_column_ids = {ColumnID{10}};
const std::vector<AllTypeVariant> right_values = {"1995-01-01"};
for (auto _ : state) {
const auto table_scan = std::make_shared<IndexScan>(_table_wrapper_map.at("lineitem"), SegmentIndexType::GroupKey,
left_column_ids, PredicateCondition::LessThan, right_values);
table_scan->execute();
}
}
BENCHMARK_F(TPCHDataMicroBenchmarkFixture, BM_TPCHQ6IndexScan_Matches_All_Predicate)(benchmark::State& state) {
auto& sm = Hyrise::get().storage_manager;
auto lineitem_table = sm.get_table("lineitem");
std::vector<ColumnID> index_column_ids = {ColumnID{10}};
lineitem_table->create_index<GroupKeyIndex>(index_column_ids);
const std::vector<ColumnID> left_column_ids = {ColumnID{10}};
const std::vector<AllTypeVariant> right_values = {"1600-01-01"};
for (auto _ : state) {
const auto table_scan = std::make_shared<IndexScan>(_table_wrapper_map.at("lineitem"), SegmentIndexType::GroupKey,
left_column_ids, PredicateCondition::GreaterThan, right_values);
table_scan->execute();
}
}
BENCHMARK_F(TPCHDataMicroBenchmarkFixture, BM_TPCHQ6TableScan_After_IndexScan)(benchmark::State& state) {
auto& sm = Hyrise::get().storage_manager;
auto lineitem_table = sm.get_table("lineitem");
std::vector<ColumnID> index_column_ids = {ColumnID{10}};
lineitem_table->create_index<GroupKeyIndex>(index_column_ids);
const std::vector<ColumnID> left_column_ids = {ColumnID{10}};
const std::vector<AllTypeVariant> right_values = {"1995-01-01"};
const auto index_scan = std::make_shared<IndexScan>(_table_wrapper_map.at("lineitem"), SegmentIndexType::GroupKey,
left_column_ids, PredicateCondition::LessThan, right_values);
index_scan->execute();
const auto scan_result = index_scan->get_output();
for (auto _ : state) {
const auto table_scan = std::make_shared<TableScan>(index_scan, _tpchq6_quantity_predicate);
table_scan->execute();
}
}
BENCHMARK_F(TPCHDataMicroBenchmarkFixture, BM_TPCHQ6IndexScan_And_TableScan_Together)(benchmark::State& state) {
auto& sm = Hyrise::get().storage_manager;
auto lineitem_table = sm.get_table("lineitem");
std::vector<ColumnID> index_column_ids = {ColumnID{10}};
lineitem_table->create_index<GroupKeyIndex>(index_column_ids);
const std::vector<ColumnID> left_column_ids = {ColumnID{10}};
const std::vector<AllTypeVariant> right_values = {"1995-01-01"};
for (auto _ : state) {
const auto index_scan = std::make_shared<IndexScan>(_table_wrapper_map.at("lineitem"), SegmentIndexType::GroupKey,
left_column_ids, PredicateCondition::LessThan, right_values);
index_scan->execute();
const auto table_scan = std::make_shared<TableScan>(index_scan, _tpchq6_quantity_predicate);
table_scan->execute();
}
}
PosList pointing into index:
------------------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------------------------------------------------------------------
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6IndexScan 182104 ns 182102 ns 3837
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6IndexScan_Matches_All_Predicate 328445 ns 328420 ns 2147
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6TableScan_After_IndexScan 22750846 ns 22750434 ns 28
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6IndexScan_And_TableScan_Together 23127492 ns 23124115 ns 30
normal (RowID) posList:
------------------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
------------------------------------------------------------------------------------------------------------------
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6IndexScan 4177652 ns 4177585 ns 166
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6IndexScan_Matches_All_Predicate 11711713 ns 11711153 ns 58
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6TableScan_After_IndexScan 20667343 ns 20666796 ns 34
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6IndexScan_And_TableScan_Together 25021510 ns 25019400 ns 28
@Bensk1
Copy link

Bensk1 commented Apr 1, 2020

I am getting these results for your branch but it is kind of pointless without being able to comparing it to the normal (RowID) PosList.

------------------------------------------------------------------------------------------------------------------
Benchmark                                                                        Time             CPU   Iterations
------------------------------------------------------------------------------------------------------------------
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6IndexScan                            120146 ns       120147 ns         5785
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6IndexScan_Matches_All_Predicate      217132 ns       217134 ns         3220
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6TableScan_After_IndexScan           6973421 ns      6968938 ns           97
TPCHDataMicroBenchmarkFixture/BM_TPCHQ6IndexScan_And_TableScan_Together    7178071 ns      7175552 ns           94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment