SQL Database Connector queries too slow

Hello everyone !

I’m running a query using SQL Database Connector and it’s taking 5 seconds to execute. When I run the query on Azure Data Studio, it takes 0,02 sec.

Why is there a degradation on Bubble’s side ? Is there a way to optimize time response, or is there things that I may have missed while creating the query and is causing this ?

My goal is to drop the response time to 2 or 3 secs at least. I know there’ll always be a delay because running a query while being directly connected to the Database is faster than connecting through Bubble.

Here’s more information :

Query :
The query itself contains two subqueries : each subquery will sum the values of 2 different columns and while having constraints on 8 other columns. The value output of each subquery will then be added. The 8 constraints are taken from bubble as parameters (they are the user’s input).

Database :
I built the database on Microsoft Azure. The database isn’t really large for now, it’s about 2000 rows x 20 columns. When the query is executed, the sum is made on one column while having constraints on 8 other columns.

Did someone encounter this previously and found a solution ? Or can someone with experience and knowledge help me on this matter ? I searched the forum but couldn’t find tangible solutions for this matter.

I’m currently on Starter’s Plan if that matters.

I’m pretty sure the reason for the slowness is because the query is running in an AWS lambda function (not 100% but I believe this is the case). If so the start-up requires a moment and then the query usually runs quickly after that. In our experience, once the function is warmed up further executions typically run quickly (based on our experiences).

Our SQL plugin has timing built in so you can see the exact timing of the queries.

@ben13 Thanks for you reply and thanks for mentioning your pluging, I’ll check it out !

I searched for solutions based on what you told me the problem might be, and Zapier offers connection between AWS lambda and Bubble.

Are you aware of Zapier ? Could this be a potential solution ?

@ghadi_hanna1 no problem. Yes I am familiar with Zapier and no I don’t think it is a solution to this specific problem (although it is a good solution for many problems).

A potential solution is to expose your Azure database/queries as an API. This has been noted before on the forum somewhere (or you can just google for exposing Azure database as API). Then you would use Bubble’s Api Connector rather then the SQL plugin.

@ben13 I understand thank you ! I will do some testing and will update this topic once it’s done