I’m using the postgres node to run a simple SELECT query, and the performance of the node is atrocious. It takes 70 seconds to query 1,000 records with only two columns. I ran the same query from another docker container on the same machine hosting my n8n docker container, and it completed in 3 seconds.
What is n8n doing that’s causing it to take so much more time to run the query? Is there something I can do to speed it up?
Hey @carlin-q-scott, are you by any chance sending multiple items to your Postgres node that are slowing down thing for you here?
E.g. a workflow like the one below passing on 3 items would result in 3 queries sent to PostgreSQL:
Resulting PostgreSQL queries:
2022-02-23 09:14:57.629 UTC  LOG: statement: SELECT * FROM names WHERE name = 'foo';SELECT * FROM names WHERE name = 'bar';SELECT * FROM names WHERE name = 'baz'
Depending on your requirements you could ensure to only pass on a single item to the Postgres node or configure it to only execute once like so:
No, it’s triggered by a Start node.
Hm, I wouldn’t have any great clue then unfortunately.
My next step in investigating would be to enable query logging on your PostgreSQL instance and compare the query sent by n8n with the query you were executing manually. Are there any noticeable differences?
The performance issue seems to have cleared up on its own. I didn’t update or change the query. I just ran it again after several weeks.
I had to specify the query using raw sql because a SELECT query isn’t supported by the configuration UI for the postgres node. But just to be sure, I checked the db server anyways, and the query matches what I specified perfectly.
The performance issue seems to have cleared up on its own.
I haven’t seen this behaviour before tbh. Maybe it was just a coincidence (slow networking, high db load etc). Anyway, I am glad to hear this is working again, many thanks for confirming!