Azure Api call taking long time

I am currently working on a project in which i need to get the list of sql databases

I used this api call

https://docs.microsoft.com/en-us/rest/api/sql/databases/listbyserver

It takes three parameter namely subscription id,resource group and server-name

I used another api to call resource group

https://docs.microsoft.com/en-us/rest/api/resources/resourcegroups/list

And for server-name and subscription-id,I have created dictionary for manual insertion.

My code structure looks something like:

For loop:To loop through server name.

Calling resources group api

For loop:to loop through resources- group

Calling listbyserver api

For loop:getting the values from list by server api call

The problem i am facing here is ,it is taking almost an hour to get the result.

I have worked on another project with different api call (mentioned below) but its code structure and parameters are similar and call completes within 5 mintues.

Api call: https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/list

I want to understand the reason why it is taking so long in case of listofserver api call.

Is there any other way i can get the expected results.

Thanks in advance!!!