There is no pagination, but since this is a maintenance script this problem isn't an issue. 

The query looks to be ok.