diff --git a/src/duckdb/generated_extension_loader_package_build.cpp b/src/duckdb/generated_extension_loader_package_build.cpp index 1c4ddd5fd..c7c1e9187 100644 --- a/src/duckdb/generated_extension_loader_package_build.cpp +++ b/src/duckdb/generated_extension_loader_package_build.cpp @@ -45,7 +45,7 @@ int32_t duckdb_extension_core_functions_describe(duckdb_extension_descriptor *de descriptor->version = 1; descriptor->name = "core_functions"; descriptor->extension_version = EXT_VERSION_CORE_FUNCTIONS; - descriptor->api_version = "v2.0.2-alpha57805"; + descriptor->api_version = "v2.0.2-alpha58209"; descriptor->entry_cpp = (void (*)(void))core_functions_duckdb_cpp_init; return 0; } @@ -78,7 +78,7 @@ int32_t duckdb_extension_parquet_describe(duckdb_extension_descriptor *descripto descriptor->version = 1; descriptor->name = "parquet"; descriptor->extension_version = EXT_VERSION_PARQUET; - descriptor->api_version = "v2.0.2-alpha57805"; + descriptor->api_version = "v2.0.2-alpha58209"; descriptor->entry_cpp = (void (*)(void))parquet_duckdb_cpp_init; return 0; } @@ -111,7 +111,7 @@ int32_t duckdb_extension_icu_describe(duckdb_extension_descriptor *descriptor) { descriptor->version = 1; descriptor->name = "icu"; descriptor->extension_version = EXT_VERSION_ICU; - descriptor->api_version = "v2.0.2-alpha57805"; + descriptor->api_version = "v2.0.2-alpha58209"; descriptor->entry_cpp = (void (*)(void))icu_duckdb_cpp_init; return 0; } @@ -144,7 +144,7 @@ int32_t duckdb_extension_json_describe(duckdb_extension_descriptor *descriptor) descriptor->version = 1; descriptor->name = "json"; descriptor->extension_version = EXT_VERSION_JSON; - descriptor->api_version = "v2.0.2-alpha57805"; + descriptor->api_version = "v2.0.2-alpha58209"; descriptor->entry_cpp = (void (*)(void))json_duckdb_cpp_init; return 0; } diff --git a/src/duckdb/src/function/table/version/pragma_version.cpp b/src/duckdb/src/function/table/version/pragma_version.cpp index c7cf4b1f9..04846c087 100644 --- a/src/duckdb/src/function/table/version/pragma_version.cpp +++ b/src/duckdb/src/function/table/version/pragma_version.cpp @@ -1,5 +1,5 @@ #ifndef DUCKDB_PATCH_VERSION -#define DUCKDB_PATCH_VERSION "2-alpha57805" +#define DUCKDB_PATCH_VERSION "2-alpha58209" #endif #ifndef DUCKDB_MINOR_VERSION #define DUCKDB_MINOR_VERSION 0 @@ -8,10 +8,10 @@ #define DUCKDB_MAJOR_VERSION 2 #endif #ifndef DUCKDB_VERSION -#define DUCKDB_VERSION "v2.0.2-alpha57805" +#define DUCKDB_VERSION "v2.0.2-alpha58209" #endif #ifndef DUCKDB_SOURCE_ID -#define DUCKDB_SOURCE_ID "33c12b9721" +#define DUCKDB_SOURCE_ID "16cfccddc4" #endif #include "duckdb/function/table/system_functions.hpp" #include "duckdb/main/database.hpp" diff --git a/src/duckdb/src/parallel/runtime_filter_schedule.cpp b/src/duckdb/src/parallel/runtime_filter_schedule.cpp index e13692990..1caa71e1f 100644 --- a/src/duckdb/src/parallel/runtime_filter_schedule.cpp +++ b/src/duckdb/src/parallel/runtime_filter_schedule.cpp @@ -23,6 +23,18 @@ static optional_ptr RuntimeFilterProducer(Pipeline &pipe } } +static bool IsSmallBuild(const PhysicalOperator &op) { + if (op.estimated_cardinality > DEFAULT_STANDARD_VECTOR_SIZE || op.IsSink()) { + return false; + } + for (auto &child : op.children) { + if (!IsSmallBuild(child.get())) { + return false; + } + } + return true; +} + static bool HasJoinSink(Pipeline &pipeline) { auto sink = pipeline.GetSink(); if (!sink) { @@ -128,7 +140,11 @@ static void ScheduleRuntimeFiltersInternal(PipelineSchedule &schedule, bool clea dependency_check = RuntimeFilterDependencyCheck(schedule); join_build_stages = CollectJoinBuildStages(schedule); } - reference_map_t> sources; + struct FilterSource { + idx_t stage_idx; + bool small_build_only; + }; + reference_map_t> sources; for (idx_t stage_idx = 0; add_edges && stage_idx < schedule.stages.size(); stage_idx++) { auto &stage = schedule.stages[stage_idx]; auto &pipeline = *stage.pipeline; @@ -143,12 +159,12 @@ static void ScheduleRuntimeFiltersInternal(PipelineSchedule &schedule, bool clea scan.function.global_initialization == TableFunctionInitialization::INITIALIZE_ON_SCHEDULE) { continue; } - if (!join_build_stages[stage_idx] && (!scan.table_filters || (!scan.table_filters->HasFilters() && - !scan.table_filters->HasMultiColumnFilters()))) { - sources[*scan.dynamic_filters].push_back(stage_idx); - } + const auto small_build_only = + join_build_stages[stage_idx] || + (scan.table_filters && (scan.table_filters->HasFilters() || scan.table_filters->HasMultiColumnFilters())); + sources[*scan.dynamic_filters].push_back({stage_idx, small_build_only}); for (auto &filters : scan.dynamic_filters->GetDisjunctionFilters()) { - sources[filters.get()].push_back(stage_idx); + sources[filters.get()].push_back({stage_idx, false}); } } @@ -157,6 +173,7 @@ static void ScheduleRuntimeFiltersInternal(PipelineSchedule &schedule, bool clea auto &publication = publications[producer]; auto build_estimate = producer.children[1].get().estimated_cardinality; auto probe_estimate = producer.children[0].get().estimated_cardinality; + const auto small_build = add_edges && IsSmallBuild(producer.children[1].get()); for (auto &target : producer.filter_pushdown->probe_info) { if (clear_filters) { // Clear previous executions before any scan can take its filter snapshot. @@ -170,7 +187,12 @@ static void ScheduleRuntimeFiltersInternal(PipelineSchedule &schedule, bool clea build_estimate >= MaxValue(probe_estimate, target.estimated_scan_cardinality)) { continue; } - for (auto execution : source->second) { + for (auto &filter_source : source->second) { + // A small aggregate or join result can still require expensive inputs. + if (filter_source.small_build_only && !small_build) { + continue; + } + auto execution = filter_source.stage_idx; if (dependency_check.TryAddDependency(execution, publication[0])) { schedule.TryAddDependency(execution, publication[0]); }