diff --git a/.github/workflows/linux-32bit-build-and-test.yaml b/.github/workflows/linux-32bit-build-and-test.yaml index c66d99b9bbf..620f509971d 100644 --- a/.github/workflows/linux-32bit-build-and-test.yaml +++ b/.github/workflows/linux-32bit-build-and-test.yaml @@ -47,7 +47,9 @@ jobs: CC: clang-14 CXX: clang++-14 DEBIAN_FRONTEND: noninteractive - IGNORES: "append-* transparent_decompression-* transparent_decompress_chunk-* pg_dump telemetry bgw_db_scheduler* hypercore_vacuum" + # vectorized_aggregation has different output on i386 because int8 is by + # reference and currently it cannot be used for vectorized hash grouping. + IGNORES: "append-* transparent_decompression-* transparent_decompress_chunk-* pg_dump telemetry bgw_db_scheduler* hypercore_vacuum vectorized_aggregation" SKIPS: chunk_adaptive histogram_test-* EXTENSIONS: "postgres_fdw test_decoding pageinspect pgstattuple" strategy: diff --git a/.unreleased/vectorized-grouping-one-fixed b/.unreleased/vectorized-grouping-one-fixed new file mode 100644 index 00000000000..47f74a45210 --- /dev/null +++ b/.unreleased/vectorized-grouping-one-fixed @@ -0,0 +1 @@ +Implements: #7341 Vectorized aggregation with grouping by one fixed-size by-value compressed column (such as arithmetic types). diff --git a/tsl/src/nodes/vector_agg/CMakeLists.txt b/tsl/src/nodes/vector_agg/CMakeLists.txt index e621571d5f5..cf69755c077 100644 --- a/tsl/src/nodes/vector_agg/CMakeLists.txt +++ b/tsl/src/nodes/vector_agg/CMakeLists.txt @@ -1,6 +1,8 @@ add_subdirectory(function) +add_subdirectory(hashing) set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/exec.c ${CMAKE_CURRENT_SOURCE_DIR}/grouping_policy_batch.c + ${CMAKE_CURRENT_SOURCE_DIR}/grouping_policy_hash.c ${CMAKE_CURRENT_SOURCE_DIR}/plan.c) target_sources(${TSL_LIBRARY_NAME} PRIVATE ${SOURCES}) diff --git a/tsl/src/nodes/vector_agg/exec.c b/tsl/src/nodes/vector_agg/exec.c index 68b6c244a05..6d9b08fee65 100644 --- a/tsl/src/nodes/vector_agg/exec.c +++ b/tsl/src/nodes/vector_agg/exec.c @@ -21,6 +21,7 @@ #include "nodes/decompress_chunk/exec.h" #include "nodes/decompress_chunk/vector_quals.h" #include "nodes/vector_agg.h" +#include "nodes/vector_agg/plan.h" static int get_input_offset(DecompressChunkState *decompress_state, Var *var) @@ -179,17 +180,41 @@ vector_agg_begin(CustomScanState *node, EState *estate, int eflags) Var *var = castNode(Var, tlentry->expr); col->input_offset = get_input_offset(decompress_state, var); + DecompressContext *dcontext = &decompress_state->decompress_context; + CompressionColumnDescription *desc = + &dcontext->compressed_chunk_columns[col->input_offset]; + col->value_bytes = desc->value_bytes; } } /* - * Currently the only grouping policy we use is per-batch grouping. + * Create the grouping policy chosen at plan time. */ - vector_agg_state->grouping = - create_grouping_policy_batch(vector_agg_state->num_agg_defs, - vector_agg_state->agg_defs, - vector_agg_state->num_grouping_columns, - vector_agg_state->grouping_columns); + const VectorAggGroupingType grouping_type = + intVal(list_nth(cscan->custom_private, VASI_GroupingType)); + if (grouping_type == VAGT_Batch) + { + /* + * Per-batch grouping. + */ + vector_agg_state->grouping = + create_grouping_policy_batch(vector_agg_state->num_agg_defs, + vector_agg_state->agg_defs, + vector_agg_state->num_grouping_columns, + vector_agg_state->grouping_columns); + } + else + { + /* + * Hash grouping. + */ + vector_agg_state->grouping = + create_grouping_policy_hash(vector_agg_state->num_agg_defs, + vector_agg_state->agg_defs, + vector_agg_state->num_grouping_columns, + vector_agg_state->grouping_columns, + grouping_type); + } } static void diff --git a/tsl/src/nodes/vector_agg/exec.h b/tsl/src/nodes/vector_agg/exec.h index e5e9775ebb9..8c2e5d53d00 100644 --- a/tsl/src/nodes/vector_agg/exec.h +++ b/tsl/src/nodes/vector_agg/exec.h @@ -26,6 +26,7 @@ typedef struct GroupingColumn { int input_offset; int output_offset; + int value_bytes; } GroupingColumn; typedef struct diff --git a/tsl/src/nodes/vector_agg/function/agg_many_vector_helper.c b/tsl/src/nodes/vector_agg/function/agg_many_vector_helper.c new file mode 100644 index 00000000000..192fad35017 --- /dev/null +++ b/tsl/src/nodes/vector_agg/function/agg_many_vector_helper.c @@ -0,0 +1,58 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ + +/* + * A generic implementation of adding the given batch to many aggregate function + * states with given offsets. Used for hash aggregation, and builds on the + * FUNCTION_NAME(one) function, which adds one passing non-null row to the given + * aggregate function state. + */ +static pg_attribute_always_inline void +FUNCTION_NAME(many_vector_impl)(void *restrict agg_states, const uint32 *offsets, + const uint64 *filter, int start_row, int end_row, + const ArrowArray *vector, MemoryContext agg_extra_mctx) +{ + FUNCTION_NAME(state) *restrict states = (FUNCTION_NAME(state) *) agg_states; + const CTYPE *values = vector->buffers[1]; + MemoryContext old = MemoryContextSwitchTo(agg_extra_mctx); + for (int row = start_row; row < end_row; row++) + { + const CTYPE value = values[row]; + FUNCTION_NAME(state) *restrict state = &states[offsets[row]]; + if (arrow_row_is_valid(filter, row)) + { + Assert(offsets[row] != 0); + FUNCTION_NAME(one)(state, value); + } + } + MemoryContextSwitchTo(old); +} + +static pg_noinline void +FUNCTION_NAME(many_vector_all_valid)(void *restrict agg_states, const uint32 *offsets, + int start_row, int end_row, const ArrowArray *vector, + MemoryContext agg_extra_mctx) +{ + FUNCTION_NAME(many_vector_impl) + (agg_states, offsets, NULL, start_row, end_row, vector, agg_extra_mctx); +} + +static void +FUNCTION_NAME(many_vector)(void *restrict agg_states, const uint32 *offsets, const uint64 *filter, + int start_row, int end_row, const ArrowArray *vector, + MemoryContext agg_extra_mctx) +{ + if (filter == NULL) + { + FUNCTION_NAME(many_vector_all_valid) + (agg_states, offsets, start_row, end_row, vector, agg_extra_mctx); + } + else + { + FUNCTION_NAME(many_vector_impl) + (agg_states, offsets, filter, start_row, end_row, vector, agg_extra_mctx); + } +} diff --git a/tsl/src/nodes/vector_agg/function/float48_accum_single.c b/tsl/src/nodes/vector_agg/function/float48_accum_single.c index 0bdcd928593..eba81ee687b 100644 --- a/tsl/src/nodes/vector_agg/function/float48_accum_single.c +++ b/tsl/src/nodes/vector_agg/function/float48_accum_single.c @@ -316,6 +316,7 @@ FUNCTION_NAME(one)(void *restrict agg_state, const CTYPE value) state->Sx = newSx; } +#include "agg_many_vector_helper.c" #include "agg_scalar_helper.c" #include "agg_vector_validity_helper.c" @@ -325,6 +326,7 @@ VectorAggFunctions FUNCTION_NAME(argdef) = { .agg_emit = FUNCTION_NAME(emit), .agg_scalar = FUNCTION_NAME(scalar), .agg_vector = FUNCTION_NAME(vector), + .agg_many_vector = FUNCTION_NAME(many_vector), }; #undef UPDATE #undef COMBINE diff --git a/tsl/src/nodes/vector_agg/function/functions.c b/tsl/src/nodes/vector_agg/function/functions.c index 1cd08e7cd25..bb6ef7cf074 100644 --- a/tsl/src/nodes/vector_agg/function/functions.c +++ b/tsl/src/nodes/vector_agg/function/functions.c @@ -52,11 +52,70 @@ count_star_scalar(void *agg_state, Datum constvalue, bool constisnull, int n, state->count += n; } +static pg_attribute_always_inline void +count_star_many_scalar_impl(void *restrict agg_states, const uint32 *offsets, const uint64 *filter, + int start_row, int end_row, Datum constvalue, bool constisnull, + MemoryContext agg_extra_mctx) +{ + CountState *states = (CountState *) agg_states; + for (int row = start_row; row < end_row; row++) + { + if (arrow_row_is_valid(filter, row)) + { + states[offsets[row]].count++; + } + } +} + +static pg_noinline void +count_star_many_scalar_nofilter(void *restrict agg_states, const uint32 *offsets, int start_row, + int end_row, Datum constvalue, bool constisnull, + MemoryContext agg_extra_mctx) +{ + count_star_many_scalar_impl(agg_states, + offsets, + NULL, + start_row, + end_row, + constvalue, + constisnull, + agg_extra_mctx); +} + +static void +count_star_many_scalar(void *restrict agg_states, const uint32 *offsets, const uint64 *filter, + int start_row, int end_row, Datum constvalue, bool constisnull, + MemoryContext agg_extra_mctx) +{ + if (filter == NULL) + { + count_star_many_scalar_nofilter(agg_states, + offsets, + start_row, + end_row, + constvalue, + constisnull, + agg_extra_mctx); + } + else + { + count_star_many_scalar_impl(agg_states, + offsets, + filter, + start_row, + end_row, + constvalue, + constisnull, + agg_extra_mctx); + } +} + VectorAggFunctions count_star_agg = { .state_bytes = sizeof(CountState), .agg_init = count_init, .agg_scalar = count_star_scalar, .agg_emit = count_emit, + .agg_many_scalar = count_star_many_scalar, }; /* @@ -110,12 +169,28 @@ count_any_vector(void *agg_state, const ArrowArray *vector, const uint64 *filter } } +static void +count_any_many_vector(void *restrict agg_states, const uint32 *offsets, const uint64 *filter, + int start_row, int end_row, const ArrowArray *vector, + MemoryContext agg_extra_mctx) +{ + for (int row = start_row; row < end_row; row++) + { + CountState *state = (offsets[row] + (CountState *) agg_states); + if (arrow_row_is_valid(filter, row)) + { + state->count++; + } + } +} + VectorAggFunctions count_any_agg = { .state_bytes = sizeof(CountState), .agg_init = count_init, .agg_emit = count_emit, .agg_scalar = count_any_scalar, .agg_vector = count_any_vector, + .agg_many_vector = count_any_many_vector, }; /* diff --git a/tsl/src/nodes/vector_agg/function/functions.h b/tsl/src/nodes/vector_agg/function/functions.h index cd05fe4ea5a..5845333d79d 100644 --- a/tsl/src/nodes/vector_agg/function/functions.h +++ b/tsl/src/nodes/vector_agg/function/functions.h @@ -37,6 +37,22 @@ typedef struct void (*agg_scalar)(void *restrict agg_state, Datum constvalue, bool constisnull, int n, MemoryContext agg_extra_mctx); + /* + * Add the rows of the given arrow array to aggregate function states given + * by the respective offsets. + */ + void (*agg_many_vector)(void *restrict agg_states, const uint32 *offsets, const uint64 *filter, + int start_row, int end_row, const ArrowArray *vector, + MemoryContext agg_extra_mctx); + + /* + * Same as above, but for a scalar argument. This is mostly important for + * count(*) and can be NULL. + */ + void (*agg_many_scalar)(void *restrict agg_states, const uint32 *offsets, const uint64 *filter, + int start_row, int end_row, Datum constvalue, bool constisnull, + MemoryContext agg_extra_mctx); + /* Emit a partial aggregation result. */ void (*agg_emit)(void *restrict agg_state, Datum *out_result, bool *out_isnull); } VectorAggFunctions; diff --git a/tsl/src/nodes/vector_agg/function/int128_accum_single.c b/tsl/src/nodes/vector_agg/function/int128_accum_single.c index d94ead56cd3..2e0b9ca25f2 100644 --- a/tsl/src/nodes/vector_agg/function/int128_accum_single.c +++ b/tsl/src/nodes/vector_agg/function/int128_accum_single.c @@ -110,6 +110,7 @@ FUNCTION_NAME(one)(void *restrict agg_state, const CTYPE value) #endif } +#include "agg_many_vector_helper.c" #include "agg_scalar_helper.c" #include "agg_vector_validity_helper.c" @@ -119,6 +120,7 @@ VectorAggFunctions FUNCTION_NAME(argdef) = { .agg_emit = FUNCTION_NAME(emit), .agg_scalar = FUNCTION_NAME(scalar), .agg_vector = FUNCTION_NAME(vector), + .agg_many_vector = FUNCTION_NAME(many_vector), }; #endif diff --git a/tsl/src/nodes/vector_agg/function/int24_avg_accum_single.c b/tsl/src/nodes/vector_agg/function/int24_avg_accum_single.c index 9fbf950330a..fb90f116255 100644 --- a/tsl/src/nodes/vector_agg/function/int24_avg_accum_single.c +++ b/tsl/src/nodes/vector_agg/function/int24_avg_accum_single.c @@ -38,6 +38,7 @@ FUNCTION_NAME(one)(void *restrict agg_state, const CTYPE value) state->sum += value; } +#include "agg_many_vector_helper.c" #include "agg_scalar_helper.c" #include "agg_vector_validity_helper.c" @@ -47,6 +48,7 @@ VectorAggFunctions FUNCTION_NAME(argdef) = { .agg_emit = int24_avg_accum_emit, .agg_scalar = FUNCTION_NAME(scalar), .agg_vector = FUNCTION_NAME(vector), + .agg_many_vector = FUNCTION_NAME(many_vector), }; #endif diff --git a/tsl/src/nodes/vector_agg/function/int24_sum_single.c b/tsl/src/nodes/vector_agg/function/int24_sum_single.c index ccf1e98cbf8..95320240e75 100644 --- a/tsl/src/nodes/vector_agg/function/int24_sum_single.c +++ b/tsl/src/nodes/vector_agg/function/int24_sum_single.c @@ -61,6 +61,7 @@ FUNCTION_NAME(one)(void *restrict agg_state, const CTYPE value) typedef Int24SumState FUNCTION_NAME(state); +#include "agg_many_vector_helper.c" #include "agg_scalar_helper.c" #include "agg_vector_validity_helper.c" @@ -70,6 +71,7 @@ VectorAggFunctions FUNCTION_NAME(argdef) = { .agg_emit = int_sum_emit, .agg_scalar = FUNCTION_NAME(scalar), .agg_vector = FUNCTION_NAME(vector), + .agg_many_vector = FUNCTION_NAME(many_vector), }; #endif diff --git a/tsl/src/nodes/vector_agg/function/minmax_arithmetic_single.c b/tsl/src/nodes/vector_agg/function/minmax_arithmetic_single.c index e21658c4dfe..e64dab8e20c 100644 --- a/tsl/src/nodes/vector_agg/function/minmax_arithmetic_single.c +++ b/tsl/src/nodes/vector_agg/function/minmax_arithmetic_single.c @@ -58,6 +58,7 @@ FUNCTION_NAME(one)(void *restrict agg_state, const CTYPE value) } } +#include "agg_many_vector_helper.c" #include "agg_scalar_helper.c" #include "agg_vector_validity_helper.c" @@ -67,6 +68,7 @@ VectorAggFunctions FUNCTION_NAME(argdef) = { .agg_emit = minmax_emit, .agg_scalar = FUNCTION_NAME(scalar), .agg_vector = FUNCTION_NAME(vector), + .agg_many_vector = FUNCTION_NAME(many_vector), }; #endif diff --git a/tsl/src/nodes/vector_agg/function/sum_float_single.c b/tsl/src/nodes/vector_agg/function/sum_float_single.c index cce0d6f42c2..6f3002fd12f 100644 --- a/tsl/src/nodes/vector_agg/function/sum_float_single.c +++ b/tsl/src/nodes/vector_agg/function/sum_float_single.c @@ -91,6 +91,7 @@ FUNCTION_NAME(one)(void *restrict agg_state, const CTYPE value) state->result += value; } +#include "agg_many_vector_helper.c" #include "agg_scalar_helper.c" #include "agg_vector_validity_helper.c" @@ -100,6 +101,7 @@ VectorAggFunctions FUNCTION_NAME(argdef) = { .agg_emit = FUNCTION_NAME(emit), .agg_scalar = FUNCTION_NAME(scalar), .agg_vector = FUNCTION_NAME(vector), + .agg_many_vector = FUNCTION_NAME(many_vector), }; #endif diff --git a/tsl/src/nodes/vector_agg/grouping_policy.h b/tsl/src/nodes/vector_agg/grouping_policy.h index 98bcbbed315..30a6dfd4690 100644 --- a/tsl/src/nodes/vector_agg/grouping_policy.h +++ b/tsl/src/nodes/vector_agg/grouping_policy.h @@ -28,6 +28,9 @@ typedef struct GroupingPolicy */ void (*gp_reset)(GroupingPolicy *gp); + /* + * Aggregate a single compressed batch. + */ void (*gp_add_batch)(GroupingPolicy *gp, DecompressBatchState *batch_state); /* @@ -51,6 +54,24 @@ typedef struct GroupingPolicy char *(*gp_explain)(GroupingPolicy *gp); } GroupingPolicy; +/* + * The various types of grouping we might use, as determined at planning time. + * The hashed subtypes are all implemented by hash grouping policy. + */ +typedef enum +{ + VAGT_Invalid, + VAGT_Batch, + VAGT_HashSingleFixed2, + VAGT_HashSingleFixed4, + VAGT_HashSingleFixed8 +} VectorAggGroupingType; + extern GroupingPolicy *create_grouping_policy_batch(int num_agg_defs, VectorAggDef *agg_defs, int num_grouping_columns, GroupingColumn *grouping_columns); + +extern GroupingPolicy *create_grouping_policy_hash(int num_agg_defs, VectorAggDef *agg_defs, + int num_grouping_columns, + GroupingColumn *grouping_columns, + VectorAggGroupingType grouping_type); diff --git a/tsl/src/nodes/vector_agg/grouping_policy_hash.c b/tsl/src/nodes/vector_agg/grouping_policy_hash.c new file mode 100644 index 00000000000..05a8e13d474 --- /dev/null +++ b/tsl/src/nodes/vector_agg/grouping_policy_hash.c @@ -0,0 +1,433 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ + +/* + * This grouping policy groups the rows using a hash table. Currently it only + * supports a single fixed-size by-value compressed column that fits into a Datum. + */ + +#include + +#include +#include + +#include "grouping_policy.h" + +#include "nodes/decompress_chunk/compressed_batch.h" +#include "nodes/vector_agg/exec.h" + +#include "grouping_policy_hash.h" + +#ifdef USE_FLOAT8_BYVAL +#define DEBUG_LOG(MSG, ...) elog(DEBUG3, MSG, __VA_ARGS__) +#else +/* + * On 32-bit platforms we'd have to use the cross-platform int width printf + * specifiers which are really unreadable. + */ +#define DEBUG_LOG(...) +#endif + +extern HashingStrategy single_fixed_2_strategy; +extern HashingStrategy single_fixed_4_strategy; +extern HashingStrategy single_fixed_8_strategy; + +static const GroupingPolicy grouping_policy_hash_functions; + +GroupingPolicy * +create_grouping_policy_hash(int num_agg_defs, VectorAggDef *agg_defs, int num_grouping_columns, + GroupingColumn *grouping_columns, VectorAggGroupingType grouping_type) +{ + GroupingPolicyHash *policy = palloc0(sizeof(GroupingPolicyHash)); + policy->funcs = grouping_policy_hash_functions; + + policy->num_grouping_columns = num_grouping_columns; + policy->grouping_columns = grouping_columns; + + policy->agg_extra_mctx = + AllocSetContextCreate(CurrentMemoryContext, "agg extra", ALLOCSET_DEFAULT_SIZES); + policy->num_allocated_per_key_agg_states = TARGET_COMPRESSED_BATCH_SIZE; + + policy->num_agg_defs = num_agg_defs; + policy->agg_defs = agg_defs; + + policy->per_agg_per_key_states = + palloc(sizeof(*policy->per_agg_per_key_states) * policy->num_agg_defs); + for (int i = 0; i < policy->num_agg_defs; i++) + { + const VectorAggDef *agg_def = &policy->agg_defs[i]; + policy->per_agg_per_key_states[i] = + palloc(agg_def->func.state_bytes * policy->num_allocated_per_key_agg_states); + } + + policy->current_batch_grouping_column_values = + palloc(sizeof(CompressedColumnValues) * num_grouping_columns); + + switch (grouping_type) + { + case VAGT_HashSingleFixed8: + policy->hashing = single_fixed_8_strategy; + break; + case VAGT_HashSingleFixed4: + policy->hashing = single_fixed_4_strategy; + break; + case VAGT_HashSingleFixed2: + policy->hashing = single_fixed_2_strategy; + break; + default: + Ensure(false, "failed to determine the hashing strategy"); + break; + } + + policy->hashing.init(&policy->hashing, policy); + + return &policy->funcs; +} + +static void +gp_hash_reset(GroupingPolicy *obj) +{ + GroupingPolicyHash *policy = (GroupingPolicyHash *) obj; + + MemoryContextReset(policy->agg_extra_mctx); + + policy->returning_results = false; + + policy->hashing.reset(&policy->hashing); + + policy->last_used_key_index = 0; + + policy->stat_input_valid_rows = 0; + policy->stat_input_total_rows = 0; + policy->stat_consecutive_keys = 0; +} + +static void +compute_single_aggregate(GroupingPolicyHash *policy, const DecompressBatchState *batch_state, + int start_row, int end_row, const VectorAggDef *agg_def, void *agg_states) +{ + const ArrowArray *arg_arrow = NULL; + const uint64 *arg_validity_bitmap = NULL; + Datum arg_datum = 0; + bool arg_isnull = true; + + const uint32 *offsets = policy->key_index_for_row; + MemoryContext agg_extra_mctx = policy->agg_extra_mctx; + + /* + * We have functions with one argument, and one function with no arguments + * (count(*)). Collect the arguments. + */ + if (agg_def->input_offset >= 0) + { + const CompressedColumnValues *values = + &batch_state->compressed_columns[agg_def->input_offset]; + Assert(values->decompression_type != DT_Invalid); + Assert(values->decompression_type != DT_Iterator); + + if (values->arrow != NULL) + { + arg_arrow = values->arrow; + arg_validity_bitmap = values->buffers[0]; + } + else + { + Assert(values->decompression_type == DT_Scalar); + arg_datum = *values->output_value; + arg_isnull = *values->output_isnull; + } + } + + /* + * Compute the unified validity bitmap. + */ + const size_t num_words = (batch_state->total_batch_rows + 63) / 64; + const uint64 *filter = arrow_combine_validity(num_words, + policy->tmp_filter, + agg_def->filter_result, + batch_state->vector_qual_result, + arg_validity_bitmap); + + /* + * Now call the function. + */ + if (arg_arrow != NULL) + { + /* Arrow argument. */ + agg_def->func.agg_many_vector(agg_states, + offsets, + filter, + start_row, + end_row, + arg_arrow, + agg_extra_mctx); + } + else + { + /* + * Scalar argument, or count(*). The latter has an optimized + * implementation. + */ + if (agg_def->func.agg_many_scalar != NULL) + { + agg_def->func.agg_many_scalar(agg_states, + offsets, + filter, + start_row, + end_row, + arg_datum, + arg_isnull, + agg_extra_mctx); + } + else + { + for (int i = start_row; i < end_row; i++) + { + if (!arrow_row_is_valid(filter, i)) + { + continue; + } + + void *state = (offsets[i] * agg_def->func.state_bytes + (char *) agg_states); + agg_def->func.agg_scalar(state, arg_datum, arg_isnull, 1, agg_extra_mctx); + } + } + } +} + +static void +add_one_range(GroupingPolicyHash *policy, DecompressBatchState *batch_state, const int start_row, + const int end_row) +{ + const int num_fns = policy->num_agg_defs; + + Assert(start_row < end_row); + Assert(end_row <= batch_state->total_batch_rows); + + /* + * Remember which aggregation states have already existed, and which we + * have to initialize. State index zero is invalid. + */ + const uint32 last_initialized_key_index = policy->last_used_key_index; + Assert(last_initialized_key_index <= policy->num_allocated_per_key_agg_states); + + /* + * Match rows to aggregation states using a hash table. + */ + Assert((size_t) end_row <= policy->num_key_index_for_row); + policy->hashing.fill_offsets(policy, batch_state, start_row, end_row); + + /* + * Process the aggregate function states. We are processing single aggregate + * function for the entire batch to improve the memory locality. + */ + const uint64 new_aggstate_rows = policy->num_allocated_per_key_agg_states * 2 + 1; + for (int agg_index = 0; agg_index < num_fns; agg_index++) + { + const VectorAggDef *agg_def = &policy->agg_defs[agg_index]; + /* + * If we added new keys, initialize the aggregate function states for + * them. + */ + if (policy->last_used_key_index > last_initialized_key_index) + { + /* + * If the aggregate function states don't fit into the existing + * storage, reallocate it. + */ + if (policy->last_used_key_index >= policy->num_allocated_per_key_agg_states) + { + policy->per_agg_per_key_states[agg_index] = + repalloc(policy->per_agg_per_key_states[agg_index], + new_aggstate_rows * agg_def->func.state_bytes); + } + + void *first_uninitialized_state = + agg_def->func.state_bytes * (last_initialized_key_index + 1) + + (char *) policy->per_agg_per_key_states[agg_index]; + agg_def->func.agg_init(first_uninitialized_state, + policy->last_used_key_index - last_initialized_key_index); + } + + /* + * Add this batch to the states of this aggregate function. + */ + compute_single_aggregate(policy, + batch_state, + start_row, + end_row, + agg_def, + policy->per_agg_per_key_states[agg_index]); + } + + /* + * Record the newly allocated number of aggregate function states in case we + * had to reallocate. + */ + if (policy->last_used_key_index >= policy->num_allocated_per_key_agg_states) + { + Assert(new_aggstate_rows > policy->num_allocated_per_key_agg_states); + policy->num_allocated_per_key_agg_states = new_aggstate_rows; + } +} + +static void +gp_hash_add_batch(GroupingPolicy *gp, DecompressBatchState *batch_state) +{ + GroupingPolicyHash *policy = (GroupingPolicyHash *) gp; + + Assert(!policy->returning_results); + + const int n = batch_state->total_batch_rows; + + /* + * Initialize the array for storing the aggregate state offsets corresponding + * to a given batch row. We don't need the offsets for the previous batch + * that are currently stored there, so we don't need to use repalloc. + */ + if ((size_t) n > policy->num_key_index_for_row) + { + if (policy->key_index_for_row != NULL) + { + pfree(policy->key_index_for_row); + } + policy->num_key_index_for_row = n; + policy->key_index_for_row = + palloc(sizeof(policy->key_index_for_row[0]) * policy->num_key_index_for_row); + } + memset(policy->key_index_for_row, 0, n * sizeof(policy->key_index_for_row[0])); + + /* + * Allocate the temporary filter array for computing the combined results of + * batch filter, aggregate filter and column validity. + */ + const size_t num_words = (n + 63) / 64; + if (num_words > policy->num_tmp_filter_words) + { + policy->tmp_filter = palloc(sizeof(*policy->tmp_filter) * (num_words * 2 + 1)); + policy->num_tmp_filter_words = (num_words * 2 + 1); + } + + /* + * Arrange the input compressed columns in the order of grouping columns. + */ + for (int i = 0; i < policy->num_grouping_columns; i++) + { + const GroupingColumn *def = &policy->grouping_columns[i]; + const CompressedColumnValues *values = &batch_state->compressed_columns[def->input_offset]; + policy->current_batch_grouping_column_values[i] = *values; + } + + /* + * Call the per-batch initialization function of the hashing strategy. + */ + + policy->hashing.prepare_for_batch(policy, batch_state); + + /* + * Add the batch rows to aggregate function states. + */ + const uint64_t *restrict filter = batch_state->vector_qual_result; + add_one_range(policy, batch_state, 0, n); + + policy->stat_input_total_rows += batch_state->total_batch_rows; + policy->stat_input_valid_rows += arrow_num_valid(filter, batch_state->total_batch_rows); +} + +static bool +gp_hash_should_emit(GroupingPolicy *gp) +{ + GroupingPolicyHash *policy = (GroupingPolicyHash *) gp; + + if (policy->last_used_key_index > UINT32_MAX - GLOBAL_MAX_ROWS_PER_COMPRESSION) + { + /* + * The max valid key index is UINT32_MAX, so we have to spill if the next + * batch can possibly lead to key index overflow. + */ + return true; + } + + /* + * Don't grow the hash table cardinality too much, otherwise we become bound + * by memory reads. In general, when this first stage of grouping doesn't + * significantly reduce the cardinality, it becomes pure overhead and the + * work will be done by the final Postgres aggregation, so we should bail + * out early here. + */ + return policy->hashing.get_size_bytes(&policy->hashing) > 512 * 1024; +} + +static bool +gp_hash_do_emit(GroupingPolicy *gp, TupleTableSlot *aggregated_slot) +{ + GroupingPolicyHash *policy = (GroupingPolicyHash *) gp; + + if (!policy->returning_results) + { + policy->returning_results = true; + policy->last_returned_key = 1; + + const float keys = policy->last_used_key_index; + if (keys > 0) + { + DEBUG_LOG("spill after %ld input, %ld valid, %ld bulk filtered, %ld cons, %.0f keys, " + "%f ratio, %ld curctx bytes, %ld aggstate bytes", + policy->stat_input_total_rows, + policy->stat_input_valid_rows, + 0UL, + policy->stat_consecutive_keys, + keys, + policy->stat_input_valid_rows / keys, + MemoryContextMemAllocated(CurrentMemoryContext, false), + MemoryContextMemAllocated(policy->agg_extra_mctx, false)); + } + } + else + { + policy->last_returned_key++; + } + + const uint32 current_key = policy->last_returned_key; + const uint32 keys_end = policy->last_used_key_index + 1; + if (current_key >= keys_end) + { + policy->returning_results = false; + return false; + } + + const int naggs = policy->num_agg_defs; + for (int i = 0; i < naggs; i++) + { + const VectorAggDef *agg_def = &policy->agg_defs[i]; + void *agg_states = policy->per_agg_per_key_states[i]; + void *agg_state = current_key * agg_def->func.state_bytes + (char *) agg_states; + agg_def->func.agg_emit(agg_state, + &aggregated_slot->tts_values[agg_def->output_offset], + &aggregated_slot->tts_isnull[agg_def->output_offset]); + } + + policy->hashing.emit_key(policy, current_key, aggregated_slot); + + DEBUG_PRINT("%p: output key index %d\n", policy, current_key); + + return true; +} + +static char * +gp_hash_explain(GroupingPolicy *gp) +{ + GroupingPolicyHash *policy = (GroupingPolicyHash *) gp; + return psprintf("hashed with %s key", policy->hashing.explain_name); +} + +static const GroupingPolicy grouping_policy_hash_functions = { + .gp_reset = gp_hash_reset, + .gp_add_batch = gp_hash_add_batch, + .gp_should_emit = gp_hash_should_emit, + .gp_do_emit = gp_hash_do_emit, + .gp_explain = gp_hash_explain, +}; diff --git a/tsl/src/nodes/vector_agg/grouping_policy_hash.h b/tsl/src/nodes/vector_agg/grouping_policy_hash.h new file mode 100644 index 00000000000..3fc0016b444 --- /dev/null +++ b/tsl/src/nodes/vector_agg/grouping_policy_hash.h @@ -0,0 +1,138 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ +#pragma once + +#include + +#include + +#include "grouping_policy.h" + +#include "nodes/decompress_chunk/compressed_batch.h" + +#include "hashing/hashing_strategy.h" + +typedef struct GroupingPolicyHash GroupingPolicyHash; + +/* + * Hash grouping policy. + * + * The grouping and aggregation is performed as follows: + * + * 0) The grouping policy keeps track of the unique grouping keys seen in + * the input rows, and the states of aggregate functions for each key. This + * spans multiple input compressed batches, and is reset after the partial + * aggregation results are emitted. + * + * 1) For each row of the new compressed batch, we obtain an index that + * uniquely identifies its grouping key. This is done by matching the row's + * grouping columns to the hash table recording the unique grouping keys and + * their respective indexes. It is performed in bulk for all rows of the batch, + * to improve memory locality. The details of this are managed by the hashing + * strategy. + * + * 2) The key indexes are used to locate the aggregate function states + * corresponding to a given row's key, and update it. This is done in bulk for all + * rows of the batch, and for each aggregate function separately, to generate + * simpler and potentially vectorizable code, and improve memory locality. + * + * 3) After the input has ended, or if the memory limit is reached, the partial + * results are emitted into the output slot. This is done in the order of unique + * grouping key indexes, thereby preserving the incoming key order. This + * guarantees that this policy works correctly even in a Partial GroupAggregate + * node, even though it's not optimal performance-wise. + */ +typedef struct GroupingPolicyHash +{ + /* + * We're using data inheritance from the GroupingPolicy. + */ + GroupingPolicy funcs; + + /* + * Aggregate function definitions. + */ + int num_agg_defs; + const VectorAggDef *restrict agg_defs; + + /* + * Grouping column definitions. + */ + int num_grouping_columns; + const GroupingColumn *restrict grouping_columns; + + /* + * The values of the grouping columns picked from the compressed batch and + * arranged in the order of grouping column definitions. + */ + CompressedColumnValues *restrict current_batch_grouping_column_values; + + /* + * Hashing strategy that is responsible for mapping the rows to the unique + * indexes of their grouping keys. + */ + HashingStrategy hashing; + + /* + * The last used index of an unique grouping key. Key index 0 is invalid. + */ + uint32 last_used_key_index; + + /* + * Temporary storage of unique indexes of keys corresponding to a given row + * of the compressed batch that is currently being aggregated. We keep it in + * the policy because it is potentially too big to keep on stack, and we + * don't want to reallocate it for each batch. + */ + uint32 *restrict key_index_for_row; + uint64 num_key_index_for_row; + + /* + * The temporary filter bitmap we use to combine the results of the + * vectorized filters in WHERE, validity of the aggregate function argument, + * and the aggregate FILTER clause. It is then used by the aggregate + * function implementation to filter out the rows that don't pass. + */ + uint64 *tmp_filter; + uint64 num_tmp_filter_words; + + /* + * Aggregate function states. Each element is an array of states for the + * respective function from agg_defs. These arrays are indexed by the unique + * grouping key indexes. The key index 0 is invalid, so the corresponding + * states are unused. + * The states of each aggregate function are stored separately and + * contiguously, to achieve better memory locality when updating them. + */ + void **per_agg_per_key_states; + uint64 num_allocated_per_key_agg_states; + + /* + * A memory context for aggregate functions to allocate additional data, + * i.e. if they store strings or float8 datum on 32-bit systems. Valid until + * the grouping policy is reset. + */ + MemoryContext agg_extra_mctx; + + /* + * Whether we are in the mode of returning the partial aggregation results. + * If we are, track the index of the last returned grouping key. + */ + bool returning_results; + uint32 last_returned_key; + + /* + * Some statistics for debugging. + */ + uint64 stat_input_total_rows; + uint64 stat_input_valid_rows; + uint64 stat_consecutive_keys; +} GroupingPolicyHash; + +//#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__) +#ifndef DEBUG_PRINT +#define DEBUG_PRINT(...) +#endif diff --git a/tsl/src/nodes/vector_agg/hashing/CMakeLists.txt b/tsl/src/nodes/vector_agg/hashing/CMakeLists.txt new file mode 100644 index 00000000000..c6ff65f65ca --- /dev/null +++ b/tsl/src/nodes/vector_agg/hashing/CMakeLists.txt @@ -0,0 +1,6 @@ +set(SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/hash_strategy_single_fixed_2.c + ${CMAKE_CURRENT_SOURCE_DIR}/hash_strategy_single_fixed_4.c + ${CMAKE_CURRENT_SOURCE_DIR}/hash_strategy_single_fixed_8.c + ${CMAKE_CURRENT_SOURCE_DIR}/hash_strategy_common.c) +target_sources(${TSL_LIBRARY_NAME} PRIVATE ${SOURCES}) diff --git a/tsl/src/nodes/vector_agg/hashing/batch_hashing_params.h b/tsl/src/nodes/vector_agg/hashing/batch_hashing_params.h new file mode 100644 index 00000000000..0f18a0f5fe0 --- /dev/null +++ b/tsl/src/nodes/vector_agg/hashing/batch_hashing_params.h @@ -0,0 +1,36 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ + +#pragma once + +/* + * The data required to map the rows of the given compressed batch to the unique + * indexes of grouping keys, using a hash table. + */ +typedef struct BatchHashingParams +{ + const uint64 *batch_filter; + CompressedColumnValues single_grouping_column; + + GroupingPolicyHash *restrict policy; + + uint32 *restrict result_key_indexes; +} BatchHashingParams; + +static pg_attribute_always_inline BatchHashingParams +build_batch_hashing_params(GroupingPolicyHash *policy, DecompressBatchState *batch_state) +{ + BatchHashingParams params = { + .policy = policy, + .batch_filter = batch_state->vector_qual_result, + .result_key_indexes = policy->key_index_for_row, + }; + + Assert(policy->num_grouping_columns == 1); + params.single_grouping_column = policy->current_batch_grouping_column_values[0]; + + return params; +} diff --git a/tsl/src/nodes/vector_agg/hashing/hash64.h b/tsl/src/nodes/vector_agg/hashing/hash64.h new file mode 100644 index 00000000000..97b0ec17987 --- /dev/null +++ b/tsl/src/nodes/vector_agg/hashing/hash64.h @@ -0,0 +1,36 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ +#pragma once + +/* + * We can use crc32 as a hash function, it has bad properties but takes only one + * cycle, which is why it is sometimes used in the existing hash table + * implementations. When we don't have the crc32 instruction, use the SplitMix64 + * finalizer. + */ +static pg_attribute_always_inline uint64 +hash64_splitmix(uint64 x) +{ + x ^= x >> 30; + x *= 0xbf58476d1ce4e5b9U; + x ^= x >> 27; + x *= 0x94d049bb133111ebU; + x ^= x >> 31; + return x; +} + +#ifdef USE_SSE42_CRC32C +#include +static pg_attribute_always_inline uint64 +hash64_crc(uint64 x) +{ + return _mm_crc32_u64(~0ULL, x); +} + +#define HASH64 hash64_crc +#else +#define HASH64 hash64_splitmix +#endif diff --git a/tsl/src/nodes/vector_agg/hashing/hash_strategy_common.c b/tsl/src/nodes/vector_agg/hashing/hash_strategy_common.c new file mode 100644 index 00000000000..ead986dc600 --- /dev/null +++ b/tsl/src/nodes/vector_agg/hashing/hash_strategy_common.c @@ -0,0 +1,52 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ + +#include "hashing_strategy.h" + +#include "nodes/vector_agg/exec.h" +#include "nodes/vector_agg/grouping_policy_hash.h" + +/* + * Allocate enough storage for keys, given that each row of the new compressed + * batch might turn out to be a new grouping key. We do this separately to avoid + * allocations in the hot loop that fills the hash table. + */ +void +hash_strategy_output_key_alloc(GroupingPolicyHash *policy, DecompressBatchState *batch_state) +{ + HashingStrategy *hashing = &policy->hashing; + const int n = batch_state->total_batch_rows; + const uint32 num_possible_keys = policy->last_used_key_index + 1 + n; + if (num_possible_keys > hashing->num_allocated_output_keys) + { + hashing->num_allocated_output_keys = num_possible_keys * 2 + 1; + const size_t new_bytes = sizeof(Datum) * hashing->num_allocated_output_keys; + if (hashing->output_keys == NULL) + { + hashing->output_keys = palloc(new_bytes); + } + else + { + hashing->output_keys = repalloc(hashing->output_keys, new_bytes); + } + } +} + +/* + * Emit a single-column grouping key with the given index into the aggregated + * slot. + */ +void +hash_strategy_output_key_single_emit(GroupingPolicyHash *policy, uint32 current_key, + TupleTableSlot *aggregated_slot) +{ + HashingStrategy *hashing = &policy->hashing; + Assert(policy->num_grouping_columns == 1); + + const GroupingColumn *col = &policy->grouping_columns[0]; + aggregated_slot->tts_values[col->output_offset] = hashing->output_keys[current_key]; + aggregated_slot->tts_isnull[col->output_offset] = current_key == hashing->null_key_index; +} diff --git a/tsl/src/nodes/vector_agg/hashing/hash_strategy_impl.c b/tsl/src/nodes/vector_agg/hashing/hash_strategy_impl.c new file mode 100644 index 00000000000..319ec06c6fb --- /dev/null +++ b/tsl/src/nodes/vector_agg/hashing/hash_strategy_impl.c @@ -0,0 +1,186 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ + +#include "batch_hashing_params.h" + +/* + * The hash table maps the value of the grouping key to its unique index. + * We don't store any extra information here, because we're accessing the memory + * of the hash table randomly, and want it to be as small as possible to fit the + * caches. + */ +typedef struct FUNCTION_NAME(entry) +{ + /* Key index 0 is invalid. */ + uint32 key_index; + + uint8 status; + + HASH_TABLE_KEY_TYPE hash_table_key; +} FUNCTION_NAME(entry); + +#define SH_PREFIX KEY_VARIANT +#define SH_ELEMENT_TYPE FUNCTION_NAME(entry) +#define SH_KEY_TYPE HASH_TABLE_KEY_TYPE +#define SH_KEY hash_table_key +#define SH_HASH_KEY(tb, key) KEY_HASH(key) +#define SH_EQUAL(tb, a, b) KEY_EQUAL(a, b) +#define SH_SCOPE static inline +#define SH_DECLARE +#define SH_DEFINE +#include + +struct FUNCTION_NAME(hash); + +static uint64 +FUNCTION_NAME(get_size_bytes)(HashingStrategy *hashing) +{ + struct FUNCTION_NAME(hash) *hash = (struct FUNCTION_NAME(hash) *) hashing->table; + return hash->members * sizeof(FUNCTION_NAME(entry)); +} + +static void +FUNCTION_NAME(hash_strategy_init)(HashingStrategy *hashing, GroupingPolicyHash *policy) +{ + hashing->table = + FUNCTION_NAME(create)(CurrentMemoryContext, policy->num_allocated_per_key_agg_states, NULL); + + FUNCTION_NAME(key_hashing_init)(hashing); +} + +static void +FUNCTION_NAME(hash_strategy_reset)(HashingStrategy *hashing) +{ + struct FUNCTION_NAME(hash) *table = (struct FUNCTION_NAME(hash) *) hashing->table; + FUNCTION_NAME(reset)(table); + hashing->null_key_index = 0; +} + +static void +FUNCTION_NAME(hash_strategy_prepare_for_batch)(GroupingPolicyHash *policy, + DecompressBatchState *batch_state) +{ + hash_strategy_output_key_alloc(policy, batch_state); + FUNCTION_NAME(key_hashing_prepare_for_batch)(policy, batch_state); +} + +/* + * Fill the unique key indexes for all rows of the batch, using a hash table. + */ +static pg_attribute_always_inline void +FUNCTION_NAME(fill_offsets_impl)(BatchHashingParams params, int start_row, int end_row) +{ + GroupingPolicyHash *policy = params.policy; + HashingStrategy *hashing = &policy->hashing; + + uint32 *restrict indexes = params.result_key_indexes; + + struct FUNCTION_NAME(hash) *restrict table = hashing->table; + + HASH_TABLE_KEY_TYPE prev_hash_table_key = { 0 }; + uint32 previous_key_index = 0; + for (int row = start_row; row < end_row; row++) + { + if (!arrow_row_is_valid(params.batch_filter, row)) + { + /* The row doesn't pass the filter. */ + DEBUG_PRINT("%p: row %d doesn't pass batch filter\n", policy, row); + continue; + } + + /* + * Get the key for the given row. For some hashing strategies, the key + * that is used for the hash table is different from actual values of + * the grouping columns, termed "output key" here. + */ + bool key_valid = false; + OUTPUT_KEY_TYPE output_key = { 0 }; + HASH_TABLE_KEY_TYPE hash_table_key = { 0 }; + FUNCTION_NAME(key_hashing_get_key)(params, row, &output_key, &hash_table_key, &key_valid); + + if (unlikely(!key_valid)) + { + /* The key is null. */ + if (hashing->null_key_index == 0) + { + hashing->null_key_index = ++policy->last_used_key_index; + } + indexes[row] = hashing->null_key_index; + DEBUG_PRINT("%p: row %d null key index %d\n", policy, row, hashing->null_key_index); + continue; + } + + if (likely(previous_key_index != 0) && KEY_EQUAL(hash_table_key, prev_hash_table_key)) + { + /* + * In real data sets, we often see consecutive rows with the + * same value of a grouping column, so checking for this case + * improves performance. For multi-column keys, this is unlikely, + * but we currently often have suboptimal plans that use this policy + * as a GroupAggregate, so we still use this as an easy optimization + * for that case. + */ + indexes[row] = previous_key_index; +#ifndef NDEBUG + policy->stat_consecutive_keys++; +#endif + DEBUG_PRINT("%p: row %d consecutive key index %d\n", policy, row, previous_key_index); + continue; + } + + /* + * Find the key using the hash table. + */ + bool found = false; + FUNCTION_NAME(entry) *restrict entry = FUNCTION_NAME(insert)(table, hash_table_key, &found); + if (!found) + { + /* + * New key, have to store it persistently. + */ + const uint32 index = ++policy->last_used_key_index; + entry->key_index = index; + FUNCTION_NAME(key_hashing_store_new)(policy, index, output_key); + DEBUG_PRINT("%p: row %d new key index %d\n", policy, row, index); + } + else + { + DEBUG_PRINT("%p: row %d old key index %d\n", policy, row, entry->key_index); + } + indexes[row] = entry->key_index; + + previous_key_index = entry->key_index; + prev_hash_table_key = entry->hash_table_key; + } +} + +static void +FUNCTION_NAME(fill_offsets)(GroupingPolicyHash *policy, DecompressBatchState *batch_state, + int start_row, int end_row) +{ + Assert((size_t) end_row <= policy->num_key_index_for_row); + + BatchHashingParams params = build_batch_hashing_params(policy, batch_state); + + FUNCTION_NAME(fill_offsets_impl)(params, start_row, end_row); +} + +HashingStrategy FUNCTION_NAME(strategy) = { + .emit_key = FUNCTION_NAME(emit_key), + .explain_name = EXPLAIN_NAME, + .fill_offsets = FUNCTION_NAME(fill_offsets), + .get_size_bytes = FUNCTION_NAME(get_size_bytes), + .init = FUNCTION_NAME(hash_strategy_init), + .prepare_for_batch = FUNCTION_NAME(hash_strategy_prepare_for_batch), + .reset = FUNCTION_NAME(hash_strategy_reset), +}; + +#undef EXPLAIN_NAME +#undef KEY_VARIANT +#undef KEY_EQUAL +#undef OUTPUT_KEY_TYPE +#undef HASH_TABLE_KEY_TYPE +#undef USE_DICT_HASHING diff --git a/tsl/src/nodes/vector_agg/hashing/hash_strategy_impl_single_fixed_key.c b/tsl/src/nodes/vector_agg/hashing/hash_strategy_impl_single_fixed_key.c new file mode 100644 index 00000000000..972567dcc10 --- /dev/null +++ b/tsl/src/nodes/vector_agg/hashing/hash_strategy_impl_single_fixed_key.c @@ -0,0 +1,70 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ + +/* + * Key handling function for a single fixed-size grouping key. + */ + +#include "batch_hashing_params.h" + +static void +FUNCTION_NAME(key_hashing_init)(HashingStrategy *hashing) +{ +} + +static void +FUNCTION_NAME(key_hashing_prepare_for_batch)(GroupingPolicyHash *policy, + DecompressBatchState *batch_state) +{ +} + +static pg_attribute_always_inline void +FUNCTION_NAME(key_hashing_get_key)(BatchHashingParams params, int row, + void *restrict output_key_ptr, void *restrict hash_table_key_ptr, + bool *restrict valid) +{ + OUTPUT_KEY_TYPE *restrict output_key = (OUTPUT_KEY_TYPE *) output_key_ptr; + HASH_TABLE_KEY_TYPE *restrict hash_table_key = (HASH_TABLE_KEY_TYPE *) hash_table_key_ptr; + + if (unlikely(params.single_grouping_column.decompression_type == DT_Scalar)) + { + *output_key = DATUM_TO_OUTPUT_KEY(*params.single_grouping_column.output_value); + *valid = !*params.single_grouping_column.output_isnull; + } + else if (params.single_grouping_column.decompression_type == sizeof(OUTPUT_KEY_TYPE)) + { + const OUTPUT_KEY_TYPE *values = params.single_grouping_column.buffers[1]; + *valid = arrow_row_is_valid(params.single_grouping_column.buffers[0], row); + *output_key = values[row]; + } + else + { + pg_unreachable(); + } + + /* + * For the fixed-size hash grouping, we use the output key as the hash table + * key as well. + */ + *hash_table_key = *output_key; +} + +static pg_attribute_always_inline void +FUNCTION_NAME(key_hashing_store_new)(GroupingPolicyHash *restrict policy, uint32 new_key_index, + OUTPUT_KEY_TYPE output_key) +{ + policy->hashing.output_keys[new_key_index] = OUTPUT_KEY_TO_DATUM(output_key); +} + +static void +FUNCTION_NAME(emit_key)(GroupingPolicyHash *policy, uint32 current_key, + TupleTableSlot *aggregated_slot) +{ + hash_strategy_output_key_single_emit(policy, current_key, aggregated_slot); +} + +#undef DATUM_TO_OUTPUT_KEY +#undef OUTPUT_KEY_TO_DATUM diff --git a/tsl/src/nodes/vector_agg/hashing/hash_strategy_single_fixed_2.c b/tsl/src/nodes/vector_agg/hashing/hash_strategy_single_fixed_2.c new file mode 100644 index 00000000000..8e2a9083d06 --- /dev/null +++ b/tsl/src/nodes/vector_agg/hashing/hash_strategy_single_fixed_2.c @@ -0,0 +1,32 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ + +/* + * Implementation of column hashing for a single fixed size 2-byte column. + */ + +#include + +#include "compression/arrow_c_data_interface.h" +#include "hash64.h" +#include "nodes/decompress_chunk/compressed_batch.h" +#include "nodes/vector_agg/exec.h" +#include "nodes/vector_agg/grouping_policy_hash.h" +#include "template_helper.h" + +#define EXPLAIN_NAME "single 2-byte" +#define KEY_VARIANT single_fixed_2 +#define OUTPUT_KEY_TYPE int16 +#define HASH_TABLE_KEY_TYPE OUTPUT_KEY_TYPE +#define DATUM_TO_OUTPUT_KEY DatumGetInt16 +#define OUTPUT_KEY_TO_DATUM Int16GetDatum + +#include "hash_strategy_impl_single_fixed_key.c" + +#define KEY_EQUAL(a, b) a == b +#define KEY_HASH(X) HASH64(X) + +#include "hash_strategy_impl.c" diff --git a/tsl/src/nodes/vector_agg/hashing/hash_strategy_single_fixed_4.c b/tsl/src/nodes/vector_agg/hashing/hash_strategy_single_fixed_4.c new file mode 100644 index 00000000000..cdf7a0e84a4 --- /dev/null +++ b/tsl/src/nodes/vector_agg/hashing/hash_strategy_single_fixed_4.c @@ -0,0 +1,32 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ + +/* + * Implementation of column hashing for a single fixed size 4-byte column. + */ + +#include + +#include "compression/arrow_c_data_interface.h" +#include "hash64.h" +#include "nodes/decompress_chunk/compressed_batch.h" +#include "nodes/vector_agg/exec.h" +#include "nodes/vector_agg/grouping_policy_hash.h" +#include "template_helper.h" + +#define EXPLAIN_NAME "single 4-byte" +#define KEY_VARIANT single_fixed_4 +#define OUTPUT_KEY_TYPE int32 +#define HASH_TABLE_KEY_TYPE int32 +#define DATUM_TO_OUTPUT_KEY DatumGetInt32 +#define OUTPUT_KEY_TO_DATUM Int32GetDatum + +#include "hash_strategy_impl_single_fixed_key.c" + +#define KEY_EQUAL(a, b) a == b +#define KEY_HASH(X) HASH64(X) + +#include "hash_strategy_impl.c" diff --git a/tsl/src/nodes/vector_agg/hashing/hash_strategy_single_fixed_8.c b/tsl/src/nodes/vector_agg/hashing/hash_strategy_single_fixed_8.c new file mode 100644 index 00000000000..e0f12adf85b --- /dev/null +++ b/tsl/src/nodes/vector_agg/hashing/hash_strategy_single_fixed_8.c @@ -0,0 +1,32 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ + +/* + * Implementation of column hashing for a single fixed size 8-byte column. + */ + +#include + +#include "compression/arrow_c_data_interface.h" +#include "hash64.h" +#include "nodes/decompress_chunk/compressed_batch.h" +#include "nodes/vector_agg/exec.h" +#include "nodes/vector_agg/grouping_policy_hash.h" +#include "template_helper.h" + +#define EXPLAIN_NAME "single 8-byte" +#define KEY_VARIANT single_fixed_8 +#define OUTPUT_KEY_TYPE int64 +#define HASH_TABLE_KEY_TYPE int64 +#define DATUM_TO_OUTPUT_KEY DatumGetInt64 +#define OUTPUT_KEY_TO_DATUM Int64GetDatum + +#include "hash_strategy_impl_single_fixed_key.c" + +#define KEY_EQUAL(a, b) a == b +#define KEY_HASH(X) HASH64(X) + +#include "hash_strategy_impl.c" diff --git a/tsl/src/nodes/vector_agg/hashing/hashing_strategy.h b/tsl/src/nodes/vector_agg/hashing/hashing_strategy.h new file mode 100644 index 00000000000..73c6130ffca --- /dev/null +++ b/tsl/src/nodes/vector_agg/hashing/hashing_strategy.h @@ -0,0 +1,61 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ +#pragma once + +#include + +typedef struct GroupingPolicyHash GroupingPolicyHash; + +typedef struct HashingStrategy HashingStrategy; + +typedef struct DecompressBatchState DecompressBatchState; + +typedef struct TupleTableSlot TupleTableSlot; + +/* + * The hashing strategy manages the details of how the grouping keys are stored + * in a hash table. + */ +typedef struct HashingStrategy +{ + char *explain_name; + void (*init)(HashingStrategy *hashing, GroupingPolicyHash *policy); + void (*reset)(HashingStrategy *hashing); + uint64 (*get_size_bytes)(HashingStrategy *hashing); + void (*prepare_for_batch)(GroupingPolicyHash *policy, DecompressBatchState *batch_state); + void (*fill_offsets)(GroupingPolicyHash *policy, DecompressBatchState *batch_state, + int start_row, int end_row); + void (*emit_key)(GroupingPolicyHash *policy, uint32 current_key, + TupleTableSlot *aggregated_slot); + + /* + * The hash table we use for grouping. It matches each grouping key to its + * unique integer index. + */ + void *table; + + /* + * For each unique grouping key, we store the values of the grouping columns. + * This is stored separately from hash table keys, because they might not + * have the full column values, and also storing them contiguously here + * leads to better memory access patterns when emitting the results. + * The details of the key storage are managed by the hashing strategy. + */ + Datum *restrict output_keys; + uint64 num_allocated_output_keys; + + /* + * In single-column grouping, we store the null key outside of the hash + * table, and its index is given by this value. Key index 0 is invalid. + * This is done to avoid having an "is null" flag in the hash table entries, + * to reduce the hash table size. + */ + uint32 null_key_index; +} HashingStrategy; + +void hash_strategy_output_key_alloc(GroupingPolicyHash *policy, DecompressBatchState *batch_state); +void hash_strategy_output_key_single_emit(GroupingPolicyHash *policy, uint32 current_key, + TupleTableSlot *aggregated_slot); diff --git a/tsl/src/nodes/vector_agg/hashing/template_helper.h b/tsl/src/nodes/vector_agg/hashing/template_helper.h new file mode 100644 index 00000000000..684186ab27e --- /dev/null +++ b/tsl/src/nodes/vector_agg/hashing/template_helper.h @@ -0,0 +1,10 @@ +/* + * This file and its contents are licensed under the Timescale License. + * Please see the included NOTICE for copyright information and + * LICENSE-TIMESCALE for a copy of the license. + */ +#pragma once + +#define FUNCTION_NAME_HELPER2(X, Y) X##_##Y +#define FUNCTION_NAME_HELPER(X, Y) FUNCTION_NAME_HELPER2(X, Y) +#define FUNCTION_NAME(Y) FUNCTION_NAME_HELPER(KEY_VARIANT, Y) diff --git a/tsl/src/nodes/vector_agg/plan.c b/tsl/src/nodes/vector_agg/plan.c index d68376eef14..055300e6990 100644 --- a/tsl/src/nodes/vector_agg/plan.c +++ b/tsl/src/nodes/vector_agg/plan.c @@ -16,6 +16,7 @@ #include "plan.h" #include "exec.h" +#include "import/list.h" #include "nodes/decompress_chunk/planner.h" #include "nodes/decompress_chunk/vector_quals.h" #include "nodes/vector_agg.h" @@ -131,7 +132,8 @@ resolve_outer_special_vars(List *agg_tlist, CustomScan *custom) * node. */ static Plan * -vector_agg_plan_create(Agg *agg, CustomScan *decompress_chunk, List *resolved_targetlist) +vector_agg_plan_create(Agg *agg, CustomScan *decompress_chunk, List *resolved_targetlist, + VectorAggGroupingType grouping_type) { CustomScan *vector_agg = (CustomScan *) makeNode(CustomScan); vector_agg->custom_plans = list_make1(decompress_chunk); @@ -171,13 +173,9 @@ vector_agg_plan_create(Agg *agg, CustomScan *decompress_chunk, List *resolved_ta vector_agg->scan.plan.extParam = bms_copy(agg->plan.extParam); vector_agg->scan.plan.allParam = bms_copy(agg->plan.allParam); - List *grouping_child_output_offsets = NIL; - for (int i = 0; i < agg->numCols; i++) - { - grouping_child_output_offsets = - lappend_int(grouping_child_output_offsets, AttrNumberGetAttrOffset(agg->grpColIdx[i])); - } - vector_agg->custom_private = list_make1(grouping_child_output_offsets); + vector_agg->custom_private = ts_new_list(T_List, VASI_Count); + lfirst(list_nth_cell(vector_agg->custom_private, VASI_GroupingType)) = + makeInteger(grouping_type); return (Plan *) vector_agg; } @@ -427,38 +425,112 @@ can_vectorize_aggref(Aggref *aggref, CustomScan *custom, VectorQualInfo *vqi) } /* - * Whether we can perform vectorized aggregation with a given grouping. - * Currently supports either no grouping or grouping by segmentby columns. + * What vectorized grouping strategy we can use for the given grouping columns. */ -static bool -can_vectorize_grouping(Agg *agg, CustomScan *custom, List *resolved_targetlist) +static VectorAggGroupingType +get_vectorized_grouping_type(Agg *agg, CustomScan *custom, List *resolved_targetlist) { /* - * We support vectorized aggregation without grouping. + * The Agg->numCols value can be less than the number of the non-aggregated + * vars in the aggregated targetlist, if some of them are equated to a + * constant. This behavior started with PG 16. This case is not very + * important, so we treat all non-aggregated columns as grouping columns to + * keep the vectorized aggregation node simple. */ - if (agg->numCols == 0) - { - return true; - } + int num_grouping_columns = 0; + bool all_segmentby = true; + Var *single_grouping_var = NULL; - for (int i = 0; i < agg->numCols; i++) + ListCell *lc; + foreach (lc, resolved_targetlist) { - int offset = AttrNumberGetAttrOffset(agg->grpColIdx[i]); - TargetEntry *entry = list_nth_node(TargetEntry, resolved_targetlist, offset); + TargetEntry *target_entry = lfirst_node(TargetEntry, lc); + if (IsA(target_entry->expr, Aggref)) + { + continue; + } - bool is_segmentby = false; - if (!is_vector_var(custom, entry->expr, &is_segmentby)) + if (!IsA(target_entry->expr, Var)) { - return false; + /* + * We shouldn't see anything except Vars or Aggrefs in the + * aggregated targetlists. Just say it's not vectorizable, because + * here we are working with arbitrary plans that we don't control. + */ + return VAGT_Invalid; } - if (!is_segmentby) + num_grouping_columns++; + + Var *var = castNode(Var, target_entry->expr); + bool is_segmentby; + if (!is_vector_var(custom, (Expr *) var, &is_segmentby)) { - return false; + return VAGT_Invalid; + } + + all_segmentby &= is_segmentby; + + /* + * If we have a single grouping column, record it for the additional + * checks later. + */ + if (num_grouping_columns == 1) + { + single_grouping_var = var; + } + else + { + single_grouping_var = NULL; } } - return true; + Assert(num_grouping_columns == 1 || single_grouping_var == NULL); + Assert(num_grouping_columns >= agg->numCols); + + /* + * We support vectorized aggregation without grouping. + */ + if (num_grouping_columns == 0) + { + return VAGT_Batch; + } + + /* + * We support grouping by any number of columns if all of them are segmentby. + */ + if (all_segmentby) + { + return VAGT_Batch; + } + + /* + * We support hashed vectorized grouping by one fixed-size by-value + * compressed column. + */ + if (num_grouping_columns == 1) + { + int16 typlen; + bool typbyval; + get_typlenbyval(single_grouping_var->vartype, &typlen, &typbyval); + if (typbyval) + { + switch (typlen) + { + case 2: + return VAGT_HashSingleFixed2; + case 4: + return VAGT_HashSingleFixed4; + case 8: + return VAGT_HashSingleFixed8; + default: + Ensure(false, "invalid fixed size %d of a vector type", typlen); + break; + } + } + } + + return VAGT_Invalid; } /* @@ -651,9 +723,11 @@ try_insert_vector_agg_node(Plan *plan) */ List *resolved_targetlist = resolve_outer_special_vars(agg->plan.targetlist, custom); - if (!can_vectorize_grouping(agg, custom, resolved_targetlist)) + const VectorAggGroupingType grouping_type = + get_vectorized_grouping_type(agg, custom, resolved_targetlist); + if (grouping_type == VAGT_Invalid) { - /* No GROUP BY support for now. */ + /* The grouping is not vectorizable. */ return plan; } @@ -667,7 +741,7 @@ try_insert_vector_agg_node(Plan *plan) ListCell *lc; foreach (lc, resolved_targetlist) { - TargetEntry *target_entry = castNode(TargetEntry, lfirst(lc)); + TargetEntry *target_entry = lfirst_node(TargetEntry, lc); if (IsA(target_entry->expr, Aggref)) { Aggref *aggref = castNode(Aggref, target_entry->expr); @@ -700,5 +774,5 @@ try_insert_vector_agg_node(Plan *plan) * Finally, all requirements are satisfied and we can vectorize this partial * aggregation node. */ - return vector_agg_plan_create(agg, custom, resolved_targetlist); + return vector_agg_plan_create(agg, custom, resolved_targetlist, grouping_type); } diff --git a/tsl/src/nodes/vector_agg/plan.h b/tsl/src/nodes/vector_agg/plan.h index 67f0e2957c9..94dabb35d6d 100644 --- a/tsl/src/nodes/vector_agg/plan.h +++ b/tsl/src/nodes/vector_agg/plan.h @@ -13,6 +13,15 @@ typedef struct VectorAggPlan CustomScan custom; } VectorAggPlan; +/* + * The indexes of settings that we have to pass through the custom_private list. + */ +typedef enum +{ + VASI_GroupingType = 0, + VASI_Count +} VectorAggSettingsIndex; + extern void _vector_agg_init(void); Plan *try_insert_vector_agg_node(Plan *plan); diff --git a/tsl/test/expected/vector_agg_filter.out b/tsl/test/expected/vector_agg_filter.out index 13629d3e4b3..8310a828be5 100644 --- a/tsl/test/expected/vector_agg_filter.out +++ b/tsl/test/expected/vector_agg_filter.out @@ -68,6 +68,7 @@ vacuum freeze analyze aggfilter; set timescaledb.debug_require_vector_agg = 'require'; ---- Uncomment to generate reference. --set timescaledb.enable_vectorized_aggregation to off; set timescaledb.debug_require_vector_agg = 'allow'; +set max_parallel_workers_per_gather = 0; select format('%sselect %s%s(%s)%s from aggfilter%s%s%s;', explain, @@ -2962,4 +2963,27 @@ select count(*) filter (where cint2 = stable_abs(0)) from aggfilter; 7 (1 row) +-- With hash grouping +select + ss, + count(*) filter (where s != 5), + count(*) filter (where cint2 < 0) +from aggfilter +group by ss +order by 2, 3; + ss | count | count +----+-------+------- + 5 | 0 | 9871 + | 19 | 12 + 4 | 19981 | 10064 + 3 | 19981 | 10076 + 9 | 20000 | 9961 + 0 | 20000 | 9968 + 7 | 20000 | 10008 + 8 | 20000 | 10082 + 6 | 20000 | 10089 + 11 | 40019 | 20008 +(10 rows) + reset timescaledb.debug_require_vector_agg; +reset max_parallel_workers_per_gather; diff --git a/tsl/test/expected/vector_agg_functions.out b/tsl/test/expected/vector_agg_functions.out index bdb17aacb29..2bd56502fb5 100644 --- a/tsl/test/expected/vector_agg_functions.out +++ b/tsl/test/expected/vector_agg_functions.out @@ -114,7 +114,8 @@ limit 1 set timescaledb.debug_require_vector_agg = :'guc_value'; ---- Uncomment to generate reference. Note that there are minor discrepancies ---- on float4 due to different numeric stability in our and PG implementations. --- set timescaledb.enable_vectorized_aggregation to off; set timescaledb.debug_require_vector_agg = 'allow'; +--set timescaledb.enable_vectorized_aggregation to off; set timescaledb.debug_require_vector_agg = 'forbid'; +set max_parallel_workers_per_gather = 0; select format('%sselect %s%s(%s) from aggfns%s%s%s;', explain, @@ -157,7 +158,8 @@ from 'cint2 is null']) with ordinality as condition(condition, n), unnest(array[ null, - 's']) with ordinality as grouping(grouping, n) + 's', + 'ss']) with ordinality as grouping(grouping, n) where true and (explain is null /* or condition is null and grouping = 's' */) @@ -190,6 +192,21 @@ select s, count(*) from aggfns group by s order by count(*), s limit 10; 9 | 20000 (10 rows) +select ss, count(*) from aggfns group by ss order by count(*), ss limit 10; + ss | count +----+------- + | 19 + 3 | 19981 + 4 | 19981 + 0 | 20000 + 5 | 20000 + 6 | 20000 + 7 | 20000 + 8 | 20000 + 9 | 20000 + 11 | 40019 +(10 rows) + select max(cdate) from aggfns; max ------------ @@ -211,6 +228,21 @@ select s, max(cdate) from aggfns group by s order by max(cdate), s limit 10; 9 | 06-01-2267 (10 rows) +select ss, max(cdate) from aggfns group by ss order by max(cdate), ss limit 10; + ss | max +----+------------ + 0 | 01-01-2021 + 3 | 02-21-2103 + | 02-21-2103 + 4 | 07-09-2130 + 11 | 07-09-2130 + 5 | 11-24-2157 + 6 | 04-11-2185 + 7 | 08-28-2212 + 8 | 01-14-2240 + 9 | 06-01-2267 +(10 rows) + select min(cdate) from aggfns; min ------------ @@ -232,6 +264,21 @@ select s, min(cdate) from aggfns group by s order by min(cdate), s limit 10; 9 | 06-01-2267 (10 rows) +select ss, min(cdate) from aggfns group by ss order by min(cdate), ss limit 10; + ss | min +----+------------ + 0 | 01-01-2021 + 11 | 05-19-2048 + 3 | 02-21-2103 + | 02-21-2103 + 4 | 07-09-2130 + 5 | 11-24-2157 + 6 | 04-11-2185 + 7 | 08-28-2212 + 8 | 01-14-2240 + 9 | 06-01-2267 +(10 rows) + select avg(cfloat4) from aggfns; avg ----- @@ -253,6 +300,21 @@ select s, avg(cfloat4) from aggfns group by s order by avg(cfloat4), s limit 10; 1 | NaN (10 rows) +select ss, avg(cfloat4) from aggfns group by ss order by avg(cfloat4), ss limit 10; + ss | avg +----+---------------------- + 3 | -Infinity + | -1.39583652270468 + 9 | -0.292700759558938 + 4 | -0.169252917487522 + 6 | -0.00610964622725733 + 5 | 0.0107821527590975 + 0 | 0.0862269837114494 + 7 | 0.19168354413514 + 8 | 0.456703752867272 + 11 | NaN +(10 rows) + select max(cfloat4) from aggfns; max ----- @@ -274,6 +336,21 @@ select s, max(cfloat4) from aggfns group by s order by max(cfloat4), s limit 10; 1 | NaN (10 rows) +select ss, max(cfloat4) from aggfns group by ss order by max(cfloat4), ss limit 10; + ss | max +----+--------- + | 47.2047 + 9 | 49.9899 + 4 | 49.9946 + 6 | 49.9956 + 7 | 49.9969 + 3 | 49.9979 + 5 | 49.9992 + 0 | 49.9995 + 8 | 49.9997 + 11 | NaN +(10 rows) + select min(cfloat4) from aggfns; min ----------- @@ -295,6 +372,21 @@ select s, min(cfloat4) from aggfns group by s order by min(cfloat4), s limit 10; 9 | -49.9911 (10 rows) +select ss, min(cfloat4) from aggfns group by ss order by min(cfloat4), ss limit 10; + ss | min +----+----------- + 3 | -Infinity + 4 | -49.9999 + 6 | -49.9995 + 7 | -49.9984 + 8 | -49.9969 + 0 | -49.9949 + 5 | -49.9942 + 9 | -49.9911 + | -45.4083 + 11 | NaN +(10 rows) + select stddev(cfloat4) from aggfns; stddev -------- @@ -316,6 +408,21 @@ select s, stddev(cfloat4) from aggfns group by s order by stddev(cfloat4), s lim 3 | NaN (10 rows) +select ss, stddev(cfloat4) from aggfns group by ss order by stddev(cfloat4), ss limit 10; + ss | stddev +----+------------------ + 0 | 28.7274163912974 + 7 | 28.7892027644318 + 4 | 28.8220943927954 + 9 | 28.8426424990846 + 6 | 28.9190577543738 + 8 | 29.0040125904064 + 5 | 29.0213532270614 + | 30.6324072248673 + 3 | NaN + 11 | NaN +(10 rows) + select sum(cfloat4) from aggfns; sum ----- @@ -337,6 +444,21 @@ select s, sum(cfloat4) from aggfns group by s order by sum(cfloat4), s limit 10; 1 | NaN (10 rows) +select ss, sum(cfloat4) from aggfns group by ss order by sum(cfloat4), ss limit 10; + ss | sum +----+----------- + 3 | -Infinity + 9 | -5854.02 + 4 | -3381.84 + 6 | -122.193 + | -26.5209 + 5 | 215.643 + 0 | 1724.54 + 7 | 3833.67 + 8 | 9134.08 + 11 | NaN +(10 rows) + select avg(cfloat8) from aggfns; avg ----------------- @@ -358,6 +480,21 @@ select s, avg(cfloat8) from aggfns group by s order by avg(cfloat8), s limit 10; 1 | 13 (10 rows) +select ss, avg(cfloat8) from aggfns group by ss order by avg(cfloat8), ss limit 10; + ss | avg +----+-------------------- + 0 | -0.306925132697215 + 8 | -0.268692900155438 + 4 | -0.224160255000712 + 3 | -0.153492446187821 + 9 | -0.114842409039848 + 7 | -0.063637967283139 + 5 | 0.0438265096326359 + 6 | 0.169599099685438 + | 5.42090986487701 + 11 | 6.59778165165114 +(10 rows) + select max(cfloat8) from aggfns; max ------------------ @@ -379,6 +516,21 @@ select s, max(cfloat8) from aggfns group by s order by max(cfloat8), s limit 10; 9 | 49.9995574122295 (10 rows) +select ss, max(cfloat8) from aggfns group by ss order by max(cfloat8), ss limit 10; + ss | max +----+------------------ + | 46.3985309237614 + 5 | 49.9874341068789 + 3 | 49.9890822684392 + 6 | 49.9939429108053 + 8 | 49.9963666079566 + 0 | 49.9965498689562 + 7 | 49.9973275698721 + 11 | 49.9975695507601 + 4 | 49.9978997278959 + 9 | 49.9995574122295 +(10 rows) + select min(cfloat8) from aggfns; min ------------------- @@ -400,6 +552,21 @@ select s, min(cfloat8) from aggfns group by s order by min(cfloat8), s limit 10; 1 | 13 (10 rows) +select ss, min(cfloat8) from aggfns group by ss order by min(cfloat8), ss limit 10; + ss | min +----+------------------- + 0 | -49.9994775978848 + 11 | -49.9985320260748 + 4 | -49.9983572866768 + 3 | -49.9977725092322 + 6 | -49.9967515002936 + 9 | -49.992344272323 + 5 | -49.9921301845461 + 7 | -49.99003498815 + 8 | -49.9897602945566 + | -38.5084833716974 +(10 rows) + select stddev(cfloat8) from aggfns; stddev ------------------ @@ -421,6 +588,21 @@ select s, stddev(cfloat8) from aggfns group by s order by stddev(cfloat8), s lim 7 | 28.9656492103737 (10 rows) +select ss, stddev(cfloat8) from aggfns group by ss order by stddev(cfloat8), ss limit 10; + ss | stddev +----+------------------ + 11 | 21.3262797346004 + | 22.894065438835 + 9 | 28.7642081921344 + 4 | 28.7760615445521 + 5 | 28.7843925303698 + 6 | 28.8543767497508 + 3 | 28.926156595386 + 8 | 28.96331707256 + 0 | 28.9653425568561 + 7 | 28.9656492103736 +(10 rows) + select sum(cfloat8) from aggfns; sum ----------------- @@ -442,6 +624,21 @@ select s, sum(cfloat8) from aggfns group by s order by sum(cfloat8), s limit 10; 1 | 260000 (10 rows) +select ss, sum(cfloat8) from aggfns group by ss order by sum(cfloat8), ss limit 10; + ss | sum +----+------------------- + 0 | -6138.50265394431 + 8 | -5373.85800310876 + 4 | -4478.94605516922 + 3 | -3066.93256727885 + 9 | -2296.84818079695 + 7 | -1272.75934566278 + | 102.997287432663 + 5 | 876.530192652717 + 6 | 3391.98199370876 + 11 | 264036.623917427 +(10 rows) + select avg(cint2) from aggfns; avg ---------------------- @@ -463,6 +660,21 @@ select s, avg(cint2) from aggfns group by s order by avg(cint2), s limit 10; 5 | 110.0305290025524248 (10 rows) +select ss, avg(cint2) from aggfns group by ss order by avg(cint2), ss limit 10; + ss | avg +----+------------------------ + | -1368.1578947368421053 + 8 | -129.4959711726139833 + 3 | -94.5546037471195271 + 6 | -61.0756218407487113 + 7 | -55.8695260497472599 + 11 | -33.7550336409794652 + 4 | -27.5652740206392145 + 9 | -21.7994594865121866 + 0 | 17.5951654071367799 + 5 | 110.0305290025524248 +(10 rows) + select count(cint2) from aggfns; count -------- @@ -484,6 +696,21 @@ select s, count(cint2) from aggfns group by s order by count(cint2), s limit 10; 9 | 19981 (10 rows) +select ss, count(cint2) from aggfns group by ss order by count(cint2), ss limit 10; + ss | count +----+------- + | 19 + 3 | 19962 + 4 | 19962 + 0 | 19981 + 5 | 19981 + 6 | 19981 + 7 | 19981 + 8 | 19981 + 9 | 19981 + 11 | 39981 +(10 rows) + select max(cint2) from aggfns; max ------- @@ -505,6 +732,21 @@ select s, max(cint2) from aggfns group by s order by max(cint2), s limit 10; 9 | 16383 (10 rows) +select ss, max(cint2) from aggfns group by ss order by max(cint2), ss limit 10; + ss | max +----+------- + | 16362 + 3 | 16380 + 5 | 16381 + 7 | 16381 + 8 | 16382 + 0 | 16383 + 4 | 16383 + 6 | 16383 + 9 | 16383 + 11 | 16383 +(10 rows) + select min(cint2) from aggfns; min -------- @@ -526,6 +768,21 @@ select s, min(cint2) from aggfns group by s order by min(cint2), s limit 10; 9 | -16375 (10 rows) +select ss, min(cint2) from aggfns group by ss order by min(cint2), ss limit 10; + ss | min +----+-------- + 0 | -16383 + 4 | -16383 + 5 | -16383 + 6 | -16383 + 7 | -16382 + 8 | -16382 + 11 | -16382 + 3 | -16381 + 9 | -16375 + | -16100 +(10 rows) + select stddev(cint2) from aggfns; stddev ------------------- @@ -547,6 +804,21 @@ select s, stddev(cint2) from aggfns group by s order by stddev(cint2), s limit 1 1 | 9528.039076724276 (10 rows) +select ss, stddev(cint2) from aggfns group by ss order by stddev(cint2), ss limit 10; + ss | stddev +----+------------------- + | 8413.549166956554 + 9 | 9450.322790943425 + 7 | 9462.161209850735 + 6 | 9467.569674984571 + 5 | 9467.776835158782 + 3 | 9474.482349111595 + 8 | 9477.586839536066 + 4 | 9483.611454519949 + 0 | 9484.907423282680 + 11 | 9494.206429493352 +(10 rows) + select sum(cint2) from aggfns; sum ---------- @@ -568,6 +840,21 @@ select s, sum(cint2) from aggfns group by s order by sum(cint2), s limit 10; 5 | 2198520 (10 rows) +select ss, sum(cint2) from aggfns group by ss order by sum(cint2), ss limit 10; + ss | sum +----+---------- + 8 | -2587459 + 3 | -1887499 + 11 | -1349560 + 6 | -1220352 + 7 | -1116329 + 4 | -550258 + 9 | -435575 + | -25995 + 0 | 351569 + 5 | 2198520 +(10 rows) + select avg(cint4) from aggfns; avg --------------------- @@ -589,6 +876,21 @@ select s, avg(cint4) from aggfns group by s order by avg(cint4), s limit 10; 5 | 103.1069000000000000 (10 rows) +select ss, avg(cint4) from aggfns group by ss order by avg(cint4), ss limit 10; + ss | avg +----+----------------------- + 9 | -102.4283000000000000 + 6 | -53.1566500000000000 + 7 | -42.6121500000000000 + 8 | -29.2615500000000000 + 11 | -16.4247732327144606 + 4 | 9.6930584054852110 + 0 | 27.7536500000000000 + 3 | 68.3874180471447875 + 5 | 103.1069000000000000 + | 2197.6842105263157895 +(10 rows) + select max(cint4) from aggfns; max ------- @@ -610,6 +912,21 @@ select s, max(cint4) from aggfns group by s order by max(cint4), s limit 10; 9 | 16383 (10 rows) +select ss, max(cint4) from aggfns group by ss order by max(cint4), ss limit 10; + ss | max +----+------- + | 14812 + 3 | 16379 + 5 | 16379 + 7 | 16379 + 0 | 16383 + 4 | 16383 + 6 | 16383 + 8 | 16383 + 9 | 16383 + 11 | 16383 +(10 rows) + select min(cint4) from aggfns; min -------- @@ -631,6 +948,21 @@ select s, min(cint4) from aggfns group by s order by min(cint4), s limit 10; 5 | -16380 (10 rows) +select ss, min(cint4) from aggfns group by ss order by min(cint4), ss limit 10; + ss | min +----+-------- + 0 | -16383 + 7 | -16383 + 11 | -16383 + 3 | -16382 + 4 | -16382 + 6 | -16382 + 8 | -16382 + 9 | -16382 + 5 | -16380 + | -15907 +(10 rows) + select stddev(cint4) from aggfns; stddev ------------------- @@ -652,6 +984,21 @@ select s, stddev(cint4) from aggfns group by s order by stddev(cint4), s limit 1 5 | 9504.684751625578 (10 rows) +select ss, stddev(cint4) from aggfns group by ss order by stddev(cint4), ss limit 10; + ss | stddev +----+------------------- + | 9361.317298404296 + 0 | 9406.815855797801 + 6 | 9410.397911988306 + 9 | 9426.452583637956 + 4 | 9442.480718256247 + 8 | 9450.281544631633 + 11 | 9450.690059613938 + 3 | 9474.873657491443 + 7 | 9485.765898279180 + 5 | 9504.684751625578 +(10 rows) + select sum(cint4) from aggfns; sum --------- @@ -673,6 +1020,21 @@ select s, sum(cint4) from aggfns group by s order by sum(cint4), s limit 10; 5 | 2062138 (10 rows) +select ss, sum(cint4) from aggfns group by ss order by sum(cint4), ss limit 10; + ss | sum +----+---------- + 9 | -2048566 + 6 | -1063133 + 7 | -852243 + 11 | -657303 + 8 | -585231 + | 41756 + 4 | 193677 + 0 | 555073 + 3 | 1366449 + 5 | 2062138 +(10 rows) + select avg(cint8) from aggfns; avg ---------------------- @@ -694,6 +1056,21 @@ select s, avg(cint8) from aggfns group by s order by avg(cint8), s limit 10; 9 | 61.7467500000000000 (10 rows) +select ss, avg(cint8) from aggfns group by ss order by avg(cint8), ss limit 10; + ss | avg +----+----------------------- + 8 | -118.4870000000000000 + 5 | -81.6955500000000000 + 4 | -17.0811771182623492 + 11 | -15.1685449411529523 + 7 | -2.3563500000000000 + 6 | 11.9056500000000000 + 0 | 15.3018000000000000 + 3 | 37.6662329212752115 + 9 | 61.7467500000000000 + | 2467.2631578947368421 +(10 rows) + select max(cint8) from aggfns; max ------- @@ -715,6 +1092,21 @@ select s, max(cint8) from aggfns group by s order by max(cint8), s limit 10; 5 | 16383 (10 rows) +select ss, max(cint8) from aggfns group by ss order by max(cint8), ss limit 10; + ss | max +----+------- + | 13750 + 6 | 16380 + 7 | 16380 + 8 | 16380 + 3 | 16382 + 9 | 16382 + 0 | 16383 + 4 | 16383 + 5 | 16383 + 11 | 16383 +(10 rows) + select min(cint8) from aggfns; min -------- @@ -736,6 +1128,21 @@ select s, min(cint8) from aggfns group by s order by min(cint8), s limit 10; 3 | -16378 (10 rows) +select ss, min(cint8) from aggfns group by ss order by min(cint8), ss limit 10; + ss | min +----+-------- + 0 | -16383 + 6 | -16383 + 7 | -16383 + 8 | -16383 + 11 | -16383 + 5 | -16382 + 4 | -16381 + 9 | -16380 + 3 | -16378 + | -14174 +(10 rows) + select sum(cint8) from aggfns; sum ---------- @@ -757,6 +1164,21 @@ select s, sum(cint8) from aggfns group by s order by sum(cint8), s limit 10; 9 | 1234935 (10 rows) +select ss, sum(cint8) from aggfns group by ss order by sum(cint8), ss limit 10; + ss | sum +----+---------- + 8 | -2369740 + 5 | -1633911 + 11 | -607030 + 4 | -341299 + 7 | -47127 + | 46878 + 6 | 238113 + 0 | 306036 + 3 | 752609 + 9 | 1234935 +(10 rows) + select max(cts) from aggfns; max -------------------------- @@ -778,6 +1200,21 @@ select s, max(cts) from aggfns group by s order by max(cts), s limit 10; 9 | Sat Jan 02 02:01:01 2021 (10 rows) +select ss, max(cts) from aggfns group by ss order by max(cts), ss limit 10; + ss | max +----+-------------------------- + 0 | Fri Jan 01 01:01:01 2021 + 3 | Fri Jan 01 09:21:01 2021 + | Fri Jan 01 09:21:01 2021 + 4 | Fri Jan 01 12:07:41 2021 + 11 | Fri Jan 01 12:07:41 2021 + 5 | Fri Jan 01 14:54:21 2021 + 6 | Fri Jan 01 17:41:01 2021 + 7 | Fri Jan 01 20:27:41 2021 + 8 | Fri Jan 01 23:14:21 2021 + 9 | Sat Jan 02 02:01:01 2021 +(10 rows) + select min(cts) from aggfns; min -------------------------- @@ -799,6 +1236,21 @@ select s, min(cts) from aggfns group by s order by min(cts), s limit 10; 9 | Sat Jan 02 02:01:01 2021 (10 rows) +select ss, min(cts) from aggfns group by ss order by min(cts), ss limit 10; + ss | min +----+-------------------------- + 0 | Fri Jan 01 01:01:01 2021 + 11 | Fri Jan 01 03:47:41 2021 + 3 | Fri Jan 01 09:21:01 2021 + | Fri Jan 01 09:21:01 2021 + 4 | Fri Jan 01 12:07:41 2021 + 5 | Fri Jan 01 14:54:21 2021 + 6 | Fri Jan 01 17:41:01 2021 + 7 | Fri Jan 01 20:27:41 2021 + 8 | Fri Jan 01 23:14:21 2021 + 9 | Sat Jan 02 02:01:01 2021 +(10 rows) + select max(ctstz) from aggfns; max ------------------------------ @@ -820,6 +1272,21 @@ select s, max(ctstz) from aggfns group by s order by max(ctstz), s limit 10; 9 | Sat Jan 02 02:01:01 2021 PST (10 rows) +select ss, max(ctstz) from aggfns group by ss order by max(ctstz), ss limit 10; + ss | max +----+------------------------------ + 0 | Fri Jan 01 01:01:01 2021 PST + 3 | Fri Jan 01 09:21:01 2021 PST + | Fri Jan 01 09:21:01 2021 PST + 4 | Fri Jan 01 12:07:41 2021 PST + 11 | Fri Jan 01 12:07:41 2021 PST + 5 | Fri Jan 01 14:54:21 2021 PST + 6 | Fri Jan 01 17:41:01 2021 PST + 7 | Fri Jan 01 20:27:41 2021 PST + 8 | Fri Jan 01 23:14:21 2021 PST + 9 | Sat Jan 02 02:01:01 2021 PST +(10 rows) + select min(ctstz) from aggfns; min ------------------------------ @@ -841,6 +1308,21 @@ select s, min(ctstz) from aggfns group by s order by min(ctstz), s limit 10; 9 | Sat Jan 02 02:01:01 2021 PST (10 rows) +select ss, min(ctstz) from aggfns group by ss order by min(ctstz), ss limit 10; + ss | min +----+------------------------------ + 0 | Fri Jan 01 01:01:01 2021 PST + 11 | Fri Jan 01 03:47:41 2021 PST + 3 | Fri Jan 01 09:21:01 2021 PST + | Fri Jan 01 09:21:01 2021 PST + 4 | Fri Jan 01 12:07:41 2021 PST + 5 | Fri Jan 01 14:54:21 2021 PST + 6 | Fri Jan 01 17:41:01 2021 PST + 7 | Fri Jan 01 20:27:41 2021 PST + 8 | Fri Jan 01 23:14:21 2021 PST + 9 | Sat Jan 02 02:01:01 2021 PST +(10 rows) + select avg(s) from aggfns; avg -------------------- @@ -862,6 +1344,21 @@ select s, avg(s) from aggfns group by s order by avg(s), s limit 10; 9 | 9.0000000000000000 (10 rows) +select ss, avg(s) from aggfns group by ss order by avg(s), ss limit 10; + ss | avg +----+---------------------------- + 0 | 0.000000000000000000000000 + 11 | 1.5011869362053025 + 3 | 3.0000000000000000 + | 3.0000000000000000 + 4 | 4.0000000000000000 + 5 | 5.0000000000000000 + 6 | 6.0000000000000000 + 7 | 7.0000000000000000 + 8 | 8.0000000000000000 + 9 | 9.0000000000000000 +(10 rows) + select count(s) from aggfns; count -------- @@ -883,6 +1380,21 @@ select s, count(s) from aggfns group by s order by count(s), s limit 10; 9 | 20000 (10 rows) +select ss, count(s) from aggfns group by ss order by count(s), ss limit 10; + ss | count +----+------- + | 19 + 3 | 19981 + 4 | 19981 + 0 | 20000 + 5 | 20000 + 6 | 20000 + 7 | 20000 + 8 | 20000 + 9 | 20000 + 11 | 40019 +(10 rows) + select max(s) from aggfns; max ----- @@ -904,6 +1416,21 @@ select s, max(s) from aggfns group by s order by max(s), s limit 10; 9 | 9 (10 rows) +select ss, max(s) from aggfns group by ss order by max(s), ss limit 10; + ss | max +----+----- + 0 | 0 + 3 | 3 + | 3 + 4 | 4 + 11 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 +(10 rows) + select min(s) from aggfns; min ----- @@ -925,6 +1452,21 @@ select s, min(s) from aggfns group by s order by min(s), s limit 10; 9 | 9 (10 rows) +select ss, min(s) from aggfns group by ss order by min(s), ss limit 10; + ss | min +----+----- + 0 | 0 + 11 | 1 + 3 | 3 + | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 +(10 rows) + select stddev(s) from aggfns; stddev -------------------- @@ -946,6 +1488,21 @@ select s, stddev(s) from aggfns group by s order by stddev(s), s limit 10; 9 | 0 (10 rows) +select ss, stddev(s) from aggfns group by ss order by stddev(s), ss limit 10; + ss | stddev +----+------------------------ + 0 | 0 + 3 | 0 + 4 | 0 + 5 | 0 + 6 | 0 + 7 | 0 + 8 | 0 + 9 | 0 + | 0 + 11 | 0.50284545977155885187 +(10 rows) + select sum(s) from aggfns; sum -------- @@ -967,6 +1524,21 @@ select s, sum(s) from aggfns group by s order by sum(s), s limit 10; 9 | 180000 (10 rows) +select ss, sum(s) from aggfns group by ss order by sum(s), ss limit 10; + ss | sum +----+-------- + 0 | 0 + | 57 + 3 | 59943 + 11 | 60076 + 4 | 79924 + 5 | 100000 + 6 | 120000 + 7 | 140000 + 8 | 160000 + 9 | 180000 +(10 rows) + select avg(ss) from aggfns; avg -------------------- @@ -988,6 +1560,21 @@ select s, avg(ss) from aggfns group by s order by avg(ss), s limit 10; 2 | 11.0000000000000000 (10 rows) +select ss, avg(ss) from aggfns group by ss order by avg(ss), ss limit 10; + ss | avg +----+---------------------------- + 0 | 0.000000000000000000000000 + 3 | 3.0000000000000000 + 4 | 4.0000000000000000 + 5 | 5.0000000000000000 + 6 | 6.0000000000000000 + 7 | 7.0000000000000000 + 8 | 8.0000000000000000 + 9 | 9.0000000000000000 + 11 | 11.0000000000000000 + | +(10 rows) + select max(ss) from aggfns; max ----- @@ -1009,6 +1596,21 @@ select s, max(ss) from aggfns group by s order by max(ss), s limit 10; 4 | 11 (10 rows) +select ss, max(ss) from aggfns group by ss order by max(ss), ss limit 10; + ss | max +----+----- + 0 | 0 + 3 | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 + 11 | 11 + | +(10 rows) + select min(ss) from aggfns; min ----- @@ -1030,6 +1632,21 @@ select s, min(ss) from aggfns group by s order by min(ss), s limit 10; 2 | 11 (10 rows) +select ss, min(ss) from aggfns group by ss order by min(ss), ss limit 10; + ss | min +----+----- + 0 | 0 + 3 | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 + 11 | 11 + | +(10 rows) + select stddev(ss) from aggfns; stddev -------------------- @@ -1051,6 +1668,21 @@ select s, stddev(ss) from aggfns group by s order by stddev(ss), s limit 10; 4 | 0.21565737387148452722 (10 rows) +select ss, stddev(ss) from aggfns group by ss order by stddev(ss), ss limit 10; + ss | stddev +----+-------- + 0 | 0 + 3 | 0 + 4 | 0 + 5 | 0 + 6 | 0 + 7 | 0 + 8 | 0 + 9 | 0 + 11 | 0 + | +(10 rows) + select sum(ss) from aggfns; sum --------- @@ -1072,6 +1704,21 @@ select s, sum(ss) from aggfns group by s order by sum(ss), s limit 10; 2 | 220000 (10 rows) +select ss, sum(ss) from aggfns group by ss order by sum(ss), ss limit 10; + ss | sum +----+-------- + 0 | 0 + 3 | 59943 + 4 | 79924 + 5 | 100000 + 6 | 120000 + 7 | 140000 + 8 | 160000 + 9 | 180000 + 11 | 440209 + | +(10 rows) + select max(t) from aggfns; max -------- @@ -1093,6 +1740,21 @@ select s, max(t) from aggfns group by s order by max(t), s limit 10; 9 | 110000 (10 rows) +select ss, max(t) from aggfns group by ss order by max(t), ss limit 10; + ss | max +----+-------- + 0 | 20000 + | 49491 + 3 | 50000 + 11 | 59192 + 4 | 60000 + 5 | 70000 + 6 | 80000 + 7 | 90000 + 8 | 100000 + 9 | 110000 +(10 rows) + select min(t) from aggfns; min ----- @@ -1114,6 +1776,21 @@ select s, min(t) from aggfns group by s order by min(t), s limit 10; 9 | 90001 (10 rows) +select ss, min(t) from aggfns group by ss order by min(t), ss limit 10; + ss | min +----+------- + 0 | 1 + 11 | 10001 + 3 | 30001 + | 30537 + 4 | 40001 + 5 | 50001 + 6 | 60001 + 7 | 70001 + 8 | 80001 + 9 | 90001 +(10 rows) + select count(*) from aggfns where cfloat8 > 0; count -------- @@ -1135,6 +1812,21 @@ select s, count(*) from aggfns where cfloat8 > 0 group by s order by count(*), s 1 | 20000 (10 rows) +select ss, count(*) from aggfns where cfloat8 > 0 group by ss order by count(*), ss limit 10; + ss | count +----+------- + | 13 + 4 | 9872 + 0 | 9881 + 9 | 9945 + 3 | 9950 + 8 | 9950 + 5 | 9972 + 7 | 10021 + 6 | 10097 + 11 | 30084 +(10 rows) + select max(cdate) from aggfns where cfloat8 > 0; max ------------ @@ -1156,6 +1848,21 @@ select s, max(cdate) from aggfns where cfloat8 > 0 group by s order by max(cdate 9 | 06-01-2267 (10 rows) +select ss, max(cdate) from aggfns where cfloat8 > 0 group by ss order by max(cdate), ss limit 10; + ss | max +----+------------ + 0 | 01-01-2021 + 3 | 02-21-2103 + | 02-21-2103 + 4 | 07-09-2130 + 11 | 07-09-2130 + 5 | 11-24-2157 + 6 | 04-11-2185 + 7 | 08-28-2212 + 8 | 01-14-2240 + 9 | 06-01-2267 +(10 rows) + select min(cdate) from aggfns where cfloat8 > 0; min ------------ @@ -1177,6 +1884,21 @@ select s, min(cdate) from aggfns where cfloat8 > 0 group by s order by min(cdate 9 | 06-01-2267 (10 rows) +select ss, min(cdate) from aggfns where cfloat8 > 0 group by ss order by min(cdate), ss limit 10; + ss | min +----+------------ + 0 | 01-01-2021 + 11 | 05-19-2048 + 3 | 02-21-2103 + | 02-21-2103 + 4 | 07-09-2130 + 5 | 11-24-2157 + 6 | 04-11-2185 + 7 | 08-28-2212 + 8 | 01-14-2240 + 9 | 06-01-2267 +(10 rows) + select avg(cfloat4) from aggfns where cfloat8 > 0; avg ----- @@ -1198,6 +1920,21 @@ select s, avg(cfloat4) from aggfns where cfloat8 > 0 group by s order by avg(cfl 1 | NaN (10 rows) +select ss, avg(cfloat4) from aggfns where cfloat8 > 0 group by ss order by avg(cfloat4), ss limit 10; + ss | avg +----+-------------------- + 3 | -Infinity + 4 | -0.458554823065329 + 0 | -0.334856044433109 + 9 | -0.208302219537011 + 6 | 0.199537611181853 + 7 | 0.313851696029514 + 5 | 0.374879026647364 + 8 | 0.606801085094336 + | 1.47322510755979 + 11 | NaN +(10 rows) + select max(cfloat4) from aggfns where cfloat8 > 0; max ----- @@ -1219,6 +1956,21 @@ select s, max(cfloat4) from aggfns where cfloat8 > 0 group by s order by max(cfl 1 | NaN (10 rows) +select ss, max(cfloat4) from aggfns where cfloat8 > 0 group by ss order by max(cfloat4), ss limit 10; + ss | max +----+--------- + | 47.2047 + 9 | 49.9744 + 3 | 49.9744 + 0 | 49.9863 + 8 | 49.9923 + 4 | 49.9928 + 6 | 49.9956 + 7 | 49.9969 + 5 | 49.9992 + 11 | NaN +(10 rows) + select min(cfloat4) from aggfns where cfloat8 > 0; min ----------- @@ -1240,6 +1992,21 @@ select s, min(cfloat4) from aggfns where cfloat8 > 0 group by s order by min(cfl 6 | -49.9891 (10 rows) +select ss, min(cfloat4) from aggfns where cfloat8 > 0 group by ss order by min(cfloat4), ss limit 10; + ss | min +----+----------- + 3 | -Infinity + 4 | -49.9993 + 8 | -49.9969 + 7 | -49.9969 + 0 | -49.9915 + 9 | -49.9911 + 5 | -49.9892 + 6 | -49.9891 + | -41.6131 + 11 | NaN +(10 rows) + select stddev(cfloat4) from aggfns where cfloat8 > 0; stddev -------- @@ -1261,6 +2028,21 @@ select s, stddev(cfloat4) from aggfns where cfloat8 > 0 group by s order by stdd 3 | NaN (10 rows) +select ss, stddev(cfloat4) from aggfns where cfloat8 > 0 group by ss order by stddev(cfloat4), ss limit 10; + ss | stddev +----+------------------ + 7 | 28.7246858657947 + 0 | 28.7315562731003 + 9 | 28.7729261590403 + 4 | 28.8497176060195 + 5 | 28.9107809470208 + 6 | 28.9388387251543 + 8 | 29.1042713834566 + | 29.539145536489 + 3 | NaN + 11 | NaN +(10 rows) + select sum(cfloat4) from aggfns where cfloat8 > 0; sum ----- @@ -1282,6 +2064,21 @@ select s, sum(cfloat4) from aggfns where cfloat8 > 0 group by s order by sum(cfl 1 | NaN (10 rows) +select ss, sum(cfloat4) from aggfns where cfloat8 > 0 group by ss order by sum(cfloat4), ss limit 10; + ss | sum +----+----------- + 3 | -Infinity + 4 | -4526.85 + 0 | -3308.71 + 9 | -2071.57 + | 19.1519 + 6 | 2014.73 + 7 | 3145.11 + 5 | 3738.29 + 8 | 6037.67 + 11 | NaN +(10 rows) + select avg(cfloat8) from aggfns where cfloat8 > 0; avg ------------------ @@ -1303,6 +2100,21 @@ select s, avg(cfloat8) from aggfns where cfloat8 > 0 group by s order by avg(cfl 0 | 25.0776526587937 (10 rows) +select ss, avg(cfloat8) from aggfns where cfloat8 > 0 group by ss order by avg(cfloat8), ss limit 10; + ss | avg +----+------------------ + | 16.6705740293345 + 11 | 16.9860875451313 + 6 | 24.9229571834467 + 9 | 24.933601739557 + 8 | 24.9404756362227 + 4 | 24.9719502302445 + 7 | 24.9965050319499 + 5 | 25.0141908239782 + 3 | 25.0352176289523 + 0 | 25.0776526587937 +(10 rows) + select max(cfloat8) from aggfns where cfloat8 > 0; max ------------------ @@ -1324,6 +2136,21 @@ select s, max(cfloat8) from aggfns where cfloat8 > 0 group by s order by max(cfl 9 | 49.9995574122295 (10 rows) +select ss, max(cfloat8) from aggfns where cfloat8 > 0 group by ss order by max(cfloat8), ss limit 10; + ss | max +----+------------------ + | 46.3985309237614 + 5 | 49.9874341068789 + 3 | 49.9890822684392 + 6 | 49.9939429108053 + 8 | 49.9963666079566 + 0 | 49.9965498689562 + 7 | 49.9973275698721 + 11 | 49.9975695507601 + 4 | 49.9978997278959 + 9 | 49.9995574122295 +(10 rows) + select min(cfloat8) from aggfns where cfloat8 > 0; min ---------------------- @@ -1345,6 +2172,21 @@ select s, min(cfloat8) from aggfns where cfloat8 > 0 group by s order by min(cfl 1 | 13 (10 rows) +select ss, min(cfloat8) from aggfns where cfloat8 > 0 group by ss order by min(cfloat8), ss limit 10; + ss | min +----+---------------------- + 4 | 0.000765081495046616 + 7 | 0.000956561416387558 + 6 | 0.00179046764969826 + 0 | 0.00247885473072529 + 11 | 0.00441970769315958 + 3 | 0.00545482616871595 + 5 | 0.00628724228590727 + 9 | 0.0187294092029333 + 8 | 0.0195798231288791 + | 0.312147964723408 +(10 rows) + select stddev(cfloat8) from aggfns where cfloat8 > 0; stddev ------------------ @@ -1366,6 +2208,21 @@ select s, stddev(cfloat8) from aggfns where cfloat8 > 0 group by s order by stdd 8 | 14.507225286092 (10 rows) +select ss, stddev(cfloat8) from aggfns where cfloat8 > 0 group by ss order by stddev(cfloat8), ss limit 10; + ss | stddev +----+------------------ + 11 | 10.0892977778207 + 9 | 14.3145979997847 + 3 | 14.3656116060957 + 4 | 14.4158826742614 + 6 | 14.4175557556357 + 5 | 14.4400766885504 + 0 | 14.4509605112521 + 7 | 14.4643374353136 + 8 | 14.507225286092 + | 15.8897779049656 +(10 rows) + select sum(cfloat8) from aggfns where cfloat8 > 0; sum ------------------ @@ -1387,6 +2244,21 @@ select s, sum(cfloat8) from aggfns where cfloat8 > 0 group by s order by sum(cfl 1 | 260000 (10 rows) +select ss, sum(cfloat8) from aggfns where cfloat8 > 0 group by ss order by sum(cfloat8), ss limit 10; + ss | sum +----+------------------ + | 216.717462381348 + 4 | 246523.092672974 + 0 | 247792.285921541 + 9 | 247964.669299894 + 8 | 248157.732580416 + 3 | 249100.415408076 + 5 | 249441.510896711 + 7 | 250489.97692517 + 6 | 251647.098681261 + 11 | 511009.457707731 +(10 rows) + select avg(cint2) from aggfns where cfloat8 > 0; avg ---------------------- @@ -1408,6 +2280,21 @@ select s, avg(cint2) from aggfns where cfloat8 > 0 group by s order by avg(cint2 5 | 153.6364822808954924 (10 rows) +select ss, avg(cint2) from aggfns where cfloat8 > 0 group by ss order by avg(cint2), ss limit 10; + ss | avg +----+------------------------ + | -2431.3076923076923077 + 9 | -192.8237544036235531 + 3 | -156.9368272809576501 + 7 | -142.7671027664036752 + 4 | -119.1966149792236749 + 6 | -98.2421689135606661 + 8 | -1.6297525648762824 + 11 | 7.3528100356037667 + 0 | 28.7771364925070879 + 5 | 153.6364822808954924 +(10 rows) + select count(cint2) from aggfns where cfloat8 > 0; count -------- @@ -1429,6 +2316,21 @@ select s, count(cint2) from aggfns where cfloat8 > 0 group by s order by count(c 1 | 19981 (10 rows) +select ss, count(cint2) from aggfns where cfloat8 > 0 group by ss order by count(cint2), ss limit 10; + ss | count +----+------- + | 13 + 4 | 9867 + 0 | 9876 + 9 | 9935 + 3 | 9941 + 8 | 9942 + 5 | 9961 + 7 | 10013 + 6 | 10088 + 11 | 30053 +(10 rows) + select max(cint2) from aggfns where cfloat8 > 0; max ------- @@ -1450,6 +2352,21 @@ select s, max(cint2) from aggfns where cfloat8 > 0 group by s order by max(cint2 9 | 16383 (10 rows) +select ss, max(cint2) from aggfns where cfloat8 > 0 group by ss order by max(cint2), ss limit 10; + ss | max +----+------- + | 7971 + 3 | 16380 + 8 | 16380 + 5 | 16381 + 6 | 16381 + 7 | 16381 + 0 | 16383 + 4 | 16383 + 9 | 16383 + 11 | 16383 +(10 rows) + select min(cint2) from aggfns where cfloat8 > 0; min -------- @@ -1471,6 +2388,21 @@ select s, min(cint2) from aggfns where cfloat8 > 0 group by s order by min(cint2 9 | -16375 (10 rows) +select ss, min(cint2) from aggfns where cfloat8 > 0 group by ss order by min(cint2), ss limit 10; + ss | min +----+-------- + 0 | -16383 + 4 | -16383 + 6 | -16383 + 8 | -16382 + 5 | -16381 + 7 | -16380 + 3 | -16378 + 11 | -16378 + 9 | -16375 + | -16100 +(10 rows) + select stddev(cint2) from aggfns where cfloat8 > 0; stddev ------------------- @@ -1492,6 +2424,21 @@ select s, stddev(cint2) from aggfns where cfloat8 > 0 group by s order by stddev 1 | 9528.039076724276 (10 rows) +select ss, stddev(cint2) from aggfns where cfloat8 > 0 group by ss order by stddev(cint2), ss limit 10; + ss | stddev +----+------------------- + | 7759.524506314969 + 5 | 9422.095841513016 + 6 | 9433.502305093184 + 9 | 9441.945023643920 + 4 | 9447.849754018911 + 7 | 9460.956887483220 + 3 | 9463.490872675688 + 8 | 9466.374225763893 + 11 | 9488.645998388904 + 0 | 9519.824544774386 +(10 rows) + select sum(cint2) from aggfns where cfloat8 > 0; sum ---------- @@ -1513,6 +2460,21 @@ select s, sum(cint2) from aggfns where cfloat8 > 0 group by s order by sum(cint2 1 | 1837240 (10 rows) +select ss, sum(cint2) from aggfns where cfloat8 > 0 group by ss order by sum(cint2), ss limit 10; + ss | sum +----+---------- + 9 | -1915704 + 3 | -1560109 + 7 | -1429527 + 4 | -1176113 + 6 | -991067 + | -31607 + 8 | -16203 + 11 | 220974 + 0 | 284203 + 5 | 1530373 +(10 rows) + select avg(cint4) from aggfns where cfloat8 > 0; avg --------------------- @@ -1534,6 +2496,21 @@ select s, avg(cint4) from aggfns where cfloat8 > 0 group by s order by avg(cint4 3 | 170.6088527551942186 (10 rows) +select ss, avg(cint4) from aggfns where cfloat8 > 0 group by ss order by avg(cint4), ss limit 10; + ss | avg +----+----------------------- + 9 | -227.0452488687782805 + 6 | -94.7697335842329405 + 4 | -40.9285858995137763 + 7 | -7.9618800518910288 + 11 | -4.2226765057838053 + 8 | 30.7776884422110553 + 5 | 70.0002005615724027 + 0 | 78.5152312518975812 + 3 | 169.6967839195979899 + | 868.6923076923076923 +(10 rows) + select max(cint4) from aggfns where cfloat8 > 0; max ------- @@ -1555,6 +2532,21 @@ select s, max(cint4) from aggfns where cfloat8 > 0 group by s order by max(cint4 1 | 16383 (10 rows) +select ss, max(cint4) from aggfns where cfloat8 > 0 group by ss order by max(cint4), ss limit 10; + ss | max +----+------- + | 14812 + 3 | 16379 + 5 | 16379 + 7 | 16379 + 0 | 16380 + 6 | 16380 + 9 | 16381 + 4 | 16382 + 8 | 16382 + 11 | 16383 +(10 rows) + select min(cint4) from aggfns where cfloat8 > 0; min -------- @@ -1576,6 +2568,21 @@ select s, min(cint4) from aggfns where cfloat8 > 0 group by s order by min(cint4 8 | -16377 (10 rows) +select ss, min(cint4) from aggfns where cfloat8 > 0 group by ss order by min(cint4), ss limit 10; + ss | min +----+-------- + 7 | -16383 + 11 | -16383 + 0 | -16382 + 9 | -16382 + 5 | -16380 + 3 | -16379 + 4 | -16378 + 6 | -16378 + 8 | -16377 + | -15907 +(10 rows) + select stddev(cint4) from aggfns where cfloat8 > 0; stddev ------------------- @@ -1597,6 +2604,21 @@ select s, stddev(cint4) from aggfns where cfloat8 > 0 group by s order by stddev 3 | 9509.065450373130 (10 rows) +select ss, stddev(cint4) from aggfns where cfloat8 > 0 group by ss order by stddev(cint4), ss limit 10; + ss | stddev +----+------------------- + | 8985.945186647640 + 0 | 9368.404782340758 + 6 | 9385.470128440942 + 8 | 9411.536015886790 + 4 | 9416.391322858156 + 11 | 9460.260597896060 + 9 | 9474.284943213442 + 5 | 9475.929892556881 + 7 | 9500.872262505529 + 3 | 9510.123363067463 +(10 rows) + select sum(cint4) from aggfns where cfloat8 > 0; sum --------- @@ -1618,6 +2640,21 @@ select s, sum(cint4) from aggfns where cfloat8 > 0 group by s order by sum(cint4 3 | 1699776 (10 rows) +select ss, sum(cint4) from aggfns where cfloat8 > 0 group by ss order by sum(cint4), ss limit 10; + ss | sum +----+---------- + 9 | -2257965 + 6 | -956890 + 4 | -404047 + 11 | -127035 + 7 | -79786 + | 11293 + 8 | 306238 + 5 | 698042 + 0 | 775809 + 3 | 1688483 +(10 rows) + select avg(cint8) from aggfns where cfloat8 > 0; avg --------------------- @@ -1639,6 +2676,21 @@ select s, avg(cint8) from aggfns where cfloat8 > 0 group by s order by avg(cint8 2 | 148.9026206075044669 (10 rows) +select ss, avg(cint8) from aggfns where cfloat8 > 0 group by ss order by avg(cint8), ss limit 10; + ss | avg +----+------------------------ + 8 | -166.4501507537688442 + 5 | -78.9197753710389089 + 4 | -61.5197528363047002 + 6 | -32.8705556105773992 + 7 | 1.15707015267937331604 + 11 | 33.0028919026725170 + 0 | 42.9815808116587390 + 9 | 44.5682252388134741 + 3 | 106.1022110552763819 + | 2876.8461538461538462 +(10 rows) + select max(cint8) from aggfns where cfloat8 > 0; max ------- @@ -1660,6 +2712,21 @@ select s, max(cint8) from aggfns where cfloat8 > 0 group by s order by max(cint8 5 | 16383 (10 rows) +select ss, max(cint8) from aggfns where cfloat8 > 0 group by ss order by max(cint8), ss limit 10; + ss | max +----+------- + | 13750 + 7 | 16378 + 6 | 16379 + 0 | 16380 + 8 | 16380 + 3 | 16381 + 4 | 16382 + 9 | 16382 + 5 | 16383 + 11 | 16383 +(10 rows) + select min(cint8) from aggfns where cfloat8 > 0; min -------- @@ -1681,6 +2748,21 @@ select s, min(cint8) from aggfns where cfloat8 > 0 group by s order by min(cint8 3 | -16378 (10 rows) +select ss, min(cint8) from aggfns where cfloat8 > 0 group by ss order by min(cint8), ss limit 10; + ss | min +----+-------- + 7 | -16383 + 8 | -16383 + 11 | -16383 + 5 | -16382 + 4 | -16381 + 6 | -16381 + 9 | -16380 + 0 | -16379 + 3 | -16378 + | -11918 +(10 rows) + select sum(cint8) from aggfns where cfloat8 > 0; sum --------- @@ -1702,6 +2784,21 @@ select s, sum(cint8) from aggfns where cfloat8 > 0 group by s order by sum(cint8 2 | 1500045 (10 rows) +select ss, sum(cint8) from aggfns where cfloat8 > 0 group by ss order by sum(cint8), ss limit 10; + ss | sum +----+---------- + 8 | -1656179 + 5 | -786988 + 4 | -607323 + 6 | -331894 + 7 | 11595 + | 37399 + 0 | 424701 + 9 | 443231 + 11 | 992859 + 3 | 1055717 +(10 rows) + select max(cts) from aggfns where cfloat8 > 0; max -------------------------- @@ -1723,6 +2820,21 @@ select s, max(cts) from aggfns where cfloat8 > 0 group by s order by max(cts), s 9 | Sat Jan 02 02:01:01 2021 (10 rows) +select ss, max(cts) from aggfns where cfloat8 > 0 group by ss order by max(cts), ss limit 10; + ss | max +----+-------------------------- + 0 | Fri Jan 01 01:01:01 2021 + 3 | Fri Jan 01 09:21:01 2021 + | Fri Jan 01 09:21:01 2021 + 4 | Fri Jan 01 12:07:41 2021 + 11 | Fri Jan 01 12:07:41 2021 + 5 | Fri Jan 01 14:54:21 2021 + 6 | Fri Jan 01 17:41:01 2021 + 7 | Fri Jan 01 20:27:41 2021 + 8 | Fri Jan 01 23:14:21 2021 + 9 | Sat Jan 02 02:01:01 2021 +(10 rows) + select min(cts) from aggfns where cfloat8 > 0; min -------------------------- @@ -1744,6 +2856,21 @@ select s, min(cts) from aggfns where cfloat8 > 0 group by s order by min(cts), s 9 | Sat Jan 02 02:01:01 2021 (10 rows) +select ss, min(cts) from aggfns where cfloat8 > 0 group by ss order by min(cts), ss limit 10; + ss | min +----+-------------------------- + 0 | Fri Jan 01 01:01:01 2021 + 11 | Fri Jan 01 03:47:41 2021 + 3 | Fri Jan 01 09:21:01 2021 + | Fri Jan 01 09:21:01 2021 + 4 | Fri Jan 01 12:07:41 2021 + 5 | Fri Jan 01 14:54:21 2021 + 6 | Fri Jan 01 17:41:01 2021 + 7 | Fri Jan 01 20:27:41 2021 + 8 | Fri Jan 01 23:14:21 2021 + 9 | Sat Jan 02 02:01:01 2021 +(10 rows) + select max(ctstz) from aggfns where cfloat8 > 0; max ------------------------------ @@ -1765,6 +2892,21 @@ select s, max(ctstz) from aggfns where cfloat8 > 0 group by s order by max(ctstz 9 | Sat Jan 02 02:01:01 2021 PST (10 rows) +select ss, max(ctstz) from aggfns where cfloat8 > 0 group by ss order by max(ctstz), ss limit 10; + ss | max +----+------------------------------ + 0 | Fri Jan 01 01:01:01 2021 PST + 3 | Fri Jan 01 09:21:01 2021 PST + | Fri Jan 01 09:21:01 2021 PST + 4 | Fri Jan 01 12:07:41 2021 PST + 11 | Fri Jan 01 12:07:41 2021 PST + 5 | Fri Jan 01 14:54:21 2021 PST + 6 | Fri Jan 01 17:41:01 2021 PST + 7 | Fri Jan 01 20:27:41 2021 PST + 8 | Fri Jan 01 23:14:21 2021 PST + 9 | Sat Jan 02 02:01:01 2021 PST +(10 rows) + select min(ctstz) from aggfns where cfloat8 > 0; min ------------------------------ @@ -1786,6 +2928,21 @@ select s, min(ctstz) from aggfns where cfloat8 > 0 group by s order by min(ctstz 9 | Sat Jan 02 02:01:01 2021 PST (10 rows) +select ss, min(ctstz) from aggfns where cfloat8 > 0 group by ss order by min(ctstz), ss limit 10; + ss | min +----+------------------------------ + 0 | Fri Jan 01 01:01:01 2021 PST + 11 | Fri Jan 01 03:47:41 2021 PST + 3 | Fri Jan 01 09:21:01 2021 PST + | Fri Jan 01 09:21:01 2021 PST + 4 | Fri Jan 01 12:07:41 2021 PST + 5 | Fri Jan 01 14:54:21 2021 PST + 6 | Fri Jan 01 17:41:01 2021 PST + 7 | Fri Jan 01 20:27:41 2021 PST + 8 | Fri Jan 01 23:14:21 2021 PST + 9 | Sat Jan 02 02:01:01 2021 PST +(10 rows) + select avg(s) from aggfns where cfloat8 > 0; avg -------------------- @@ -1807,6 +2964,21 @@ select s, avg(s) from aggfns where cfloat8 > 0 group by s order by avg(s), s lim 9 | 9.0000000000000000 (10 rows) +select ss, avg(s) from aggfns where cfloat8 > 0 group by ss order by avg(s), ss limit 10; + ss | avg +----+------------------------ + 0 | 0.00000000000000000000 + 11 | 1.3358595931392102 + 3 | 3.0000000000000000 + | 3.0000000000000000 + 4 | 4.0000000000000000 + 5 | 5.0000000000000000 + 6 | 6.0000000000000000 + 7 | 7.0000000000000000 + 8 | 8.0000000000000000 + 9 | 9.0000000000000000 +(10 rows) + select count(s) from aggfns where cfloat8 > 0; count -------- @@ -1828,6 +3000,21 @@ select s, count(s) from aggfns where cfloat8 > 0 group by s order by count(s), s 1 | 20000 (10 rows) +select ss, count(s) from aggfns where cfloat8 > 0 group by ss order by count(s), ss limit 10; + ss | count +----+------- + | 13 + 4 | 9872 + 0 | 9881 + 9 | 9945 + 3 | 9950 + 8 | 9950 + 5 | 9972 + 7 | 10021 + 6 | 10097 + 11 | 30084 +(10 rows) + select max(s) from aggfns where cfloat8 > 0; max ----- @@ -1849,6 +3036,21 @@ select s, max(s) from aggfns where cfloat8 > 0 group by s order by max(s), s lim 9 | 9 (10 rows) +select ss, max(s) from aggfns where cfloat8 > 0 group by ss order by max(s), ss limit 10; + ss | max +----+----- + 0 | 0 + 3 | 3 + | 3 + 4 | 4 + 11 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 +(10 rows) + select min(s) from aggfns where cfloat8 > 0; min ----- @@ -1870,6 +3072,21 @@ select s, min(s) from aggfns where cfloat8 > 0 group by s order by min(s), s lim 9 | 9 (10 rows) +select ss, min(s) from aggfns where cfloat8 > 0 group by ss order by min(s), ss limit 10; + ss | min +----+----- + 0 | 0 + 11 | 1 + 3 | 3 + | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 +(10 rows) + select stddev(s) from aggfns where cfloat8 > 0; stddev -------------------- @@ -1891,6 +3108,21 @@ select s, stddev(s) from aggfns where cfloat8 > 0 group by s order by stddev(s), 9 | 0 (10 rows) +select ss, stddev(s) from aggfns where cfloat8 > 0 group by ss order by stddev(s), ss limit 10; + ss | stddev +----+------------------------ + 0 | 0 + 3 | 0 + 4 | 0 + 5 | 0 + 6 | 0 + 7 | 0 + 8 | 0 + 9 | 0 + | 0 + 11 | 0.47440470436008342899 +(10 rows) + select sum(s) from aggfns where cfloat8 > 0; sum -------- @@ -1912,6 +3144,21 @@ select s, sum(s) from aggfns where cfloat8 > 0 group by s order by sum(s), s lim 9 | 89505 (10 rows) +select ss, sum(s) from aggfns where cfloat8 > 0 group by ss order by sum(s), ss limit 10; + ss | sum +----+------- + 0 | 0 + | 39 + 3 | 29850 + 4 | 39488 + 11 | 40188 + 5 | 49860 + 6 | 60582 + 7 | 70147 + 8 | 79600 + 9 | 89505 +(10 rows) + select avg(ss) from aggfns where cfloat8 > 0; avg -------------------- @@ -1933,6 +3180,21 @@ select s, avg(ss) from aggfns where cfloat8 > 0 group by s order by avg(ss), s l 2 | 11.0000000000000000 (10 rows) +select ss, avg(ss) from aggfns where cfloat8 > 0 group by ss order by avg(ss), ss limit 10; + ss | avg +----+------------------------ + 0 | 0.00000000000000000000 + 3 | 3.0000000000000000 + 4 | 4.0000000000000000 + 5 | 5.0000000000000000 + 6 | 6.0000000000000000 + 7 | 7.0000000000000000 + 8 | 8.0000000000000000 + 9 | 9.0000000000000000 + 11 | 11.0000000000000000 + | +(10 rows) + select max(ss) from aggfns where cfloat8 > 0; max ----- @@ -1954,6 +3216,21 @@ select s, max(ss) from aggfns where cfloat8 > 0 group by s order by max(ss), s l 4 | 11 (10 rows) +select ss, max(ss) from aggfns where cfloat8 > 0 group by ss order by max(ss), ss limit 10; + ss | max +----+----- + 0 | 0 + 3 | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 + 11 | 11 + | +(10 rows) + select min(ss) from aggfns where cfloat8 > 0; min ----- @@ -1975,6 +3252,21 @@ select s, min(ss) from aggfns where cfloat8 > 0 group by s order by min(ss), s l 2 | 11 (10 rows) +select ss, min(ss) from aggfns where cfloat8 > 0 group by ss order by min(ss), ss limit 10; + ss | min +----+----- + 0 | 0 + 3 | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 + 11 | 11 + | +(10 rows) + select stddev(ss) from aggfns where cfloat8 > 0; stddev -------------------- @@ -1996,6 +3288,21 @@ select s, stddev(ss) from aggfns where cfloat8 > 0 group by s order by stddev(ss 4 | 0.22257569540261848080 (10 rows) +select ss, stddev(ss) from aggfns where cfloat8 > 0 group by ss order by stddev(ss), ss limit 10; + ss | stddev +----+-------- + 0 | 0 + 3 | 0 + 4 | 0 + 5 | 0 + 6 | 0 + 7 | 0 + 8 | 0 + 9 | 0 + 11 | 0 + | +(10 rows) + select sum(ss) from aggfns where cfloat8 > 0; sum -------- @@ -2017,6 +3324,21 @@ select s, sum(ss) from aggfns where cfloat8 > 0 group by s order by sum(ss), s l 1 | 220000 (10 rows) +select ss, sum(ss) from aggfns where cfloat8 > 0 group by ss order by sum(ss), ss limit 10; + ss | sum +----+-------- + 0 | 0 + 3 | 29850 + 4 | 39488 + 5 | 49860 + 6 | 60582 + 7 | 70147 + 8 | 79600 + 9 | 89505 + 11 | 330924 + | +(10 rows) + select max(t) from aggfns where cfloat8 > 0; max -------- @@ -2038,6 +3360,21 @@ select s, max(t) from aggfns where cfloat8 > 0 group by s order by max(t), s lim 9 | 110000 (10 rows) +select ss, max(t) from aggfns where cfloat8 > 0 group by ss order by max(t), ss limit 10; + ss | max +----+-------- + 0 | 19999 + | 49491 + 3 | 49999 + 11 | 59192 + 4 | 60000 + 5 | 70000 + 6 | 79998 + 7 | 89995 + 8 | 99997 + 9 | 110000 +(10 rows) + select min(t) from aggfns where cfloat8 > 0; min ----- @@ -2059,6 +3396,21 @@ select s, min(t) from aggfns where cfloat8 > 0 group by s order by min(t), s lim 9 | 90002 (10 rows) +select ss, min(t) from aggfns where cfloat8 > 0 group by ss order by min(t), ss limit 10; + ss | min +----+------- + 0 | 1 + 11 | 10001 + 3 | 30001 + | 30537 + 4 | 40003 + 5 | 50001 + 6 | 60002 + 7 | 70001 + 8 | 80003 + 9 | 90002 +(10 rows) + select count(*) from aggfns where cfloat8 <= 0; count ------- @@ -2079,6 +3431,21 @@ select s, count(*) from aggfns where cfloat8 <= 0 group by s order by count(*), 0 | 10119 (9 rows) +select ss, count(*) from aggfns where cfloat8 <= 0 group by ss order by count(*), ss limit 10; + ss | count +----+------- + | 6 + 6 | 9903 + 11 | 9935 + 7 | 9979 + 5 | 10028 + 3 | 10031 + 8 | 10050 + 9 | 10055 + 4 | 10109 + 0 | 10119 +(10 rows) + select max(cdate) from aggfns where cfloat8 <= 0; max ------------ @@ -2099,6 +3466,21 @@ select s, max(cdate) from aggfns where cfloat8 <= 0 group by s order by max(cdat 9 | 06-01-2267 (9 rows) +select ss, max(cdate) from aggfns where cfloat8 <= 0 group by ss order by max(cdate), ss limit 10; + ss | max +----+------------ + 0 | 01-01-2021 + 3 | 02-21-2103 + | 02-21-2103 + 4 | 07-09-2130 + 11 | 07-09-2130 + 5 | 11-24-2157 + 6 | 04-11-2185 + 7 | 08-28-2212 + 8 | 01-14-2240 + 9 | 06-01-2267 +(10 rows) + select min(cdate) from aggfns where cfloat8 <= 0; min ------------ @@ -2119,6 +3501,21 @@ select s, min(cdate) from aggfns where cfloat8 <= 0 group by s order by min(cdat 9 | 06-01-2267 (9 rows) +select ss, min(cdate) from aggfns where cfloat8 <= 0 group by ss order by min(cdate), ss limit 10; + ss | min +----+------------ + 0 | 01-01-2021 + 11 | 10-05-2075 + 3 | 02-21-2103 + | 02-21-2103 + 4 | 07-09-2130 + 5 | 11-24-2157 + 6 | 04-11-2185 + 7 | 08-28-2212 + 8 | 01-14-2240 + 9 | 06-01-2267 +(10 rows) + select avg(cfloat4) from aggfns where cfloat8 <= 0; avg ---------- @@ -2139,6 +3536,21 @@ select s, avg(cfloat4) from aggfns where cfloat8 <= 0 group by s order by avg(cf 2 | Infinity (9 rows) +select ss, avg(cfloat4) from aggfns where cfloat8 <= 0 group by ss order by avg(cfloat4), ss limit 10; + ss | avg +----+-------------------- + | -7.61213672161102 + 9 | -0.376175993822296 + 5 | -0.351281471733702 + 3 | -0.323676224863234 + 6 | -0.215785538185229 + 7 | 0.0690012062121504 + 4 | 0.113266462457489 + 8 | 0.308099926433512 + 0 | 0.497406092427368 + 11 | Infinity +(10 rows) + select max(cfloat4) from aggfns where cfloat8 <= 0; max ---------- @@ -2159,6 +3571,21 @@ select s, max(cfloat4) from aggfns where cfloat8 <= 0 group by s order by max(cf 2 | Infinity (9 rows) +select ss, max(cfloat4) from aggfns where cfloat8 <= 0 group by ss order by max(cfloat4), ss limit 10; + ss | max +----+---------- + | 43.8334 + 5 | 49.9753 + 9 | 49.9899 + 7 | 49.992 + 6 | 49.9938 + 4 | 49.9946 + 3 | 49.9979 + 0 | 49.9995 + 8 | 49.9997 + 11 | Infinity +(10 rows) + select min(cfloat4) from aggfns where cfloat8 <= 0; min ---------- @@ -2179,6 +3606,21 @@ select s, min(cfloat4) from aggfns where cfloat8 <= 0 group by s order by min(cf 3 | -49.974 (9 rows) +select ss, min(cfloat4) from aggfns where cfloat8 <= 0 group by ss order by min(cfloat4), ss limit 10; + ss | min +----+---------- + 4 | -49.9999 + 6 | -49.9995 + 11 | -49.9991 + 7 | -49.9984 + 0 | -49.9949 + 5 | -49.9942 + 9 | -49.9874 + 8 | -49.9853 + 3 | -49.974 + | -45.4083 +(10 rows) + select stddev(cfloat4) from aggfns where cfloat8 <= 0; stddev -------- @@ -2199,6 +3641,21 @@ select s, stddev(cfloat4) from aggfns where cfloat8 <= 0 group by s order by std 2 | NaN (9 rows) +select ss, stddev(cfloat4) from aggfns where cfloat8 <= 0 group by ss order by stddev(cfloat4), ss limit 10; + ss | stddev +----+------------------ + 0 | 28.7188352112159 + 3 | 28.7564997868619 + 4 | 28.7937148382071 + 7 | 28.8547648614793 + 6 | 28.89882973622 + 8 | 28.9050890855561 + 9 | 28.9126192916064 + 5 | 29.1278202173095 + | 34.8729157239149 + 11 | NaN +(10 rows) + select sum(cfloat4) from aggfns where cfloat8 <= 0; sum ---------- @@ -2219,6 +3676,21 @@ select s, sum(cfloat4) from aggfns where cfloat8 <= 0 group by s order by sum(cf 2 | Infinity (9 rows) +select ss, sum(cfloat4) from aggfns where cfloat8 <= 0 group by ss order by sum(cfloat4), ss limit 10; + ss | sum +----+---------- + 9 | -3782.45 + 5 | -3522.65 + 3 | -3246.8 + 6 | -2136.92 + | -45.6728 + 7 | 688.563 + 4 | 1145.01 + 8 | 3096.4 + 0 | 5033.25 + 11 | Infinity +(10 rows) + select avg(cfloat8) from aggfns where cfloat8 <= 0; avg ------------------- @@ -2239,6 +3711,21 @@ select s, avg(cfloat8) from aggfns where cfloat8 <= 0 group by s order by avg(cf 5 | -24.7870942066272 (9 rows) +select ss, avg(cfloat8) from aggfns where cfloat8 <= 0 group by ss order by avg(cfloat8), ss limit 10; + ss | avg +----+------------------- + 7 | -25.229255062715 + 8 | -25.2270239386592 + 3 | -25.1388045035744 + 0 | -25.0944548448943 + 6 | -25.0686778438405 + 9 | -24.8892608135943 + 11 | -24.858866008083 + 4 | -24.8295616508204 + 5 | -24.7870942066272 + | -18.9533624914475 +(10 rows) + select max(cfloat8) from aggfns where cfloat8 <= 0; max ---------------------- @@ -2259,6 +3746,21 @@ select s, max(cfloat8) from aggfns where cfloat8 <= 0 group by s order by max(cf 2 | -0.00172397121787071 (9 rows) +select ss, max(cfloat8) from aggfns where cfloat8 <= 0 group by ss order by max(cfloat8), ss limit 10; + ss | max +----+---------------------- + | -5.18986904062331 + 0 | -0.00547224190086126 + 9 | -0.00466627534478903 + 4 | -0.0041270861402154 + 6 | -0.00408347696065903 + 7 | -0.00273226760327816 + 3 | -0.00268903095275164 + 5 | -0.00228420831263065 + 8 | -0.00182925723493099 + 11 | -0.00172397121787071 +(10 rows) + select min(cfloat8) from aggfns where cfloat8 <= 0; min ------------------- @@ -2279,6 +3781,21 @@ select s, min(cfloat8) from aggfns where cfloat8 <= 0 group by s order by min(cf 8 | -49.9897602945566 (9 rows) +select ss, min(cfloat8) from aggfns where cfloat8 <= 0 group by ss order by min(cfloat8), ss limit 10; + ss | min +----+------------------- + 0 | -49.9994775978848 + 11 | -49.9985320260748 + 4 | -49.9983572866768 + 3 | -49.9977725092322 + 6 | -49.9967515002936 + 9 | -49.992344272323 + 5 | -49.9921301845461 + 7 | -49.99003498815 + 8 | -49.9897602945566 + | -38.5084833716974 +(10 rows) + select stddev(cfloat8) from aggfns where cfloat8 <= 0; stddev ------------------ @@ -2299,6 +3816,21 @@ select s, stddev(cfloat8) from aggfns where cfloat8 <= 0 group by s order by std 0 | 14.5136612753879 (9 rows) +select ss, stddev(cfloat8) from aggfns where cfloat8 <= 0 group by ss order by stddev(cfloat8), ss limit 10; + ss | stddev +----+------------------ + 7 | 14.4030112329563 + 11 | 14.4033336871388 + 6 | 14.4144870413512 + 3 | 14.4335904065982 + 4 | 14.4339025361113 + 5 | 14.4378475427373 + 9 | 14.445355480345 + 8 | 14.4532419971748 + 0 | 14.5136612753879 + | 15.4584765893444 +(10 rows) + select sum(cfloat8) from aggfns where cfloat8 <= 0; sum ------------------- @@ -2319,6 +3851,21 @@ select s, sum(cfloat8) from aggfns where cfloat8 <= 0 group by s order by sum(cf 2 | -246743.521314557 (9 rows) +select ss, sum(cfloat8) from aggfns where cfloat8 <= 0 group by ss order by sum(cfloat8), ss limit 10; + ss | sum +----+------------------- + 0 | -253930.788575485 + 8 | -253531.590583525 + 3 | -252167.347975355 + 7 | -251762.736270833 + 4 | -251002.038728143 + 9 | -250261.517480691 + 5 | -248564.980704058 + 6 | -248255.116687552 + 11 | -246972.833790304 + | -113.720174948685 +(10 rows) + select avg(cint2) from aggfns where cfloat8 <= 0; avg ---------------------- @@ -2339,6 +3886,21 @@ select s, avg(cint2) from aggfns where cfloat8 <= 0 group by s order by avg(cint 9 | 147.3351582719490344 (9 rows) +select ss, avg(cint2) from aggfns where cfloat8 <= 0 group by ss order by avg(cint2), ss limit 10; + ss | avg +----+----------------------- + 8 | -256.1267058471959359 + 11 | -158.1923851732473811 + 3 | -32.6703921764294981 + 6 | -23.1764884261599110 + 0 | 6.6666006927263731 + 7 | 31.4203451043338684 + 4 | 61.9965329370975731 + 5 | 66.6813373253493014 + 9 | 147.3351582719490344 + | 935.3333333333333333 +(10 rows) + select count(cint2) from aggfns where cfloat8 <= 0; count ------- @@ -2359,6 +3921,21 @@ select s, count(cint2) from aggfns where cfloat8 <= 0 group by s order by count( 0 | 10105 (9 rows) +select ss, count(cint2) from aggfns where cfloat8 <= 0 group by ss order by count(cint2), ss limit 10; + ss | count +----+------- + | 6 + 6 | 9893 + 11 | 9928 + 7 | 9968 + 5 | 10020 + 3 | 10021 + 8 | 10039 + 9 | 10046 + 4 | 10095 + 0 | 10105 +(10 rows) + select max(cint2) from aggfns where cfloat8 <= 0; max ------- @@ -2379,6 +3956,21 @@ select s, max(cint2) from aggfns where cfloat8 <= 0 group by s order by max(cint 6 | 16383 (9 rows) +select ss, max(cint2) from aggfns where cfloat8 <= 0 group by ss order by max(cint2), ss limit 10; + ss | max +----+------- + | 16362 + 7 | 16376 + 9 | 16376 + 3 | 16378 + 0 | 16381 + 5 | 16381 + 11 | 16381 + 8 | 16382 + 4 | 16383 + 6 | 16383 +(10 rows) + select min(cint2) from aggfns where cfloat8 <= 0; min -------- @@ -2399,6 +3991,21 @@ select s, min(cint2) from aggfns where cfloat8 <= 0 group by s order by min(cint 9 | -16374 (9 rows) +select ss, min(cint2) from aggfns where cfloat8 <= 0 group by ss order by min(cint2), ss limit 10; + ss | min +----+-------- + 0 | -16383 + 5 | -16383 + 6 | -16383 + 7 | -16382 + 8 | -16382 + 11 | -16382 + 3 | -16381 + 4 | -16379 + 9 | -16374 + | -7696 +(10 rows) + select stddev(cint2) from aggfns where cfloat8 <= 0; stddev ------------------- @@ -2419,6 +4026,21 @@ select s, stddev(cint2) from aggfns where cfloat8 <= 0 group by s order by stdde 4 | 9517.027301293118 (9 rows) +select ss, stddev(cint2) from aggfns where cfloat8 <= 0 group by ss order by stddev(cint2), ss limit 10; + ss | stddev +----+-------------------- + 0 | 9451.115288155243 + 9 | 9456.028731464701 + 7 | 9463.041992703462 + 3 | 9485.440311868001 + 8 | 9487.451140540082 + 6 | 9502.509922580216 + 11 | 9510.413974851870 + 5 | 9513.243501566793 + 4 | 9518.051043653511 + | 10051.146773710285 +(10 rows) + select sum(cint2) from aggfns where cfloat8 <= 0; sum ---------- @@ -2439,6 +4061,21 @@ select s, sum(cint2) from aggfns where cfloat8 <= 0 group by s order by sum(cint 9 | 1480129 (9 rows) +select ss, sum(cint2) from aggfns where cfloat8 <= 0 group by ss order by sum(cint2), ss limit 10; + ss | sum +----+---------- + 8 | -2571256 + 11 | -1570534 + 3 | -327390 + 6 | -229285 + | 5612 + 0 | 67366 + 7 | 313198 + 4 | 625855 + 5 | 668147 + 9 | 1480129 +(10 rows) + select avg(cint4) from aggfns where cfloat8 <= 0; avg --------------------- @@ -2459,6 +4096,21 @@ select s, avg(cint4) from aggfns where cfloat8 <= 0 group by s order by avg(cint 5 | 136.0287195851615477 (9 rows) +select ss, avg(cint4) from aggfns where cfloat8 <= 0 group by ss order by avg(cint4), ss limit 10; + ss | avg +----+----------------------- + 8 | -88.7033830845771144 + 7 | -77.4082573404148712 + 11 | -53.3737292400603926 + 3 | -32.1038779782673711 + 0 | -21.8140132424152584 + 6 | -10.7283651418761991 + 9 | 20.8253605171556440 + 4 | 59.1279058264912454 + 5 | 136.0287195851615477 + | 5077.1666666666666667 +(10 rows) + select max(cint4) from aggfns where cfloat8 <= 0; max ------- @@ -2479,6 +4131,21 @@ select s, max(cint4) from aggfns where cfloat8 <= 0 group by s order by max(cint 9 | 16383 (9 rows) +select ss, max(cint4) from aggfns where cfloat8 <= 0 group by ss order by max(cint4), ss limit 10; + ss | max +----+------- + | 13078 + 5 | 16364 + 7 | 16378 + 3 | 16379 + 11 | 16381 + 0 | 16383 + 4 | 16383 + 6 | 16383 + 8 | 16383 + 9 | 16383 +(10 rows) + select min(cint4) from aggfns where cfloat8 <= 0; min -------- @@ -2499,6 +4166,21 @@ select s, min(cint4) from aggfns where cfloat8 <= 0 group by s order by min(cint 5 | -16374 (9 rows) +select ss, min(cint4) from aggfns where cfloat8 <= 0 group by ss order by min(cint4), ss limit 10; + ss | min +----+-------- + 0 | -16383 + 3 | -16382 + 4 | -16382 + 6 | -16382 + 8 | -16382 + 9 | -16381 + 7 | -16379 + 11 | -16377 + 5 | -16374 + | -8992 +(10 rows) + select stddev(cint4) from aggfns where cfloat8 <= 0; stddev ------------------- @@ -2519,6 +4201,21 @@ select s, stddev(cint4) from aggfns where cfloat8 <= 0 group by s order by stdde 5 | 9533.551517829360 (9 rows) +select ss, stddev(cint4) from aggfns where cfloat8 <= 0 group by ss order by stddev(cint4), ss limit 10; + ss | stddev +----+------------------- + 9 | 9377.745829196558 + 11 | 9422.029173765748 + 6 | 9436.031206307503 + 3 | 9439.178404000439 + 0 | 9444.372352979574 + 4 | 9468.093604068949 + 7 | 9470.920199125109 + 8 | 9488.579674823607 + 5 | 9533.551517829360 + | 10351.23962464 +(10 rows) + select sum(cint4) from aggfns where cfloat8 <= 0; sum --------- @@ -2539,6 +4236,21 @@ select s, sum(cint4) from aggfns where cfloat8 <= 0 group by s order by sum(cint 5 | 1364096 (9 rows) +select ss, sum(cint4) from aggfns where cfloat8 <= 0 group by ss order by sum(cint4), ss limit 10; + ss | sum +----+--------- + 8 | -891469 + 7 | -772457 + 11 | -530268 + 3 | -322034 + 0 | -220736 + 6 | -106243 + | 30463 + 9 | 209399 + 4 | 597724 + 5 | 1364096 +(10 rows) + select avg(cint8) from aggfns where cfloat8 <= 0; avg ---------------------- @@ -2559,6 +4271,21 @@ select s, avg(cint8) from aggfns where cfloat8 <= 0 group by s order by avg(cint 9 | 78.7373446046742914 (9 rows) +select ss, avg(cint8) from aggfns where cfloat8 <= 0 group by ss order by avg(cint8), ss limit 10; + ss | avg +----+----------------------- + 11 | -161.0356316054353296 + 5 | -84.4558236936577583 + 8 | -71.0010945273631841 + 3 | -30.2171269065895723 + 0 | -11.7269493032908390 + 7 | -5.8845575708988877 + 4 | 26.3155603917301415 + 6 | 57.5590225184287590 + 9 | 78.7373446046742914 + | 1579.8333333333333333 +(10 rows) + select max(cint8) from aggfns where cfloat8 <= 0; max ------- @@ -2579,6 +4306,21 @@ select s, max(cint8) from aggfns where cfloat8 <= 0 group by s order by max(cint 4 | 16383 (9 rows) +select ss, max(cint8) from aggfns where cfloat8 <= 0 group by ss order by max(cint8), ss limit 10; + ss | max +----+------- + | 12678 + 8 | 16379 + 11 | 16379 + 6 | 16380 + 7 | 16380 + 5 | 16381 + 9 | 16381 + 3 | 16382 + 0 | 16383 + 4 | 16383 +(10 rows) + select min(cint8) from aggfns where cfloat8 <= 0; min -------- @@ -2599,6 +4341,21 @@ select s, min(cint8) from aggfns where cfloat8 <= 0 group by s order by min(cint 9 | -16372 (9 rows) +select ss, min(cint8) from aggfns where cfloat8 <= 0 group by ss order by min(cint8), ss limit 10; + ss | min +----+-------- + 0 | -16383 + 6 | -16383 + 8 | -16383 + 5 | -16382 + 4 | -16381 + 7 | -16381 + 3 | -16375 + 11 | -16375 + 9 | -16372 + | -14174 +(10 rows) + select sum(cint8) from aggfns where cfloat8 <= 0; sum ---------- @@ -2619,6 +4376,21 @@ select s, sum(cint8) from aggfns where cfloat8 <= 0 group by s order by sum(cint 9 | 791704 (9 rows) +select ss, sum(cint8) from aggfns where cfloat8 <= 0 group by ss order by sum(cint8), ss limit 10; + ss | sum +----+---------- + 11 | -1599889 + 5 | -846923 + 8 | -713561 + 3 | -303108 + 0 | -118665 + 7 | -58722 + | 9479 + 4 | 266024 + 6 | 570007 + 9 | 791704 +(10 rows) + select max(cts) from aggfns where cfloat8 <= 0; max -------------------------- @@ -2639,6 +4411,21 @@ select s, max(cts) from aggfns where cfloat8 <= 0 group by s order by max(cts), 9 | Sat Jan 02 02:01:01 2021 (9 rows) +select ss, max(cts) from aggfns where cfloat8 <= 0 group by ss order by max(cts), ss limit 10; + ss | max +----+-------------------------- + 0 | Fri Jan 01 01:01:01 2021 + 3 | Fri Jan 01 09:21:01 2021 + | Fri Jan 01 09:21:01 2021 + 4 | Fri Jan 01 12:07:41 2021 + 11 | Fri Jan 01 12:07:41 2021 + 5 | Fri Jan 01 14:54:21 2021 + 6 | Fri Jan 01 17:41:01 2021 + 7 | Fri Jan 01 20:27:41 2021 + 8 | Fri Jan 01 23:14:21 2021 + 9 | Sat Jan 02 02:01:01 2021 +(10 rows) + select min(cts) from aggfns where cfloat8 <= 0; min -------------------------- @@ -2659,6 +4446,21 @@ select s, min(cts) from aggfns where cfloat8 <= 0 group by s order by min(cts), 9 | Sat Jan 02 02:01:01 2021 (9 rows) +select ss, min(cts) from aggfns where cfloat8 <= 0 group by ss order by min(cts), ss limit 10; + ss | min +----+-------------------------- + 0 | Fri Jan 01 01:01:01 2021 + 11 | Fri Jan 01 06:34:21 2021 + 3 | Fri Jan 01 09:21:01 2021 + | Fri Jan 01 09:21:01 2021 + 4 | Fri Jan 01 12:07:41 2021 + 5 | Fri Jan 01 14:54:21 2021 + 6 | Fri Jan 01 17:41:01 2021 + 7 | Fri Jan 01 20:27:41 2021 + 8 | Fri Jan 01 23:14:21 2021 + 9 | Sat Jan 02 02:01:01 2021 +(10 rows) + select max(ctstz) from aggfns where cfloat8 <= 0; max ------------------------------ @@ -2679,6 +4481,21 @@ select s, max(ctstz) from aggfns where cfloat8 <= 0 group by s order by max(ctst 9 | Sat Jan 02 02:01:01 2021 PST (9 rows) +select ss, max(ctstz) from aggfns where cfloat8 <= 0 group by ss order by max(ctstz), ss limit 10; + ss | max +----+------------------------------ + 0 | Fri Jan 01 01:01:01 2021 PST + 3 | Fri Jan 01 09:21:01 2021 PST + | Fri Jan 01 09:21:01 2021 PST + 4 | Fri Jan 01 12:07:41 2021 PST + 11 | Fri Jan 01 12:07:41 2021 PST + 5 | Fri Jan 01 14:54:21 2021 PST + 6 | Fri Jan 01 17:41:01 2021 PST + 7 | Fri Jan 01 20:27:41 2021 PST + 8 | Fri Jan 01 23:14:21 2021 PST + 9 | Sat Jan 02 02:01:01 2021 PST +(10 rows) + select min(ctstz) from aggfns where cfloat8 <= 0; min ------------------------------ @@ -2699,6 +4516,21 @@ select s, min(ctstz) from aggfns where cfloat8 <= 0 group by s order by min(ctst 9 | Sat Jan 02 02:01:01 2021 PST (9 rows) +select ss, min(ctstz) from aggfns where cfloat8 <= 0 group by ss order by min(ctstz), ss limit 10; + ss | min +----+------------------------------ + 0 | Fri Jan 01 01:01:01 2021 PST + 11 | Fri Jan 01 06:34:21 2021 PST + 3 | Fri Jan 01 09:21:01 2021 PST + | Fri Jan 01 09:21:01 2021 PST + 4 | Fri Jan 01 12:07:41 2021 PST + 5 | Fri Jan 01 14:54:21 2021 PST + 6 | Fri Jan 01 17:41:01 2021 PST + 7 | Fri Jan 01 20:27:41 2021 PST + 8 | Fri Jan 01 23:14:21 2021 PST + 9 | Sat Jan 02 02:01:01 2021 PST +(10 rows) + select avg(s) from aggfns where cfloat8 <= 0; avg -------------------- @@ -2719,6 +4551,21 @@ select s, avg(s) from aggfns where cfloat8 <= 0 group by s order by avg(s), s li 9 | 9.0000000000000000 (9 rows) +select ss, avg(s) from aggfns where cfloat8 <= 0 group by ss order by avg(s), ss limit 10; + ss | avg +----+---------------------------- + 0 | 0.000000000000000000000000 + 11 | 2.0018117765475591 + 3 | 3.0000000000000000 + | 3.0000000000000000 + 4 | 4.0000000000000000 + 5 | 5.0000000000000000 + 6 | 6.0000000000000000 + 7 | 7.0000000000000000 + 8 | 8.0000000000000000 + 9 | 9.0000000000000000 +(10 rows) + select count(s) from aggfns where cfloat8 <= 0; count ------- @@ -2739,6 +4586,21 @@ select s, count(s) from aggfns where cfloat8 <= 0 group by s order by count(s), 0 | 10119 (9 rows) +select ss, count(s) from aggfns where cfloat8 <= 0 group by ss order by count(s), ss limit 10; + ss | count +----+------- + | 6 + 6 | 9903 + 11 | 9935 + 7 | 9979 + 5 | 10028 + 3 | 10031 + 8 | 10050 + 9 | 10055 + 4 | 10109 + 0 | 10119 +(10 rows) + select max(s) from aggfns where cfloat8 <= 0; max ----- @@ -2759,6 +4621,21 @@ select s, max(s) from aggfns where cfloat8 <= 0 group by s order by max(s), s li 9 | 9 (9 rows) +select ss, max(s) from aggfns where cfloat8 <= 0 group by ss order by max(s), ss limit 10; + ss | max +----+----- + 0 | 0 + 3 | 3 + | 3 + 4 | 4 + 11 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 +(10 rows) + select min(s) from aggfns where cfloat8 <= 0; min ----- @@ -2779,6 +4656,21 @@ select s, min(s) from aggfns where cfloat8 <= 0 group by s order by min(s), s li 9 | 9 (9 rows) +select ss, min(s) from aggfns where cfloat8 <= 0 group by ss order by min(s), ss limit 10; + ss | min +----+----- + 0 | 0 + 11 | 2 + 3 | 3 + | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 +(10 rows) + select stddev(s) from aggfns where cfloat8 <= 0; stddev -------------------- @@ -2799,6 +4691,21 @@ select s, stddev(s) from aggfns where cfloat8 <= 0 group by s order by stddev(s) 9 | 0 (9 rows) +select ss, stddev(s) from aggfns where cfloat8 <= 0 group by ss order by stddev(s), ss limit 10; + ss | stddev +----+------------------------ + 0 | 0 + 3 | 0 + 4 | 0 + 5 | 0 + 6 | 0 + 7 | 0 + 8 | 0 + 9 | 0 + | 0 + 11 | 0.06017171256636552646 +(10 rows) + select sum(s) from aggfns where cfloat8 <= 0; sum -------- @@ -2819,6 +4726,21 @@ select s, sum(s) from aggfns where cfloat8 <= 0 group by s order by sum(s), s li 9 | 90495 (9 rows) +select ss, sum(s) from aggfns where cfloat8 <= 0 group by ss order by sum(s), ss limit 10; + ss | sum +----+------- + 0 | 0 + | 18 + 11 | 19888 + 3 | 30093 + 4 | 40436 + 5 | 50140 + 6 | 59418 + 7 | 69853 + 8 | 80400 + 9 | 90495 +(10 rows) + select avg(ss) from aggfns where cfloat8 <= 0; avg -------------------- @@ -2839,6 +4761,21 @@ select s, avg(ss) from aggfns where cfloat8 <= 0 group by s order by avg(ss), s 2 | 11.0000000000000000 (9 rows) +select ss, avg(ss) from aggfns where cfloat8 <= 0 group by ss order by avg(ss), ss limit 10; + ss | avg +----+---------------------------- + 0 | 0.000000000000000000000000 + 3 | 3.0000000000000000 + 4 | 4.0000000000000000 + 5 | 5.0000000000000000 + 6 | 6.0000000000000000 + 7 | 7.0000000000000000 + 8 | 8.0000000000000000 + 9 | 9.0000000000000000 + 11 | 11.0000000000000000 + | +(10 rows) + select max(ss) from aggfns where cfloat8 <= 0; max ----- @@ -2859,6 +4796,21 @@ select s, max(ss) from aggfns where cfloat8 <= 0 group by s order by max(ss), s 4 | 11 (9 rows) +select ss, max(ss) from aggfns where cfloat8 <= 0 group by ss order by max(ss), ss limit 10; + ss | max +----+----- + 0 | 0 + 3 | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 + 11 | 11 + | +(10 rows) + select min(ss) from aggfns where cfloat8 <= 0; min ----- @@ -2879,6 +4831,21 @@ select s, min(ss) from aggfns where cfloat8 <= 0 group by s order by min(ss), s 2 | 11 (9 rows) +select ss, min(ss) from aggfns where cfloat8 <= 0 group by ss order by min(ss), ss limit 10; + ss | min +----+----- + 0 | 0 + 3 | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 + 11 | 11 + | +(10 rows) + select stddev(ss) from aggfns where cfloat8 <= 0; stddev -------------------- @@ -2899,6 +4866,21 @@ select s, stddev(ss) from aggfns where cfloat8 <= 0 group by s order by stddev(s 4 | 0.20868929911309143893 (9 rows) +select ss, stddev(ss) from aggfns where cfloat8 <= 0 group by ss order by stddev(ss), ss limit 10; + ss | stddev +----+-------- + 0 | 0 + 3 | 0 + 4 | 0 + 5 | 0 + 6 | 0 + 7 | 0 + 8 | 0 + 9 | 0 + 11 | 0 + | +(10 rows) + select sum(ss) from aggfns where cfloat8 <= 0; sum -------- @@ -2919,6 +4901,21 @@ select s, sum(ss) from aggfns where cfloat8 <= 0 group by s order by sum(ss), s 2 | 109186 (9 rows) +select ss, sum(ss) from aggfns where cfloat8 <= 0 group by ss order by sum(ss), ss limit 10; + ss | sum +----+-------- + 0 | 0 + 3 | 30093 + 4 | 40436 + 5 | 50140 + 6 | 59418 + 7 | 69853 + 8 | 80400 + 9 | 90495 + 11 | 109285 + | +(10 rows) + select max(t) from aggfns where cfloat8 <= 0; max -------- @@ -2939,6 +4936,21 @@ select s, max(t) from aggfns where cfloat8 <= 0 group by s order by max(t), s li 9 | 109998 (9 rows) +select ss, max(t) from aggfns where cfloat8 <= 0 group by ss order by max(t), ss limit 10; + ss | max +----+-------- + 0 | 20000 + | 48438 + 3 | 50000 + 11 | 58135 + 4 | 59998 + 5 | 69999 + 6 | 80000 + 7 | 90000 + 8 | 100000 + 9 | 109998 +(10 rows) + select min(t) from aggfns where cfloat8 <= 0; min ----- @@ -2959,6 +4971,21 @@ select s, min(t) from aggfns where cfloat8 <= 0 group by s order by min(t), s li 9 | 90001 (9 rows) +select ss, min(t) from aggfns where cfloat8 <= 0 group by ss order by min(t), ss limit 10; + ss | min +----+------- + 0 | 8 + 11 | 20003 + 3 | 30002 + | 33696 + 4 | 40001 + 5 | 50004 + 6 | 60001 + 7 | 70002 + 8 | 80001 + 9 | 90001 +(10 rows) + select count(*) from aggfns where cfloat8 < 1000; count -------- @@ -2980,6 +5007,21 @@ select s, count(*) from aggfns where cfloat8 < 1000 group by s order by count(*) 9 | 20000 (10 rows) +select ss, count(*) from aggfns where cfloat8 < 1000 group by ss order by count(*), ss limit 10; + ss | count +----+------- + | 19 + 3 | 19981 + 4 | 19981 + 0 | 20000 + 5 | 20000 + 6 | 20000 + 7 | 20000 + 8 | 20000 + 9 | 20000 + 11 | 40019 +(10 rows) + select max(cdate) from aggfns where cfloat8 < 1000; max ------------ @@ -3001,6 +5043,21 @@ select s, max(cdate) from aggfns where cfloat8 < 1000 group by s order by max(cd 9 | 06-01-2267 (10 rows) +select ss, max(cdate) from aggfns where cfloat8 < 1000 group by ss order by max(cdate), ss limit 10; + ss | max +----+------------ + 0 | 01-01-2021 + 3 | 02-21-2103 + | 02-21-2103 + 4 | 07-09-2130 + 11 | 07-09-2130 + 5 | 11-24-2157 + 6 | 04-11-2185 + 7 | 08-28-2212 + 8 | 01-14-2240 + 9 | 06-01-2267 +(10 rows) + select min(cdate) from aggfns where cfloat8 < 1000; min ------------ @@ -3022,6 +5079,21 @@ select s, min(cdate) from aggfns where cfloat8 < 1000 group by s order by min(cd 9 | 06-01-2267 (10 rows) +select ss, min(cdate) from aggfns where cfloat8 < 1000 group by ss order by min(cdate), ss limit 10; + ss | min +----+------------ + 0 | 01-01-2021 + 11 | 05-19-2048 + 3 | 02-21-2103 + | 02-21-2103 + 4 | 07-09-2130 + 5 | 11-24-2157 + 6 | 04-11-2185 + 7 | 08-28-2212 + 8 | 01-14-2240 + 9 | 06-01-2267 +(10 rows) + select avg(cfloat4) from aggfns where cfloat8 < 1000; avg ----- @@ -3043,6 +5115,21 @@ select s, avg(cfloat4) from aggfns where cfloat8 < 1000 group by s order by avg( 1 | NaN (10 rows) +select ss, avg(cfloat4) from aggfns where cfloat8 < 1000 group by ss order by avg(cfloat4), ss limit 10; + ss | avg +----+---------------------- + 3 | -Infinity + | -1.39583652270468 + 9 | -0.292700759558938 + 4 | -0.169252917487522 + 6 | -0.00610964622725733 + 5 | 0.0107821527590975 + 0 | 0.0862269837114494 + 7 | 0.19168354413514 + 8 | 0.456703752867272 + 11 | NaN +(10 rows) + select max(cfloat4) from aggfns where cfloat8 < 1000; max ----- @@ -3064,6 +5151,21 @@ select s, max(cfloat4) from aggfns where cfloat8 < 1000 group by s order by max( 1 | NaN (10 rows) +select ss, max(cfloat4) from aggfns where cfloat8 < 1000 group by ss order by max(cfloat4), ss limit 10; + ss | max +----+--------- + | 47.2047 + 9 | 49.9899 + 4 | 49.9946 + 6 | 49.9956 + 7 | 49.9969 + 3 | 49.9979 + 5 | 49.9992 + 0 | 49.9995 + 8 | 49.9997 + 11 | NaN +(10 rows) + select min(cfloat4) from aggfns where cfloat8 < 1000; min ----------- @@ -3085,6 +5187,21 @@ select s, min(cfloat4) from aggfns where cfloat8 < 1000 group by s order by min( 9 | -49.9911 (10 rows) +select ss, min(cfloat4) from aggfns where cfloat8 < 1000 group by ss order by min(cfloat4), ss limit 10; + ss | min +----+----------- + 3 | -Infinity + 4 | -49.9999 + 6 | -49.9995 + 7 | -49.9984 + 8 | -49.9969 + 0 | -49.9949 + 5 | -49.9942 + 9 | -49.9911 + | -45.4083 + 11 | NaN +(10 rows) + select stddev(cfloat4) from aggfns where cfloat8 < 1000; stddev -------- @@ -3106,6 +5223,21 @@ select s, stddev(cfloat4) from aggfns where cfloat8 < 1000 group by s order by s 3 | NaN (10 rows) +select ss, stddev(cfloat4) from aggfns where cfloat8 < 1000 group by ss order by stddev(cfloat4), ss limit 10; + ss | stddev +----+------------------ + 0 | 28.7274163912974 + 7 | 28.7892027644318 + 4 | 28.8220943927954 + 9 | 28.8426424990846 + 6 | 28.9190577543738 + 8 | 29.0040125904064 + 5 | 29.0213532270614 + | 30.6324072248673 + 3 | NaN + 11 | NaN +(10 rows) + select sum(cfloat4) from aggfns where cfloat8 < 1000; sum ----- @@ -3127,6 +5259,21 @@ select s, sum(cfloat4) from aggfns where cfloat8 < 1000 group by s order by sum( 1 | NaN (10 rows) +select ss, sum(cfloat4) from aggfns where cfloat8 < 1000 group by ss order by sum(cfloat4), ss limit 10; + ss | sum +----+----------- + 3 | -Infinity + 9 | -5854.02 + 4 | -3381.84 + 6 | -122.193 + | -26.5209 + 5 | 215.643 + 0 | 1724.54 + 7 | 3833.67 + 8 | 9134.08 + 11 | NaN +(10 rows) + select avg(cfloat8) from aggfns where cfloat8 < 1000; avg ----------------- @@ -3148,6 +5295,21 @@ select s, avg(cfloat8) from aggfns where cfloat8 < 1000 group by s order by avg( 1 | 13 (10 rows) +select ss, avg(cfloat8) from aggfns where cfloat8 < 1000 group by ss order by avg(cfloat8), ss limit 10; + ss | avg +----+-------------------- + 0 | -0.306925132697215 + 8 | -0.268692900155438 + 4 | -0.224160255000712 + 3 | -0.153492446187821 + 9 | -0.114842409039848 + 7 | -0.063637967283139 + 5 | 0.0438265096326359 + 6 | 0.169599099685438 + | 5.42090986487701 + 11 | 6.59778165165114 +(10 rows) + select max(cfloat8) from aggfns where cfloat8 < 1000; max ------------------ @@ -3169,6 +5331,21 @@ select s, max(cfloat8) from aggfns where cfloat8 < 1000 group by s order by max( 9 | 49.9995574122295 (10 rows) +select ss, max(cfloat8) from aggfns where cfloat8 < 1000 group by ss order by max(cfloat8), ss limit 10; + ss | max +----+------------------ + | 46.3985309237614 + 5 | 49.9874341068789 + 3 | 49.9890822684392 + 6 | 49.9939429108053 + 8 | 49.9963666079566 + 0 | 49.9965498689562 + 7 | 49.9973275698721 + 11 | 49.9975695507601 + 4 | 49.9978997278959 + 9 | 49.9995574122295 +(10 rows) + select min(cfloat8) from aggfns where cfloat8 < 1000; min ------------------- @@ -3190,6 +5367,21 @@ select s, min(cfloat8) from aggfns where cfloat8 < 1000 group by s order by min( 1 | 13 (10 rows) +select ss, min(cfloat8) from aggfns where cfloat8 < 1000 group by ss order by min(cfloat8), ss limit 10; + ss | min +----+------------------- + 0 | -49.9994775978848 + 11 | -49.9985320260748 + 4 | -49.9983572866768 + 3 | -49.9977725092322 + 6 | -49.9967515002936 + 9 | -49.992344272323 + 5 | -49.9921301845461 + 7 | -49.99003498815 + 8 | -49.9897602945566 + | -38.5084833716974 +(10 rows) + select stddev(cfloat8) from aggfns where cfloat8 < 1000; stddev ------------------ @@ -3211,6 +5403,21 @@ select s, stddev(cfloat8) from aggfns where cfloat8 < 1000 group by s order by s 7 | 28.9656492103737 (10 rows) +select ss, stddev(cfloat8) from aggfns where cfloat8 < 1000 group by ss order by stddev(cfloat8), ss limit 10; + ss | stddev +----+------------------ + 11 | 21.3262797346004 + | 22.894065438835 + 9 | 28.7642081921344 + 4 | 28.7760615445521 + 5 | 28.7843925303698 + 6 | 28.8543767497508 + 3 | 28.926156595386 + 8 | 28.96331707256 + 0 | 28.9653425568561 + 7 | 28.9656492103736 +(10 rows) + select sum(cfloat8) from aggfns where cfloat8 < 1000; sum ----------------- @@ -3232,6 +5439,21 @@ select s, sum(cfloat8) from aggfns where cfloat8 < 1000 group by s order by sum( 1 | 260000 (10 rows) +select ss, sum(cfloat8) from aggfns where cfloat8 < 1000 group by ss order by sum(cfloat8), ss limit 10; + ss | sum +----+------------------- + 0 | -6138.50265394431 + 8 | -5373.85800310876 + 4 | -4478.94605516922 + 3 | -3066.93256727885 + 9 | -2296.84818079695 + 7 | -1272.75934566278 + | 102.997287432663 + 5 | 876.530192652717 + 6 | 3391.98199370876 + 11 | 264036.623917427 +(10 rows) + select avg(cint2) from aggfns where cfloat8 < 1000; avg ---------------------- @@ -3253,6 +5475,21 @@ select s, avg(cint2) from aggfns where cfloat8 < 1000 group by s order by avg(ci 5 | 110.0305290025524248 (10 rows) +select ss, avg(cint2) from aggfns where cfloat8 < 1000 group by ss order by avg(cint2), ss limit 10; + ss | avg +----+------------------------ + | -1368.1578947368421053 + 8 | -129.4959711726139833 + 3 | -94.5546037471195271 + 6 | -61.0756218407487113 + 7 | -55.8695260497472599 + 11 | -33.7550336409794652 + 4 | -27.5652740206392145 + 9 | -21.7994594865121866 + 0 | 17.5951654071367799 + 5 | 110.0305290025524248 +(10 rows) + select count(cint2) from aggfns where cfloat8 < 1000; count -------- @@ -3274,6 +5511,21 @@ select s, count(cint2) from aggfns where cfloat8 < 1000 group by s order by coun 9 | 19981 (10 rows) +select ss, count(cint2) from aggfns where cfloat8 < 1000 group by ss order by count(cint2), ss limit 10; + ss | count +----+------- + | 19 + 3 | 19962 + 4 | 19962 + 0 | 19981 + 5 | 19981 + 6 | 19981 + 7 | 19981 + 8 | 19981 + 9 | 19981 + 11 | 39981 +(10 rows) + select max(cint2) from aggfns where cfloat8 < 1000; max ------- @@ -3295,6 +5547,21 @@ select s, max(cint2) from aggfns where cfloat8 < 1000 group by s order by max(ci 9 | 16383 (10 rows) +select ss, max(cint2) from aggfns where cfloat8 < 1000 group by ss order by max(cint2), ss limit 10; + ss | max +----+------- + | 16362 + 3 | 16380 + 5 | 16381 + 7 | 16381 + 8 | 16382 + 0 | 16383 + 4 | 16383 + 6 | 16383 + 9 | 16383 + 11 | 16383 +(10 rows) + select min(cint2) from aggfns where cfloat8 < 1000; min -------- @@ -3316,6 +5583,21 @@ select s, min(cint2) from aggfns where cfloat8 < 1000 group by s order by min(ci 9 | -16375 (10 rows) +select ss, min(cint2) from aggfns where cfloat8 < 1000 group by ss order by min(cint2), ss limit 10; + ss | min +----+-------- + 0 | -16383 + 4 | -16383 + 5 | -16383 + 6 | -16383 + 7 | -16382 + 8 | -16382 + 11 | -16382 + 3 | -16381 + 9 | -16375 + | -16100 +(10 rows) + select stddev(cint2) from aggfns where cfloat8 < 1000; stddev ------------------- @@ -3337,6 +5619,21 @@ select s, stddev(cint2) from aggfns where cfloat8 < 1000 group by s order by std 1 | 9528.039076724276 (10 rows) +select ss, stddev(cint2) from aggfns where cfloat8 < 1000 group by ss order by stddev(cint2), ss limit 10; + ss | stddev +----+------------------- + | 8413.549166956554 + 9 | 9450.322790943425 + 7 | 9462.161209850735 + 6 | 9467.569674984571 + 5 | 9467.776835158782 + 3 | 9474.482349111595 + 8 | 9477.586839536066 + 4 | 9483.611454519949 + 0 | 9484.907423282680 + 11 | 9494.206429493352 +(10 rows) + select sum(cint2) from aggfns where cfloat8 < 1000; sum ---------- @@ -3358,6 +5655,21 @@ select s, sum(cint2) from aggfns where cfloat8 < 1000 group by s order by sum(ci 5 | 2198520 (10 rows) +select ss, sum(cint2) from aggfns where cfloat8 < 1000 group by ss order by sum(cint2), ss limit 10; + ss | sum +----+---------- + 8 | -2587459 + 3 | -1887499 + 11 | -1349560 + 6 | -1220352 + 7 | -1116329 + 4 | -550258 + 9 | -435575 + | -25995 + 0 | 351569 + 5 | 2198520 +(10 rows) + select avg(cint4) from aggfns where cfloat8 < 1000; avg --------------------- @@ -3379,6 +5691,21 @@ select s, avg(cint4) from aggfns where cfloat8 < 1000 group by s order by avg(ci 5 | 103.1069000000000000 (10 rows) +select ss, avg(cint4) from aggfns where cfloat8 < 1000 group by ss order by avg(cint4), ss limit 10; + ss | avg +----+----------------------- + 9 | -102.4283000000000000 + 6 | -53.1566500000000000 + 7 | -42.6121500000000000 + 8 | -29.2615500000000000 + 11 | -16.4247732327144606 + 4 | 9.6930584054852110 + 0 | 27.7536500000000000 + 3 | 68.3874180471447875 + 5 | 103.1069000000000000 + | 2197.6842105263157895 +(10 rows) + select max(cint4) from aggfns where cfloat8 < 1000; max ------- @@ -3400,6 +5727,21 @@ select s, max(cint4) from aggfns where cfloat8 < 1000 group by s order by max(ci 9 | 16383 (10 rows) +select ss, max(cint4) from aggfns where cfloat8 < 1000 group by ss order by max(cint4), ss limit 10; + ss | max +----+------- + | 14812 + 3 | 16379 + 5 | 16379 + 7 | 16379 + 0 | 16383 + 4 | 16383 + 6 | 16383 + 8 | 16383 + 9 | 16383 + 11 | 16383 +(10 rows) + select min(cint4) from aggfns where cfloat8 < 1000; min -------- @@ -3421,6 +5763,21 @@ select s, min(cint4) from aggfns where cfloat8 < 1000 group by s order by min(ci 5 | -16380 (10 rows) +select ss, min(cint4) from aggfns where cfloat8 < 1000 group by ss order by min(cint4), ss limit 10; + ss | min +----+-------- + 0 | -16383 + 7 | -16383 + 11 | -16383 + 3 | -16382 + 4 | -16382 + 6 | -16382 + 8 | -16382 + 9 | -16382 + 5 | -16380 + | -15907 +(10 rows) + select stddev(cint4) from aggfns where cfloat8 < 1000; stddev ------------------- @@ -3442,6 +5799,21 @@ select s, stddev(cint4) from aggfns where cfloat8 < 1000 group by s order by std 5 | 9504.684751625578 (10 rows) +select ss, stddev(cint4) from aggfns where cfloat8 < 1000 group by ss order by stddev(cint4), ss limit 10; + ss | stddev +----+------------------- + | 9361.317298404296 + 0 | 9406.815855797801 + 6 | 9410.397911988306 + 9 | 9426.452583637956 + 4 | 9442.480718256247 + 8 | 9450.281544631633 + 11 | 9450.690059613938 + 3 | 9474.873657491443 + 7 | 9485.765898279180 + 5 | 9504.684751625578 +(10 rows) + select sum(cint4) from aggfns where cfloat8 < 1000; sum --------- @@ -3463,6 +5835,21 @@ select s, sum(cint4) from aggfns where cfloat8 < 1000 group by s order by sum(ci 5 | 2062138 (10 rows) +select ss, sum(cint4) from aggfns where cfloat8 < 1000 group by ss order by sum(cint4), ss limit 10; + ss | sum +----+---------- + 9 | -2048566 + 6 | -1063133 + 7 | -852243 + 11 | -657303 + 8 | -585231 + | 41756 + 4 | 193677 + 0 | 555073 + 3 | 1366449 + 5 | 2062138 +(10 rows) + select avg(cint8) from aggfns where cfloat8 < 1000; avg ---------------------- @@ -3484,6 +5871,21 @@ select s, avg(cint8) from aggfns where cfloat8 < 1000 group by s order by avg(ci 9 | 61.7467500000000000 (10 rows) +select ss, avg(cint8) from aggfns where cfloat8 < 1000 group by ss order by avg(cint8), ss limit 10; + ss | avg +----+----------------------- + 8 | -118.4870000000000000 + 5 | -81.6955500000000000 + 4 | -17.0811771182623492 + 11 | -15.1685449411529523 + 7 | -2.3563500000000000 + 6 | 11.9056500000000000 + 0 | 15.3018000000000000 + 3 | 37.6662329212752115 + 9 | 61.7467500000000000 + | 2467.2631578947368421 +(10 rows) + select max(cint8) from aggfns where cfloat8 < 1000; max ------- @@ -3505,6 +5907,21 @@ select s, max(cint8) from aggfns where cfloat8 < 1000 group by s order by max(ci 5 | 16383 (10 rows) +select ss, max(cint8) from aggfns where cfloat8 < 1000 group by ss order by max(cint8), ss limit 10; + ss | max +----+------- + | 13750 + 6 | 16380 + 7 | 16380 + 8 | 16380 + 3 | 16382 + 9 | 16382 + 0 | 16383 + 4 | 16383 + 5 | 16383 + 11 | 16383 +(10 rows) + select min(cint8) from aggfns where cfloat8 < 1000; min -------- @@ -3526,6 +5943,21 @@ select s, min(cint8) from aggfns where cfloat8 < 1000 group by s order by min(ci 3 | -16378 (10 rows) +select ss, min(cint8) from aggfns where cfloat8 < 1000 group by ss order by min(cint8), ss limit 10; + ss | min +----+-------- + 0 | -16383 + 6 | -16383 + 7 | -16383 + 8 | -16383 + 11 | -16383 + 5 | -16382 + 4 | -16381 + 9 | -16380 + 3 | -16378 + | -14174 +(10 rows) + select sum(cint8) from aggfns where cfloat8 < 1000; sum ---------- @@ -3547,6 +5979,21 @@ select s, sum(cint8) from aggfns where cfloat8 < 1000 group by s order by sum(ci 9 | 1234935 (10 rows) +select ss, sum(cint8) from aggfns where cfloat8 < 1000 group by ss order by sum(cint8), ss limit 10; + ss | sum +----+---------- + 8 | -2369740 + 5 | -1633911 + 11 | -607030 + 4 | -341299 + 7 | -47127 + | 46878 + 6 | 238113 + 0 | 306036 + 3 | 752609 + 9 | 1234935 +(10 rows) + select max(cts) from aggfns where cfloat8 < 1000; max -------------------------- @@ -3568,6 +6015,21 @@ select s, max(cts) from aggfns where cfloat8 < 1000 group by s order by max(cts) 9 | Sat Jan 02 02:01:01 2021 (10 rows) +select ss, max(cts) from aggfns where cfloat8 < 1000 group by ss order by max(cts), ss limit 10; + ss | max +----+-------------------------- + 0 | Fri Jan 01 01:01:01 2021 + 3 | Fri Jan 01 09:21:01 2021 + | Fri Jan 01 09:21:01 2021 + 4 | Fri Jan 01 12:07:41 2021 + 11 | Fri Jan 01 12:07:41 2021 + 5 | Fri Jan 01 14:54:21 2021 + 6 | Fri Jan 01 17:41:01 2021 + 7 | Fri Jan 01 20:27:41 2021 + 8 | Fri Jan 01 23:14:21 2021 + 9 | Sat Jan 02 02:01:01 2021 +(10 rows) + select min(cts) from aggfns where cfloat8 < 1000; min -------------------------- @@ -3589,6 +6051,21 @@ select s, min(cts) from aggfns where cfloat8 < 1000 group by s order by min(cts) 9 | Sat Jan 02 02:01:01 2021 (10 rows) +select ss, min(cts) from aggfns where cfloat8 < 1000 group by ss order by min(cts), ss limit 10; + ss | min +----+-------------------------- + 0 | Fri Jan 01 01:01:01 2021 + 11 | Fri Jan 01 03:47:41 2021 + 3 | Fri Jan 01 09:21:01 2021 + | Fri Jan 01 09:21:01 2021 + 4 | Fri Jan 01 12:07:41 2021 + 5 | Fri Jan 01 14:54:21 2021 + 6 | Fri Jan 01 17:41:01 2021 + 7 | Fri Jan 01 20:27:41 2021 + 8 | Fri Jan 01 23:14:21 2021 + 9 | Sat Jan 02 02:01:01 2021 +(10 rows) + select max(ctstz) from aggfns where cfloat8 < 1000; max ------------------------------ @@ -3610,6 +6087,21 @@ select s, max(ctstz) from aggfns where cfloat8 < 1000 group by s order by max(ct 9 | Sat Jan 02 02:01:01 2021 PST (10 rows) +select ss, max(ctstz) from aggfns where cfloat8 < 1000 group by ss order by max(ctstz), ss limit 10; + ss | max +----+------------------------------ + 0 | Fri Jan 01 01:01:01 2021 PST + 3 | Fri Jan 01 09:21:01 2021 PST + | Fri Jan 01 09:21:01 2021 PST + 4 | Fri Jan 01 12:07:41 2021 PST + 11 | Fri Jan 01 12:07:41 2021 PST + 5 | Fri Jan 01 14:54:21 2021 PST + 6 | Fri Jan 01 17:41:01 2021 PST + 7 | Fri Jan 01 20:27:41 2021 PST + 8 | Fri Jan 01 23:14:21 2021 PST + 9 | Sat Jan 02 02:01:01 2021 PST +(10 rows) + select min(ctstz) from aggfns where cfloat8 < 1000; min ------------------------------ @@ -3631,6 +6123,21 @@ select s, min(ctstz) from aggfns where cfloat8 < 1000 group by s order by min(ct 9 | Sat Jan 02 02:01:01 2021 PST (10 rows) +select ss, min(ctstz) from aggfns where cfloat8 < 1000 group by ss order by min(ctstz), ss limit 10; + ss | min +----+------------------------------ + 0 | Fri Jan 01 01:01:01 2021 PST + 11 | Fri Jan 01 03:47:41 2021 PST + 3 | Fri Jan 01 09:21:01 2021 PST + | Fri Jan 01 09:21:01 2021 PST + 4 | Fri Jan 01 12:07:41 2021 PST + 5 | Fri Jan 01 14:54:21 2021 PST + 6 | Fri Jan 01 17:41:01 2021 PST + 7 | Fri Jan 01 20:27:41 2021 PST + 8 | Fri Jan 01 23:14:21 2021 PST + 9 | Sat Jan 02 02:01:01 2021 PST +(10 rows) + select avg(s) from aggfns where cfloat8 < 1000; avg -------------------- @@ -3652,6 +6159,21 @@ select s, avg(s) from aggfns where cfloat8 < 1000 group by s order by avg(s), s 9 | 9.0000000000000000 (10 rows) +select ss, avg(s) from aggfns where cfloat8 < 1000 group by ss order by avg(s), ss limit 10; + ss | avg +----+---------------------------- + 0 | 0.000000000000000000000000 + 11 | 1.5011869362053025 + 3 | 3.0000000000000000 + | 3.0000000000000000 + 4 | 4.0000000000000000 + 5 | 5.0000000000000000 + 6 | 6.0000000000000000 + 7 | 7.0000000000000000 + 8 | 8.0000000000000000 + 9 | 9.0000000000000000 +(10 rows) + select count(s) from aggfns where cfloat8 < 1000; count -------- @@ -3673,6 +6195,21 @@ select s, count(s) from aggfns where cfloat8 < 1000 group by s order by count(s) 9 | 20000 (10 rows) +select ss, count(s) from aggfns where cfloat8 < 1000 group by ss order by count(s), ss limit 10; + ss | count +----+------- + | 19 + 3 | 19981 + 4 | 19981 + 0 | 20000 + 5 | 20000 + 6 | 20000 + 7 | 20000 + 8 | 20000 + 9 | 20000 + 11 | 40019 +(10 rows) + select max(s) from aggfns where cfloat8 < 1000; max ----- @@ -3694,6 +6231,21 @@ select s, max(s) from aggfns where cfloat8 < 1000 group by s order by max(s), s 9 | 9 (10 rows) +select ss, max(s) from aggfns where cfloat8 < 1000 group by ss order by max(s), ss limit 10; + ss | max +----+----- + 0 | 0 + 3 | 3 + | 3 + 4 | 4 + 11 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 +(10 rows) + select min(s) from aggfns where cfloat8 < 1000; min ----- @@ -3715,6 +6267,21 @@ select s, min(s) from aggfns where cfloat8 < 1000 group by s order by min(s), s 9 | 9 (10 rows) +select ss, min(s) from aggfns where cfloat8 < 1000 group by ss order by min(s), ss limit 10; + ss | min +----+----- + 0 | 0 + 11 | 1 + 3 | 3 + | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 +(10 rows) + select stddev(s) from aggfns where cfloat8 < 1000; stddev -------------------- @@ -3736,6 +6303,21 @@ select s, stddev(s) from aggfns where cfloat8 < 1000 group by s order by stddev( 9 | 0 (10 rows) +select ss, stddev(s) from aggfns where cfloat8 < 1000 group by ss order by stddev(s), ss limit 10; + ss | stddev +----+------------------------ + 0 | 0 + 3 | 0 + 4 | 0 + 5 | 0 + 6 | 0 + 7 | 0 + 8 | 0 + 9 | 0 + | 0 + 11 | 0.50284545977155885187 +(10 rows) + select sum(s) from aggfns where cfloat8 < 1000; sum -------- @@ -3757,6 +6339,21 @@ select s, sum(s) from aggfns where cfloat8 < 1000 group by s order by sum(s), s 9 | 180000 (10 rows) +select ss, sum(s) from aggfns where cfloat8 < 1000 group by ss order by sum(s), ss limit 10; + ss | sum +----+-------- + 0 | 0 + | 57 + 3 | 59943 + 11 | 60076 + 4 | 79924 + 5 | 100000 + 6 | 120000 + 7 | 140000 + 8 | 160000 + 9 | 180000 +(10 rows) + select avg(ss) from aggfns where cfloat8 < 1000; avg -------------------- @@ -3778,6 +6375,21 @@ select s, avg(ss) from aggfns where cfloat8 < 1000 group by s order by avg(ss), 2 | 11.0000000000000000 (10 rows) +select ss, avg(ss) from aggfns where cfloat8 < 1000 group by ss order by avg(ss), ss limit 10; + ss | avg +----+---------------------------- + 0 | 0.000000000000000000000000 + 3 | 3.0000000000000000 + 4 | 4.0000000000000000 + 5 | 5.0000000000000000 + 6 | 6.0000000000000000 + 7 | 7.0000000000000000 + 8 | 8.0000000000000000 + 9 | 9.0000000000000000 + 11 | 11.0000000000000000 + | +(10 rows) + select max(ss) from aggfns where cfloat8 < 1000; max ----- @@ -3799,6 +6411,21 @@ select s, max(ss) from aggfns where cfloat8 < 1000 group by s order by max(ss), 4 | 11 (10 rows) +select ss, max(ss) from aggfns where cfloat8 < 1000 group by ss order by max(ss), ss limit 10; + ss | max +----+----- + 0 | 0 + 3 | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 + 11 | 11 + | +(10 rows) + select min(ss) from aggfns where cfloat8 < 1000; min ----- @@ -3820,6 +6447,21 @@ select s, min(ss) from aggfns where cfloat8 < 1000 group by s order by min(ss), 2 | 11 (10 rows) +select ss, min(ss) from aggfns where cfloat8 < 1000 group by ss order by min(ss), ss limit 10; + ss | min +----+----- + 0 | 0 + 3 | 3 + 4 | 4 + 5 | 5 + 6 | 6 + 7 | 7 + 8 | 8 + 9 | 9 + 11 | 11 + | +(10 rows) + select stddev(ss) from aggfns where cfloat8 < 1000; stddev -------------------- @@ -3841,6 +6483,21 @@ select s, stddev(ss) from aggfns where cfloat8 < 1000 group by s order by stddev 4 | 0.21565737387148452722 (10 rows) +select ss, stddev(ss) from aggfns where cfloat8 < 1000 group by ss order by stddev(ss), ss limit 10; + ss | stddev +----+-------- + 0 | 0 + 3 | 0 + 4 | 0 + 5 | 0 + 6 | 0 + 7 | 0 + 8 | 0 + 9 | 0 + 11 | 0 + | +(10 rows) + select sum(ss) from aggfns where cfloat8 < 1000; sum --------- @@ -3862,6 +6519,21 @@ select s, sum(ss) from aggfns where cfloat8 < 1000 group by s order by sum(ss), 2 | 220000 (10 rows) +select ss, sum(ss) from aggfns where cfloat8 < 1000 group by ss order by sum(ss), ss limit 10; + ss | sum +----+-------- + 0 | 0 + 3 | 59943 + 4 | 79924 + 5 | 100000 + 6 | 120000 + 7 | 140000 + 8 | 160000 + 9 | 180000 + 11 | 440209 + | +(10 rows) + select max(t) from aggfns where cfloat8 < 1000; max -------- @@ -3883,6 +6555,21 @@ select s, max(t) from aggfns where cfloat8 < 1000 group by s order by max(t), s 9 | 110000 (10 rows) +select ss, max(t) from aggfns where cfloat8 < 1000 group by ss order by max(t), ss limit 10; + ss | max +----+-------- + 0 | 20000 + | 49491 + 3 | 50000 + 11 | 59192 + 4 | 60000 + 5 | 70000 + 6 | 80000 + 7 | 90000 + 8 | 100000 + 9 | 110000 +(10 rows) + select min(t) from aggfns where cfloat8 < 1000; min ----- @@ -3904,6 +6591,21 @@ select s, min(t) from aggfns where cfloat8 < 1000 group by s order by min(t), s 9 | 90001 (10 rows) +select ss, min(t) from aggfns where cfloat8 < 1000 group by ss order by min(t), ss limit 10; + ss | min +----+------- + 0 | 1 + 11 | 10001 + 3 | 30001 + | 30537 + 4 | 40001 + 5 | 50001 + 6 | 60001 + 7 | 70001 + 8 | 80001 + 9 | 90001 +(10 rows) + select count(*) from aggfns where cfloat8 > 1000; count ------- @@ -3915,6 +6617,11 @@ select s, count(*) from aggfns where cfloat8 > 1000 group by s order by count(*) ---+------- (0 rows) +select ss, count(*) from aggfns where cfloat8 > 1000 group by ss order by count(*), ss limit 10; + ss | count +----+------- +(0 rows) + select max(cdate) from aggfns where cfloat8 > 1000; max ----- @@ -3926,6 +6633,11 @@ select s, max(cdate) from aggfns where cfloat8 > 1000 group by s order by max(cd ---+----- (0 rows) +select ss, max(cdate) from aggfns where cfloat8 > 1000 group by ss order by max(cdate), ss limit 10; + ss | max +----+----- +(0 rows) + select min(cdate) from aggfns where cfloat8 > 1000; min ----- @@ -3937,6 +6649,11 @@ select s, min(cdate) from aggfns where cfloat8 > 1000 group by s order by min(cd ---+----- (0 rows) +select ss, min(cdate) from aggfns where cfloat8 > 1000 group by ss order by min(cdate), ss limit 10; + ss | min +----+----- +(0 rows) + select avg(cfloat4) from aggfns where cfloat8 > 1000; avg ----- @@ -3948,6 +6665,11 @@ select s, avg(cfloat4) from aggfns where cfloat8 > 1000 group by s order by avg( ---+----- (0 rows) +select ss, avg(cfloat4) from aggfns where cfloat8 > 1000 group by ss order by avg(cfloat4), ss limit 10; + ss | avg +----+----- +(0 rows) + select max(cfloat4) from aggfns where cfloat8 > 1000; max ----- @@ -3959,6 +6681,11 @@ select s, max(cfloat4) from aggfns where cfloat8 > 1000 group by s order by max( ---+----- (0 rows) +select ss, max(cfloat4) from aggfns where cfloat8 > 1000 group by ss order by max(cfloat4), ss limit 10; + ss | max +----+----- +(0 rows) + select min(cfloat4) from aggfns where cfloat8 > 1000; min ----- @@ -3970,6 +6697,11 @@ select s, min(cfloat4) from aggfns where cfloat8 > 1000 group by s order by min( ---+----- (0 rows) +select ss, min(cfloat4) from aggfns where cfloat8 > 1000 group by ss order by min(cfloat4), ss limit 10; + ss | min +----+----- +(0 rows) + select stddev(cfloat4) from aggfns where cfloat8 > 1000; stddev -------- @@ -3981,6 +6713,11 @@ select s, stddev(cfloat4) from aggfns where cfloat8 > 1000 group by s order by s ---+-------- (0 rows) +select ss, stddev(cfloat4) from aggfns where cfloat8 > 1000 group by ss order by stddev(cfloat4), ss limit 10; + ss | stddev +----+-------- +(0 rows) + select sum(cfloat4) from aggfns where cfloat8 > 1000; sum ----- @@ -3992,6 +6729,11 @@ select s, sum(cfloat4) from aggfns where cfloat8 > 1000 group by s order by sum( ---+----- (0 rows) +select ss, sum(cfloat4) from aggfns where cfloat8 > 1000 group by ss order by sum(cfloat4), ss limit 10; + ss | sum +----+----- +(0 rows) + select avg(cfloat8) from aggfns where cfloat8 > 1000; avg ----- @@ -4003,6 +6745,11 @@ select s, avg(cfloat8) from aggfns where cfloat8 > 1000 group by s order by avg( ---+----- (0 rows) +select ss, avg(cfloat8) from aggfns where cfloat8 > 1000 group by ss order by avg(cfloat8), ss limit 10; + ss | avg +----+----- +(0 rows) + select max(cfloat8) from aggfns where cfloat8 > 1000; max ----- @@ -4014,6 +6761,11 @@ select s, max(cfloat8) from aggfns where cfloat8 > 1000 group by s order by max( ---+----- (0 rows) +select ss, max(cfloat8) from aggfns where cfloat8 > 1000 group by ss order by max(cfloat8), ss limit 10; + ss | max +----+----- +(0 rows) + select min(cfloat8) from aggfns where cfloat8 > 1000; min ----- @@ -4025,6 +6777,11 @@ select s, min(cfloat8) from aggfns where cfloat8 > 1000 group by s order by min( ---+----- (0 rows) +select ss, min(cfloat8) from aggfns where cfloat8 > 1000 group by ss order by min(cfloat8), ss limit 10; + ss | min +----+----- +(0 rows) + select stddev(cfloat8) from aggfns where cfloat8 > 1000; stddev -------- @@ -4036,6 +6793,11 @@ select s, stddev(cfloat8) from aggfns where cfloat8 > 1000 group by s order by s ---+-------- (0 rows) +select ss, stddev(cfloat8) from aggfns where cfloat8 > 1000 group by ss order by stddev(cfloat8), ss limit 10; + ss | stddev +----+-------- +(0 rows) + select sum(cfloat8) from aggfns where cfloat8 > 1000; sum ----- @@ -4047,6 +6809,11 @@ select s, sum(cfloat8) from aggfns where cfloat8 > 1000 group by s order by sum( ---+----- (0 rows) +select ss, sum(cfloat8) from aggfns where cfloat8 > 1000 group by ss order by sum(cfloat8), ss limit 10; + ss | sum +----+----- +(0 rows) + select avg(cint2) from aggfns where cfloat8 > 1000; avg ----- @@ -4058,6 +6825,11 @@ select s, avg(cint2) from aggfns where cfloat8 > 1000 group by s order by avg(ci ---+----- (0 rows) +select ss, avg(cint2) from aggfns where cfloat8 > 1000 group by ss order by avg(cint2), ss limit 10; + ss | avg +----+----- +(0 rows) + select count(cint2) from aggfns where cfloat8 > 1000; count ------- @@ -4069,6 +6841,11 @@ select s, count(cint2) from aggfns where cfloat8 > 1000 group by s order by coun ---+------- (0 rows) +select ss, count(cint2) from aggfns where cfloat8 > 1000 group by ss order by count(cint2), ss limit 10; + ss | count +----+------- +(0 rows) + select max(cint2) from aggfns where cfloat8 > 1000; max ----- @@ -4080,6 +6857,11 @@ select s, max(cint2) from aggfns where cfloat8 > 1000 group by s order by max(ci ---+----- (0 rows) +select ss, max(cint2) from aggfns where cfloat8 > 1000 group by ss order by max(cint2), ss limit 10; + ss | max +----+----- +(0 rows) + select min(cint2) from aggfns where cfloat8 > 1000; min ----- @@ -4091,6 +6873,11 @@ select s, min(cint2) from aggfns where cfloat8 > 1000 group by s order by min(ci ---+----- (0 rows) +select ss, min(cint2) from aggfns where cfloat8 > 1000 group by ss order by min(cint2), ss limit 10; + ss | min +----+----- +(0 rows) + select stddev(cint2) from aggfns where cfloat8 > 1000; stddev -------- @@ -4101,6 +6888,11 @@ select s, stddev(cint2) from aggfns where cfloat8 > 1000 group by s order by std ---+-------- (0 rows) +select ss, stddev(cint2) from aggfns where cfloat8 > 1000 group by ss order by stddev(cint2), ss limit 10; + ss | stddev +----+-------- +(0 rows) + select sum(cint2) from aggfns where cfloat8 > 1000; sum ----- @@ -4112,6 +6904,11 @@ select s, sum(cint2) from aggfns where cfloat8 > 1000 group by s order by sum(ci ---+----- (0 rows) +select ss, sum(cint2) from aggfns where cfloat8 > 1000 group by ss order by sum(cint2), ss limit 10; + ss | sum +----+----- +(0 rows) + select avg(cint4) from aggfns where cfloat8 > 1000; avg ----- @@ -4123,6 +6920,11 @@ select s, avg(cint4) from aggfns where cfloat8 > 1000 group by s order by avg(ci ---+----- (0 rows) +select ss, avg(cint4) from aggfns where cfloat8 > 1000 group by ss order by avg(cint4), ss limit 10; + ss | avg +----+----- +(0 rows) + select max(cint4) from aggfns where cfloat8 > 1000; max ----- @@ -4134,6 +6936,11 @@ select s, max(cint4) from aggfns where cfloat8 > 1000 group by s order by max(ci ---+----- (0 rows) +select ss, max(cint4) from aggfns where cfloat8 > 1000 group by ss order by max(cint4), ss limit 10; + ss | max +----+----- +(0 rows) + select min(cint4) from aggfns where cfloat8 > 1000; min ----- @@ -4145,6 +6952,11 @@ select s, min(cint4) from aggfns where cfloat8 > 1000 group by s order by min(ci ---+----- (0 rows) +select ss, min(cint4) from aggfns where cfloat8 > 1000 group by ss order by min(cint4), ss limit 10; + ss | min +----+----- +(0 rows) + select stddev(cint4) from aggfns where cfloat8 > 1000; stddev -------- @@ -4155,6 +6967,11 @@ select s, stddev(cint4) from aggfns where cfloat8 > 1000 group by s order by std ---+-------- (0 rows) +select ss, stddev(cint4) from aggfns where cfloat8 > 1000 group by ss order by stddev(cint4), ss limit 10; + ss | stddev +----+-------- +(0 rows) + select sum(cint4) from aggfns where cfloat8 > 1000; sum ----- @@ -4166,6 +6983,11 @@ select s, sum(cint4) from aggfns where cfloat8 > 1000 group by s order by sum(ci ---+----- (0 rows) +select ss, sum(cint4) from aggfns where cfloat8 > 1000 group by ss order by sum(cint4), ss limit 10; + ss | sum +----+----- +(0 rows) + select avg(cint8) from aggfns where cfloat8 > 1000; avg ----- @@ -4176,6 +6998,11 @@ select s, avg(cint8) from aggfns where cfloat8 > 1000 group by s order by avg(ci ---+----- (0 rows) +select ss, avg(cint8) from aggfns where cfloat8 > 1000 group by ss order by avg(cint8), ss limit 10; + ss | avg +----+----- +(0 rows) + select max(cint8) from aggfns where cfloat8 > 1000; max ----- @@ -4187,6 +7014,11 @@ select s, max(cint8) from aggfns where cfloat8 > 1000 group by s order by max(ci ---+----- (0 rows) +select ss, max(cint8) from aggfns where cfloat8 > 1000 group by ss order by max(cint8), ss limit 10; + ss | max +----+----- +(0 rows) + select min(cint8) from aggfns where cfloat8 > 1000; min ----- @@ -4198,6 +7030,11 @@ select s, min(cint8) from aggfns where cfloat8 > 1000 group by s order by min(ci ---+----- (0 rows) +select ss, min(cint8) from aggfns where cfloat8 > 1000 group by ss order by min(cint8), ss limit 10; + ss | min +----+----- +(0 rows) + select sum(cint8) from aggfns where cfloat8 > 1000; sum ----- @@ -4208,6 +7045,11 @@ select s, sum(cint8) from aggfns where cfloat8 > 1000 group by s order by sum(ci ---+----- (0 rows) +select ss, sum(cint8) from aggfns where cfloat8 > 1000 group by ss order by sum(cint8), ss limit 10; + ss | sum +----+----- +(0 rows) + select max(cts) from aggfns where cfloat8 > 1000; max ----- @@ -4219,6 +7061,11 @@ select s, max(cts) from aggfns where cfloat8 > 1000 group by s order by max(cts) ---+----- (0 rows) +select ss, max(cts) from aggfns where cfloat8 > 1000 group by ss order by max(cts), ss limit 10; + ss | max +----+----- +(0 rows) + select min(cts) from aggfns where cfloat8 > 1000; min ----- @@ -4230,6 +7077,11 @@ select s, min(cts) from aggfns where cfloat8 > 1000 group by s order by min(cts) ---+----- (0 rows) +select ss, min(cts) from aggfns where cfloat8 > 1000 group by ss order by min(cts), ss limit 10; + ss | min +----+----- +(0 rows) + select max(ctstz) from aggfns where cfloat8 > 1000; max ----- @@ -4241,6 +7093,11 @@ select s, max(ctstz) from aggfns where cfloat8 > 1000 group by s order by max(ct ---+----- (0 rows) +select ss, max(ctstz) from aggfns where cfloat8 > 1000 group by ss order by max(ctstz), ss limit 10; + ss | max +----+----- +(0 rows) + select min(ctstz) from aggfns where cfloat8 > 1000; min ----- @@ -4252,6 +7109,11 @@ select s, min(ctstz) from aggfns where cfloat8 > 1000 group by s order by min(ct ---+----- (0 rows) +select ss, min(ctstz) from aggfns where cfloat8 > 1000 group by ss order by min(ctstz), ss limit 10; + ss | min +----+----- +(0 rows) + select avg(s) from aggfns where cfloat8 > 1000; avg ----- @@ -4263,6 +7125,11 @@ select s, avg(s) from aggfns where cfloat8 > 1000 group by s order by avg(s), s ---+----- (0 rows) +select ss, avg(s) from aggfns where cfloat8 > 1000 group by ss order by avg(s), ss limit 10; + ss | avg +----+----- +(0 rows) + select count(s) from aggfns where cfloat8 > 1000; count ------- @@ -4274,6 +7141,11 @@ select s, count(s) from aggfns where cfloat8 > 1000 group by s order by count(s) ---+------- (0 rows) +select ss, count(s) from aggfns where cfloat8 > 1000 group by ss order by count(s), ss limit 10; + ss | count +----+------- +(0 rows) + select max(s) from aggfns where cfloat8 > 1000; max ----- @@ -4285,6 +7157,11 @@ select s, max(s) from aggfns where cfloat8 > 1000 group by s order by max(s), s ---+----- (0 rows) +select ss, max(s) from aggfns where cfloat8 > 1000 group by ss order by max(s), ss limit 10; + ss | max +----+----- +(0 rows) + select min(s) from aggfns where cfloat8 > 1000; min ----- @@ -4296,6 +7173,11 @@ select s, min(s) from aggfns where cfloat8 > 1000 group by s order by min(s), s ---+----- (0 rows) +select ss, min(s) from aggfns where cfloat8 > 1000 group by ss order by min(s), ss limit 10; + ss | min +----+----- +(0 rows) + select stddev(s) from aggfns where cfloat8 > 1000; stddev -------- @@ -4306,6 +7188,11 @@ select s, stddev(s) from aggfns where cfloat8 > 1000 group by s order by stddev( ---+-------- (0 rows) +select ss, stddev(s) from aggfns where cfloat8 > 1000 group by ss order by stddev(s), ss limit 10; + ss | stddev +----+-------- +(0 rows) + select sum(s) from aggfns where cfloat8 > 1000; sum ----- @@ -4317,6 +7204,11 @@ select s, sum(s) from aggfns where cfloat8 > 1000 group by s order by sum(s), s ---+----- (0 rows) +select ss, sum(s) from aggfns where cfloat8 > 1000 group by ss order by sum(s), ss limit 10; + ss | sum +----+----- +(0 rows) + select avg(ss) from aggfns where cfloat8 > 1000; avg ----- @@ -4328,6 +7220,11 @@ select s, avg(ss) from aggfns where cfloat8 > 1000 group by s order by avg(ss), ---+----- (0 rows) +select ss, avg(ss) from aggfns where cfloat8 > 1000 group by ss order by avg(ss), ss limit 10; + ss | avg +----+----- +(0 rows) + select max(ss) from aggfns where cfloat8 > 1000; max ----- @@ -4339,6 +7236,11 @@ select s, max(ss) from aggfns where cfloat8 > 1000 group by s order by max(ss), ---+----- (0 rows) +select ss, max(ss) from aggfns where cfloat8 > 1000 group by ss order by max(ss), ss limit 10; + ss | max +----+----- +(0 rows) + select min(ss) from aggfns where cfloat8 > 1000; min ----- @@ -4350,6 +7252,11 @@ select s, min(ss) from aggfns where cfloat8 > 1000 group by s order by min(ss), ---+----- (0 rows) +select ss, min(ss) from aggfns where cfloat8 > 1000 group by ss order by min(ss), ss limit 10; + ss | min +----+----- +(0 rows) + select stddev(ss) from aggfns where cfloat8 > 1000; stddev -------- @@ -4360,6 +7267,11 @@ select s, stddev(ss) from aggfns where cfloat8 > 1000 group by s order by stddev ---+-------- (0 rows) +select ss, stddev(ss) from aggfns where cfloat8 > 1000 group by ss order by stddev(ss), ss limit 10; + ss | stddev +----+-------- +(0 rows) + select sum(ss) from aggfns where cfloat8 > 1000; sum ----- @@ -4371,6 +7283,11 @@ select s, sum(ss) from aggfns where cfloat8 > 1000 group by s order by sum(ss), ---+----- (0 rows) +select ss, sum(ss) from aggfns where cfloat8 > 1000 group by ss order by sum(ss), ss limit 10; + ss | sum +----+----- +(0 rows) + select max(t) from aggfns where cfloat8 > 1000; max ----- @@ -4382,6 +7299,11 @@ select s, max(t) from aggfns where cfloat8 > 1000 group by s order by max(t), s ---+----- (0 rows) +select ss, max(t) from aggfns where cfloat8 > 1000 group by ss order by max(t), ss limit 10; + ss | max +----+----- +(0 rows) + select min(t) from aggfns where cfloat8 > 1000; min ----- @@ -4393,6 +7315,11 @@ select s, min(t) from aggfns where cfloat8 > 1000 group by s order by min(t), s ---+----- (0 rows) +select ss, min(t) from aggfns where cfloat8 > 1000 group by ss order by min(t), ss limit 10; + ss | min +----+----- +(0 rows) + select avg(cint2) from aggfns where cint2 is null; avg ----- @@ -4414,6 +7341,20 @@ select s, avg(cint2) from aggfns where cint2 is null group by s order by avg(cin 9 | (10 rows) +select ss, avg(cint2) from aggfns where cint2 is null group by ss order by avg(cint2), ss limit 10; + ss | avg +----+----- + 0 | + 3 | + 4 | + 5 | + 6 | + 7 | + 8 | + 9 | + 11 | +(9 rows) + select count(cint2) from aggfns where cint2 is null; count ------- @@ -4435,6 +7376,20 @@ select s, count(cint2) from aggfns where cint2 is null group by s order by count 9 | 0 (10 rows) +select ss, count(cint2) from aggfns where cint2 is null group by ss order by count(cint2), ss limit 10; + ss | count +----+------- + 0 | 0 + 3 | 0 + 4 | 0 + 5 | 0 + 6 | 0 + 7 | 0 + 8 | 0 + 9 | 0 + 11 | 0 +(9 rows) + select max(cint2) from aggfns where cint2 is null; max ----- @@ -4456,6 +7411,20 @@ select s, max(cint2) from aggfns where cint2 is null group by s order by max(cin 9 | (10 rows) +select ss, max(cint2) from aggfns where cint2 is null group by ss order by max(cint2), ss limit 10; + ss | max +----+----- + 0 | + 3 | + 4 | + 5 | + 6 | + 7 | + 8 | + 9 | + 11 | +(9 rows) + select min(cint2) from aggfns where cint2 is null; min ----- @@ -4477,6 +7446,20 @@ select s, min(cint2) from aggfns where cint2 is null group by s order by min(cin 9 | (10 rows) +select ss, min(cint2) from aggfns where cint2 is null group by ss order by min(cint2), ss limit 10; + ss | min +----+----- + 0 | + 3 | + 4 | + 5 | + 6 | + 7 | + 8 | + 9 | + 11 | +(9 rows) + select stddev(cint2) from aggfns where cint2 is null; stddev -------- @@ -4498,6 +7481,20 @@ select s, stddev(cint2) from aggfns where cint2 is null group by s order by stdd 9 | (10 rows) +select ss, stddev(cint2) from aggfns where cint2 is null group by ss order by stddev(cint2), ss limit 10; + ss | stddev +----+-------- + 0 | + 3 | + 4 | + 5 | + 6 | + 7 | + 8 | + 9 | + 11 | +(9 rows) + select sum(cint2) from aggfns where cint2 is null; sum ----- @@ -4519,6 +7516,38 @@ select s, sum(cint2) from aggfns where cint2 is null group by s order by sum(cin 9 | (10 rows) +select ss, sum(cint2) from aggfns where cint2 is null group by ss order by sum(cint2), ss limit 10; + ss | sum +----+----- + 0 | + 3 | + 4 | + 5 | + 6 | + 7 | + 8 | + 9 | + 11 | +(9 rows) + +-- Test multiple aggregate functions as well. +select count(*), count(cint2), min(cfloat4), cint2 from aggfns group by cint2 +order by count(*) desc, cint2 limit 10 +; + count | count | min | cint2 +-------+-------+----------+-------- + 190 | 0 | -49.6644 | + 19 | 19 | -49.5299 | -8743 + 17 | 17 | -48.5497 | -12921 + 17 | 17 | -48.5697 | -701 + 17 | 17 | -47.2641 | 525 + 16 | 16 | -42.41 | -10234 + 16 | 16 | -47.2083 | -4609 + 16 | 16 | -49.9555 | -4261 + 16 | 16 | -35.1643 | -296 + 16 | 16 | -45.4426 | 1373 +(10 rows) + -- Test edge cases for various batch sizes and the filter matching around batch -- end. select count(*) from edges; @@ -4588,3 +7617,46 @@ select s, count(*), min(f1) from edges where f1 = 65 group by 1 order by 1; 12 | 1 | 65 (8 rows) +select ss, count(*), min(f1) from edges where f1 = 63 group by 1 order by 1; + ss | count | min +----+-------+----- + 3 | 1 | 63 + 4 | 1 | 63 + 5 | 1 | 63 + 6 | 1 | 63 + 7 | 1 | 63 + 8 | 1 | 63 + 9 | 1 | 63 + 10 | 1 | 63 + 11 | 1 | 63 + 12 | 1 | 63 +(10 rows) + +select ss, count(*), min(f1) from edges where f1 = 64 group by 1 order by 1; + ss | count | min +----+-------+----- + 4 | 1 | 64 + 5 | 1 | 64 + 6 | 1 | 64 + 7 | 1 | 64 + 8 | 1 | 64 + 9 | 1 | 64 + 10 | 1 | 64 + 11 | 1 | 64 + 12 | 1 | 64 +(9 rows) + +select ss, count(*), min(f1) from edges where f1 = 65 group by 1 order by 1; + ss | count | min +----+-------+----- + 5 | 1 | 65 + 6 | 1 | 65 + 7 | 1 | 65 + 8 | 1 | 65 + 9 | 1 | 65 + 10 | 1 | 65 + 11 | 1 | 65 + 12 | 1 | 65 +(8 rows) + +reset max_parallel_workers_per_gather; diff --git a/tsl/test/expected/vectorized_aggregation.out b/tsl/test/expected/vectorized_aggregation.out index 01f690b743a..79b6b608d6f 100644 --- a/tsl/test/expected/vectorized_aggregation.out +++ b/tsl/test/expected/vectorized_aggregation.out @@ -409,23 +409,23 @@ SELECT sum(segment_by_value) FROM testtable GROUP BY float_value; Output: _hyper_1_1_chunk.float_value, (PARTIAL sum(_hyper_1_1_chunk.segment_by_value)) Workers Planned: 2 -> Parallel Append - -> Partial HashAggregate - Output: _hyper_1_1_chunk.float_value, PARTIAL sum(_hyper_1_1_chunk.segment_by_value) - Group Key: _hyper_1_1_chunk.float_value + -> Custom Scan (VectorAgg) + Output: _hyper_1_1_chunk.float_value, (PARTIAL sum(_hyper_1_1_chunk.segment_by_value)) + Grouping Policy: hashed with single 8-byte key -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_1_chunk Output: _hyper_1_1_chunk.float_value, _hyper_1_1_chunk.segment_by_value -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_11_chunk Output: compress_hyper_2_11_chunk._ts_meta_count, compress_hyper_2_11_chunk.segment_by_value, compress_hyper_2_11_chunk._ts_meta_min_1, compress_hyper_2_11_chunk._ts_meta_max_1, compress_hyper_2_11_chunk."time", compress_hyper_2_11_chunk.int_value, compress_hyper_2_11_chunk.float_value - -> Partial HashAggregate - Output: _hyper_1_2_chunk.float_value, PARTIAL sum(_hyper_1_2_chunk.segment_by_value) - Group Key: _hyper_1_2_chunk.float_value + -> Custom Scan (VectorAgg) + Output: _hyper_1_2_chunk.float_value, (PARTIAL sum(_hyper_1_2_chunk.segment_by_value)) + Grouping Policy: hashed with single 8-byte key -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_2_chunk Output: _hyper_1_2_chunk.float_value, _hyper_1_2_chunk.segment_by_value -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_12_chunk Output: compress_hyper_2_12_chunk._ts_meta_count, compress_hyper_2_12_chunk.segment_by_value, compress_hyper_2_12_chunk._ts_meta_min_1, compress_hyper_2_12_chunk._ts_meta_max_1, compress_hyper_2_12_chunk."time", compress_hyper_2_12_chunk.int_value, compress_hyper_2_12_chunk.float_value - -> Partial HashAggregate - Output: _hyper_1_3_chunk.float_value, PARTIAL sum(_hyper_1_3_chunk.segment_by_value) - Group Key: _hyper_1_3_chunk.float_value + -> Custom Scan (VectorAgg) + Output: _hyper_1_3_chunk.float_value, (PARTIAL sum(_hyper_1_3_chunk.segment_by_value)) + Grouping Policy: hashed with single 8-byte key -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_3_chunk Output: _hyper_1_3_chunk.float_value, _hyper_1_3_chunk.segment_by_value -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_13_chunk @@ -478,23 +478,23 @@ SELECT sum(segment_by_value) FROM testtable GROUP BY int_value; Output: _hyper_1_1_chunk.int_value, (PARTIAL sum(_hyper_1_1_chunk.segment_by_value)) Workers Planned: 2 -> Parallel Append - -> Partial HashAggregate - Output: _hyper_1_1_chunk.int_value, PARTIAL sum(_hyper_1_1_chunk.segment_by_value) - Group Key: _hyper_1_1_chunk.int_value + -> Custom Scan (VectorAgg) + Output: _hyper_1_1_chunk.int_value, (PARTIAL sum(_hyper_1_1_chunk.segment_by_value)) + Grouping Policy: hashed with single 4-byte key -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_1_chunk Output: _hyper_1_1_chunk.int_value, _hyper_1_1_chunk.segment_by_value -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_11_chunk Output: compress_hyper_2_11_chunk._ts_meta_count, compress_hyper_2_11_chunk.segment_by_value, compress_hyper_2_11_chunk._ts_meta_min_1, compress_hyper_2_11_chunk._ts_meta_max_1, compress_hyper_2_11_chunk."time", compress_hyper_2_11_chunk.int_value, compress_hyper_2_11_chunk.float_value - -> Partial HashAggregate - Output: _hyper_1_2_chunk.int_value, PARTIAL sum(_hyper_1_2_chunk.segment_by_value) - Group Key: _hyper_1_2_chunk.int_value + -> Custom Scan (VectorAgg) + Output: _hyper_1_2_chunk.int_value, (PARTIAL sum(_hyper_1_2_chunk.segment_by_value)) + Grouping Policy: hashed with single 4-byte key -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_2_chunk Output: _hyper_1_2_chunk.int_value, _hyper_1_2_chunk.segment_by_value -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_12_chunk Output: compress_hyper_2_12_chunk._ts_meta_count, compress_hyper_2_12_chunk.segment_by_value, compress_hyper_2_12_chunk._ts_meta_min_1, compress_hyper_2_12_chunk._ts_meta_max_1, compress_hyper_2_12_chunk."time", compress_hyper_2_12_chunk.int_value, compress_hyper_2_12_chunk.float_value - -> Partial HashAggregate - Output: _hyper_1_3_chunk.int_value, PARTIAL sum(_hyper_1_3_chunk.segment_by_value) - Group Key: _hyper_1_3_chunk.int_value + -> Custom Scan (VectorAgg) + Output: _hyper_1_3_chunk.int_value, (PARTIAL sum(_hyper_1_3_chunk.segment_by_value)) + Grouping Policy: hashed with single 4-byte key -> Custom Scan (DecompressChunk) on _timescaledb_internal._hyper_1_3_chunk Output: _hyper_1_3_chunk.int_value, _hyper_1_3_chunk.segment_by_value -> Parallel Seq Scan on _timescaledb_internal.compress_hyper_2_13_chunk @@ -3519,3 +3519,11 @@ SELECT sum(float_value) FROM testtable2 GROUP BY tableoid ORDER BY 1 LIMIT 1; 82620 (1 row) +-- Postgres versions starting with 16 remove the grouping columns that are +-- equated to a constant. Check that our planning code handles this well. +SELECT sum(float_value), int_value FROM testtable2 WHERE int_value = 1 GROUP BY int_value; + sum | int_value +------+----------- + 3162 | 1 +(1 row) + diff --git a/tsl/test/sql/vector_agg_filter.sql b/tsl/test/sql/vector_agg_filter.sql index d3423d84eac..8a5aec27370 100644 --- a/tsl/test/sql/vector_agg_filter.sql +++ b/tsl/test/sql/vector_agg_filter.sql @@ -65,6 +65,8 @@ set timescaledb.debug_require_vector_agg = 'require'; ---- Uncomment to generate reference. --set timescaledb.enable_vectorized_aggregation to off; set timescaledb.debug_require_vector_agg = 'allow'; +set max_parallel_workers_per_gather = 0; + select format('%sselect %s%s(%s)%s from aggfilter%s%s%s;', explain, @@ -113,9 +115,19 @@ reset timescaledb.debug_require_vector_agg; -- FILTER that is not vectorizable set timescaledb.debug_require_vector_agg = 'forbid'; select count(*) filter (where cint2 === 0) from aggfilter; + -- FILTER with stable function set timescaledb.debug_require_vector_agg = 'require'; select count(*) filter (where cint2 = stable_abs(0)) from aggfilter; -reset timescaledb.debug_require_vector_agg; +-- With hash grouping +select + ss, + count(*) filter (where s != 5), + count(*) filter (where cint2 < 0) +from aggfilter +group by ss +order by 2, 3; +reset timescaledb.debug_require_vector_agg; +reset max_parallel_workers_per_gather; diff --git a/tsl/test/sql/vector_agg_functions.sql b/tsl/test/sql/vector_agg_functions.sql index 0e6a0d0860f..ef5d3c2b8dc 100644 --- a/tsl/test/sql/vector_agg_functions.sql +++ b/tsl/test/sql/vector_agg_functions.sql @@ -98,7 +98,9 @@ limit 1 set timescaledb.debug_require_vector_agg = :'guc_value'; ---- Uncomment to generate reference. Note that there are minor discrepancies ---- on float4 due to different numeric stability in our and PG implementations. --- set timescaledb.enable_vectorized_aggregation to off; set timescaledb.debug_require_vector_agg = 'allow'; +--set timescaledb.enable_vectorized_aggregation to off; set timescaledb.debug_require_vector_agg = 'forbid'; + +set max_parallel_workers_per_gather = 0; select format('%sselect %s%s(%s) from aggfns%s%s%s;', @@ -142,7 +144,8 @@ from 'cint2 is null']) with ordinality as condition(condition, n), unnest(array[ null, - 's']) with ordinality as grouping(grouping, n) + 's', + 'ss']) with ordinality as grouping(grouping, n) where true and (explain is null /* or condition is null and grouping = 's' */) @@ -156,6 +159,11 @@ order by explain, condition.n, variable, function, grouping.n \gexec +-- Test multiple aggregate functions as well. +select count(*), count(cint2), min(cfloat4), cint2 from aggfns group by cint2 +order by count(*) desc, cint2 limit 10 +; + -- Test edge cases for various batch sizes and the filter matching around batch -- end. select count(*) from edges; @@ -164,3 +172,9 @@ select s, count(*) from edges group by 1 order by 1; select s, count(*), min(f1) from edges where f1 = 63 group by 1 order by 1; select s, count(*), min(f1) from edges where f1 = 64 group by 1 order by 1; select s, count(*), min(f1) from edges where f1 = 65 group by 1 order by 1; + +select ss, count(*), min(f1) from edges where f1 = 63 group by 1 order by 1; +select ss, count(*), min(f1) from edges where f1 = 64 group by 1 order by 1; +select ss, count(*), min(f1) from edges where f1 = 65 group by 1 order by 1; + +reset max_parallel_workers_per_gather; diff --git a/tsl/test/sql/vectorized_aggregation.sql b/tsl/test/sql/vectorized_aggregation.sql index 324a96716f5..e3deb9bbb16 100644 --- a/tsl/test/sql/vectorized_aggregation.sql +++ b/tsl/test/sql/vectorized_aggregation.sql @@ -407,3 +407,7 @@ RESET max_parallel_workers_per_gather; -- Can't group by a system column SELECT sum(float_value) FROM testtable2 GROUP BY tableoid ORDER BY 1 LIMIT 1; + +-- Postgres versions starting with 16 remove the grouping columns that are +-- equated to a constant. Check that our planning code handles this well. +SELECT sum(float_value), int_value FROM testtable2 WHERE int_value = 1 GROUP BY int_value;