Gateway timeout when fetching records from MySQL database

Hi,
I’ve created a service for a mysql database which is in AWS RDS. In the service configuration i saw a field “schema”, if i give it as “default” that service will work only with that particular DB’s schemas and tables. I’ve done the configuration. if i call the “domain name”+api/v2/servicename/_table/ endpoint i’m getting the response with the list of table available in that database.
But when i try to retrieve records from a particular table by using the “domain name”+api/v2/servicename/_table/tablename endpoint, I’m getting “Gateway timeout” error

504 Gateway Timeout

Gateway Timeout

The gateway did not receive a timely response from the upstream server or application.

Sometimes I’m getting the same error for both endpoints.
Can anyone please guide me on this. Thank you.