-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3700 from Mytherin/parallelinsertorderpreserving
Support Parallel Order-Preserving Result Set Materialization
- Loading branch information
Showing
93 changed files
with
2,251 additions
and
493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# name: benchmark/micro/filter/parallel_complex_filter.benchmark | ||
# description: Benchmark of parallel complex filter limit computation | ||
# group: [filter] | ||
|
||
name Parallel Complex Filter | ||
group micro | ||
subgroup filter | ||
|
||
load | ||
CREATE TABLE integers AS SELECT * FROM range(100000000) tbl(i); | ||
CREATE TABLE other_table AS SELECT 337 i UNION ALL SELECT 948247 UNION ALL SELECT 17797934; | ||
|
||
run | ||
SELECT * FROM integers WHERE i IN (SELECT * FROM other_table) | ||
|
||
result I | ||
337 | ||
948247 | ||
17797934 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# name: benchmark/micro/limit/parallel_limit.benchmark | ||
# description: Benchmark of parallel limit computation | ||
# group: [limit] | ||
|
||
name Parallel Limit | ||
group micro | ||
subgroup limit | ||
|
||
load | ||
CREATE TABLE integers AS SELECT * FROM range(100000000) tbl(i); | ||
CREATE TABLE other_table AS SELECT 337 i UNION ALL SELECT 948247 UNION ALL SELECT 17797934 UNION ALL SELECT 99999998 UNION ALL SELECT 99999999 | ||
|
||
run | ||
SELECT * FROM integers WHERE i IN (SELECT * FROM other_table) LIMIT 4 | ||
|
||
result I | ||
337 | ||
948247 | ||
17797934 | ||
99999998 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# name: benchmark/micro/limit/parallel_streaming_limit.benchmark | ||
# description: Benchmark of parallel streaming limit computation | ||
# group: [limit] | ||
|
||
name Parallel Streaming Limit | ||
group micro | ||
subgroup limit | ||
|
||
load | ||
SET preserve_insertion_order=false; | ||
CREATE TABLE integers AS SELECT i, 1 AS j FROM range(100000000) tbl(i); | ||
CREATE TABLE other_table AS SELECT 337 i UNION ALL SELECT 948247 UNION ALL SELECT 17797934 UNION ALL SELECT 99999998 UNION ALL SELECT 99999999 | ||
|
||
|
||
run | ||
SELECT j FROM integers WHERE i IN (SELECT * FROM other_table) LIMIT 4 | ||
|
||
result I | ||
1 | ||
1 | ||
1 | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# name: benchmark/micro/limit/parquet_parallel_limit.benchmark | ||
# description: Benchmark of parallel limit computation | ||
# group: [limit] | ||
|
||
name Parallel Limit (Parquet) | ||
group micro | ||
subgroup limit | ||
|
||
require parquet | ||
|
||
load | ||
CREATE TABLE tmp_integers AS SELECT * FROM range(100000000) tbl(i); | ||
CREATE TABLE other_table AS SELECT 337 i UNION ALL SELECT 948247 UNION ALL SELECT 17797934 UNION ALL SELECT 99999998 UNION ALL SELECT 99999999; | ||
COPY tmp_integers TO '${BENCHMARK_DIR}/integers.parquet'; | ||
CREATE VIEW integers AS SELECT * FROM '${BENCHMARK_DIR}/integers.parquet'; | ||
|
||
run | ||
SELECT * FROM integers WHERE i IN (SELECT * FROM other_table) LIMIT 4 | ||
|
||
result I | ||
337 | ||
948247 | ||
17797934 | ||
99999998 |
24 changes: 24 additions & 0 deletions
24
benchmark/micro/limit/parquet_parallel_limit_glob.benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# name: benchmark/micro/limit/parquet_parallel_limit_glob.benchmark | ||
# description: Benchmark of parallel limit computation | ||
# group: [limit] | ||
|
||
name Parallel Limit (Parquet Glob) | ||
group micro | ||
subgroup limit | ||
|
||
require parquet | ||
|
||
load | ||
CREATE TABLE other_table AS SELECT 337 i UNION ALL SELECT 948247 UNION ALL SELECT 17797934 UNION ALL SELECT 99999998 UNION ALL SELECT 99999999; | ||
COPY (SELECT * FROM range(50000000) t(i)) TO '${BENCHMARK_DIR}/integers1.parquet'; | ||
COPY (SELECT * FROM range(50000000, 100000000) t(i)) TO '${BENCHMARK_DIR}/integers2.parquet'; | ||
CREATE VIEW integers AS SELECT * FROM parquet_scan(['${BENCHMARK_DIR}/integers1.parquet', '${BENCHMARK_DIR}/integers2.parquet']); | ||
|
||
run | ||
SELECT * FROM integers WHERE i IN (SELECT * FROM other_table) LIMIT 4 | ||
|
||
result I | ||
337 | ||
948247 | ||
17797934 | ||
99999998 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include "duckdb/common/types/batched_chunk_collection.hpp" | ||
#include "duckdb/common/printer.hpp" | ||
|
||
namespace duckdb { | ||
|
||
BatchedChunkCollection::BatchedChunkCollection() { | ||
} | ||
|
||
void BatchedChunkCollection::Append(DataChunk &input, idx_t batch_index) { | ||
D_ASSERT(batch_index != DConstants::INVALID_INDEX); | ||
auto entry = data.find(batch_index); | ||
ChunkCollection *collection; | ||
if (entry == data.end()) { | ||
auto new_collection = make_unique<ChunkCollection>(); | ||
collection = new_collection.get(); | ||
data.insert(make_pair(batch_index, move(new_collection))); | ||
} else { | ||
collection = entry->second.get(); | ||
} | ||
collection->Append(input); | ||
} | ||
|
||
void BatchedChunkCollection::Merge(BatchedChunkCollection &other) { | ||
for (auto &entry : other.data) { | ||
if (data.find(entry.first) != data.end()) { | ||
throw InternalException( | ||
"BatchChunkCollection::Merge error - batch index %d is present in both collections. This occurs when " | ||
"batch indexes are not uniquely distributed over threads", | ||
entry.first); | ||
} | ||
data[entry.first] = move(entry.second); | ||
} | ||
other.data.clear(); | ||
} | ||
|
||
void BatchedChunkCollection::InitializeScan(BatchedChunkScanState &state) { | ||
state.iterator = data.begin(); | ||
state.chunk_index = 0; | ||
} | ||
|
||
void BatchedChunkCollection::Scan(BatchedChunkScanState &state, DataChunk &output) { | ||
while (state.iterator != data.end()) { | ||
// check if there is a chunk remaining in this collection | ||
auto collection = state.iterator->second.get(); | ||
if (state.chunk_index < collection->ChunkCount()) { | ||
// there is! increment the chunk count | ||
output.Reference(collection->GetChunk(state.chunk_index)); | ||
state.chunk_index++; | ||
return; | ||
} | ||
// there isn't! move to the next collection | ||
state.iterator++; | ||
state.chunk_index = 0; | ||
} | ||
} | ||
|
||
string BatchedChunkCollection::ToString() const { | ||
string result; | ||
result += "Batched Chunk Collection\n"; | ||
for (auto &entry : data) { | ||
result += "Batch Index - " + to_string(entry.first) + "\n"; | ||
result += entry.second->ToString() + "\n\n"; | ||
} | ||
return result; | ||
} | ||
|
||
void BatchedChunkCollection::Print() const { | ||
Printer::Print(ToString()); | ||
} | ||
|
||
} // namespace duckdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.