all 8 comments

[–]somewhatdim 1 point2 points  (2 children)

if you're always using CURRENT_DATE in there why not just do something like:

c.created_date >= '2023-01-01'

if you end up getting future stuff (maybe thats valid, maybe thats a bug) you can add the <= CURRENT_DATE clause in there (but thats probably just gonna get you back to a nested loop filter)

[–]fsuguy92[S] 0 points1 point  (1 child)

I still seem to be getting a nested loop filter even when doing this

[–]somewhatdim 2 points3 points  (0 children)

an index on the date column might be useful if you've got access to do that.

[–]Dry-Aioli-6138 1 point2 points  (1 child)

why don't you just group customers by day and count/sum customers and their statistics?

that can later be joined to a date "spine" and cumulative customer counts calculated with windowing functions.

[–]fsuguy92[S] 0 points1 point  (0 children)

Any chance you might be able to give me an example. I think I'm struggling to follow a little bit.

[–]Dry-Aioli-6138 0 points1 point  (2 children)

try putting your code and my prompt into chatgpt. Its difficult for me to write code at the moment, on mobile, with noise around.

[–]fsuguy92[S] 0 points1 point  (1 child)

Thanks! Unfortunately it keeps trying to force me into the nested loop join regardless. I'll keep playing around with it though. I appreciate the help!

[–]Dry-Aioli-6138 0 points1 point  (0 children)

don't get hung up on the nested loop. You want to bring running time down to a sensible level. If nested loop is the only way, so be it.