I really wish a function existed in PG that took some order by clause and gave a value with comparator functions... I'll hopefully write a blog post about this in the next few days. Or I'll get sidetracked writing bg info on btrees and why offset is bad and never finish
-
Show this thread
-
Writing a where clause that is "rows that appear after the row with a given id" for an arbitrary order by clause in generic code is possible, but obnoxiously hard. Especially once you start assuming all columns can contain null and handling nulls first/last
1 reply 0 retweets 0 likesShow this thread -
I can't be the first person to want to do this. And this feels like the sort of thing that PG has hidden gems to help with, but I can't seem to find them.
2 replies 0 retweets 1 likeShow this thread -
-
Replying to @redtwitdown
I'm not sure I follow. Can you give me more context on what you mean?
1 reply 0 retweets 0 likes -
Replying to @sgrif
sorry, haven't worked through the details, but.. order by / where apply to original rows, group by / having apply to an aggregate function over that result. So presumably you can have a bistable function that is true once your condition is seen..
1 reply 0 retweets 0 likes -
Replying to @redtwitdown
That's not really helpful here, this is for seeking in a pagination context. E.g. turning `ORDER BY ... LIMIT X OFFSET Y` into a where clause only for records appearing after OFFSET Y
1 reply 0 retweets 0 likes -
Replying to @sgrif
oh.. something with cursors, probably where your function returns the cursor?
2 replies 0 retweets 0 likes -
Replying to @redtwitdown
Yeah cursor based pagination is one term folks use to describe this. Using actual sql cursors for this uses more resources than the problem it's solving though
1 reply 0 retweets 0 likes -
Replying to @sgrif
which brings you back to a client-side filter iterator, yup
2 replies 0 retweets 0 likes
Yeah, that's just reinventing offset :)
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.