bug #4582 Debug SQL works only for the first page

Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>