Frappe report show largest than data

I couldn’t get more than 5000 records when making a script report, it always shows ‘Request Time Out’, Because when I tried < 5000 records it ran smoothly but more than that it didn’t work. But when I use a simple query such as

select * from ‘tabSales Invoice’

it’d show more than 5000 records (11.000 records more precisely). Does anyone know how to fix this?