Postgresql SELECT queries problems

Hi!
Faced with a confusing situation after upgrading to the latest version.

There are two tables:
In the first two records, in the second one.
I do SELECT * FROM ferst_table; The result is two records.
Then I do SELECT * FROM next_table; The result is two records.

Why does the second one return two records instead of one?

P.S. I saw that in version 117 added the ability to select the transaction, I do not know whether it could have some effect.

That is explain in the breaking changes for the latest version.

I understand it should be in Default mode (Multiple queries).
In Independently (Execute each query independently) should it work like this?

Ahh not sure to be honest as I did not do the change. Can you share the workflow you are using and explain a bit where is not working exactly.

Sorry for the long response.
Workflow and database schema below.

I expect that on each query, I get the data that is in the database, but it is not…

SQL Shema
CREATE TABLE IF NOT EXISTS first_table(
    name VARCHAR
);

INSERT INTO first_table (name) VALUES ('first'), ('second');

CREATE TABLE IF NOT EXISTS next_table(
    name VARCHAR
);

INSERT INTO next_table (name) VALUES ('first');
Workflow
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT * FROM first_table;",
        "additionalFields": {
          "mode": "independently"
        }
      },
      "name": "Postgres",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        450,
        300
      ],
      "credentials": {
        "postgres": "PG_mr_braun"
      }
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT * FROM next_table;",
        "additionalFields": {
          "mode": "independently"
        }
      },
      "name": "Postgres1",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        650,
        300
      ],
      "credentials": {
        "postgres": "PG_mr_braun"
      }
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres": {
      "main": [
        [
          {
            "node": "Postgres1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Hey @a1ekseev!

Since your previous node returns 2 items, the next node gets executed twice. If the first node returns 10 items, the next node will be executed 10 times. Since you are not using the information coming from the previous node and you want to execute your query only once, you can set the Execute Once option to true. You can find that option in the node’s setting tab. Below is a screenshot

Hope this solves your issue :slight_smile:

2 Likes

Yes, it works now thank you.
It used to work without it:)