PostgreSQL Foreign Table Parsing Frequency with file_fdw

csvpostgresqlpostgresql-fdw

I have a foreign table defined with file_fdw, which reads the data from a CSV file. Postgresql parses the CSV file and converts the date for example from YYYYMMDD to YYYY-MM-DD. This works fine.

My question is how often gets the CSV file parsed? Does it get parsed on every select? Or does it get cached? And if so how long does it get cached?

Best Answer

The file is read whenever the foreign table is scanned, which can happen several times during processing of a query.

There is no caching except the file system cache of the operating system.