It sounds that it might be solvable with another loop which sliced your input-table. There you could add a counter maybe with something like:
ceil(rowno() / 5000) as LoopCounter
and then you could loop through this field like:
for i = 1 to fieldvaluecount(LoopCounter)
load * from Table where LoopCounter = $(i);
... your other stuff ...
Sounds like you need to look at pagination - here is the url of to the loading paged data manual section
The actual details of what you precisely need to do will depend on the details of your data source.