Making STATS_AGG return NULL if no values present?
#874
jdmwood
started this conversation in
Bugs / Internal Improvements
Replies: 1 comment
-
|
I'm pretty sure this is at least safe to do. To show some workings: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
So let's say I'm doing something like:
One minor annoyance with
STATS_AGGis that it returns a non null, but emptyStatsSummary1Dlike(version:1,n:0,sx:0,sx2:0,sx3:0,sx4:0)even if all results for that column are null.If you have a query with a large number of columns which are often sparse (i.e. NULL), then this is a large amount of wasted storage (for things like Timescale continuous aggregates).
I can work around it like this:
but
a) I'm not totally sure this is mathematically correct. Is
STATS_AGGwith no matched rows =STATS_AGGwith many values which are NULL? I do know that, for example,AVERAGE('(version:1,n:0,sx:0,sx2:0,sx3:0,sx4:0)'::StatsSummary1D)is NULL and so isAVERAGE(NULL::StatsSummary1D).b) If it is OK, is there any reason to not have
STATS_AGGstore NULL in this case too?c) If it's not desirable to change
STATS_AGGis there any problem with theFILTER WHEREapproach above?Beta Was this translation helpful? Give feedback.
All reactions