The statistics collector then passes the information to backends using temporary files, location of the temporary files are defined by stats_temp_directory variable in postgresql.conf, by defaults it points to $PGDATA/pg_stat_tmp. In the instruction below we will make Postgres use another destination: $PGDATA/pgsql_stats_tmp. This will be a RAM disk. As Postgres is running, there are continuous I/O in stats_temp_directory, the disk I/O may affect database performance. Postgres recommends to point stats_temp_directory to RAM-based file system, decreasing physical I/O, thus increasing database performance.
We can use either ramfs or tmpfs. For more information about the differences between these, see overview-of-ramfs-and-tmpfs-on-linux.
In the example below, tempfs has been used as the stats_temp_directory: