Hi there,
I have the following workflow:
I simply execute a SQL statement that returns some data which I need to evaluate before I send it to the AI to work with.
Now this is fine and works, as I can tell the AI to use the JSON from $(‘Microsoft SQL1’).all() etc…however when you do this, it is extremely slow (I’m using Gemini, but that should be a moot point).
To give you an idea, it takes around 40 seconds as the AI attempts to read/parse the JSON data and provide the answer which leads to a horrible end user experience. Now, when I do this:
and I give the AI agent the SQL tool to re-execute the exact same query it just ran, it is way faster. I’m talking 40 seconds → 10 seconds because it’s not having to parse the lengthy JSON and build a nice response.
I have tried everything I can think of to get the first SQL node to spit out something fast like a CSV string for the AI to use and format but I just can’t get it working. I don’t really want to have to leave it in this state of having to re-execute the same SQL I just executed in order to get sensible performance.
Does anyone know of a way I can get the AI to use the returned data quick, much like the Microsoft SQL “tool” does, rather than the “node”?
Any help would be appreciated on this. It’s almost like I need the “Convert to CSV” node to have an option that states “output as string” or something instead so that I can pass that to the AI.
Using n8n version 1.85.4