CSV File Size Discrepancy - n8n/pgAdmin

Hello everyone,

I’m experiencing an issue with the CSV file size generated by an n8n workflow compared to the same query executed directly in pgAdmin.

Scenario:

I have a workflow in n8n that runs a SQL query and saves the result to a CSV file.
When I execute the query in pgAdmin and download the CSV file, the final file size is approximately 1.8 MB.
However, when the same query is run through my n8n workflow, the resulting CSV file is around 8 MB.
Both files contain the same data—just over 10,000 rows. I’m curious as to why there’s such a significant difference in file size between the two methods.

Questions:

  • Why is the CSV file generated by n8n so much larger than the one downloaded from pgAdmin?

  • Is there a way to reduce the size of the CSV file generated by n8n?

Any insights or tips would be greatly appreciated!

Thanks in advance!

n8n version: 1.50.1
running via npm
operating system: linux

Hey @thidp,

It could be encoding, Are you able to share both files so we can take a look? Maybe go for a smaller one with 5 rows to make it easier to check.

Hello, @Jon,

When I try to upload the files, I receive the message: “Sorry, the file you are trying to upload is not authorized.”

However, the encoding of the file generated by the n8n workflow is UTF-8 BOM, while the other file is UTF-8.

I noticed that the date fields in the n8n file are in a complete timestamp format, whereas the other file uses a standard date format.

Examples:

  • n8n: Sun Jan 21 2024 00:00:00 GMT+0000 (Coordinated Universal Time)
  • pgAdmin: 2024-01-21

The data type in my database is “date”. I could adjust my query and convert the date fields to char, but is there a way to fix this directly in the n8n workflow?

Hey @thidp,

The BOM should be ok but the different date formats would soon add up. We tend to format the date field which looks like the problem, the best I can think of would be to use a Set node to format the date field to yyyy-MM-dd after the merge and that should take care of it.