Deferred Join
Hi - I'm experimenting with adding deferred join capability (as described here: (https://planetscale.com/learn/courses/mysql-for-developers/examples/deferred-joins) to a limit/offset query.
The premise is to apply the
order by
, limit
and offset
values to the inner join query but I'm having trouble finding a way syntactically to apply this to the inner join. Do I need to use the sql
escape hatch? If so, I'm also struggling with where I'd apply that too!
Any pointers appreciated as always, thanksDeferred joins
Optimize your pagination strategy with deferred joins! This video shows you how to modify the offset/limit style to keep it performant as you reach deeper pages. Improve your MySQL skills today.
4 Replies
Something like this?
https://kyse.link/?p=s&i=wFay4V59GwY9i0hrlQEA
using id
is the same as saying person.id = person2.id
Thank you - I'd just managed to come to a similar point but what I'm struggling with now is generating the order by part dynamically, and then applying that. I'm just putting together a playground to illustrate
Here it is - https://kyse.link/?p=s&i=QnDGj00PaNmXsVjRUfDv
The type changes when you call
as
. You can't assign it to the same variable
https://kyse.link/?p=s&i=Jod1DIR88Jmr9SNbIe7R
But this won't work
you're comparing a column to itself. You need to specify the tables.
Your example can actually be simplified to this
https://kyse.link/?p=s&i=gYmIsmgyajbPEGjrR1DMFantastic, thank you so much
Worked a treat and sped up my two queries as hoped. Thanks again.