Postgresql select from database where id = '{{$node["Gmail"].json["id"]}}';

Hi Guys,
I try to use n8n to connect to my Gmail. After I detect a new email I check with PostgreSQL if that email id was already processed or not

This is the selection I RUN:
SELECT id FROM n8n_logs WHERE gmail_id = '{{$node["Gmail"].json["id"]}}';

While this is working fine when I limit the number of selected emails to 1, when I try to put limit 2 or more I get an error

image

If however, I select just to get 1 email Postgres selection works just fine:

image

What am I doing wrong and how can I make sure it will work well even when i run this for 10 - 20 emails in the same time

As an update, if I add Execute Once, it will work

image

It seems like the Postgres-Node is one of the ones which has currently still some issues to execute multiple items. For that reason do you have to use the SplitInBatches-Node.

Here an example workflow:

{
  "nodes": [
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "=SELECT * FROM product WHERE id = {{$json[\"id\"]}}"
      },
      "name": "Postgres8",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        900,
        50
      ],
      "credentials": {
        "postgres": ""
      }
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "name": "SplitInBatches",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        700,
        50
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [
            {
              "value1": "={{$node[\"SplitInBatches\"].context[\"noItemsLeft\"]}}",
              "value2": true
            }
          ]
        }
      },
      "name": "IF1",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1100,
        150
      ]
    },
    {
      "parameters": {},
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1300,
        100
      ]
    },
    {
      "parameters": {
        "functionCode": "return [\n  {\n    json: {\n      id: 400\n    }\n  },\n  {\n    json: {\n      id: 401\n    }\n  }\n]"
      },
      "name": "Mock-Data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        500,
        50
      ]
    }
  ],
  "connections": {
    "Postgres8": {
      "main": [
        [
          {
            "node": "IF1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SplitInBatches": {
      "main": [
        [
          {
            "node": "Postgres8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF1": {
      "main": [
        [
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mock-Data": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}