Despite the fact that PostgreSQL is quite a powerful database, it lacks full support for storing tables in memory.Here I will explain how to get PostgreSQL to store the selected tables in memory for fast operations with them.Everything will happen in Debian.Let’s create an empty folder to mountmkdir / mnt / ramfsAnd smonriruem ramfs theremount -t ramfs none / mnt / ramfsCreate a folder for PostgreSQL and assign it to the right.mkdir / mnt / ramfs / pgdatachown postgres: postgres / mnt / ramfs / pgdatachmod 600 / mnt / ramfs / pgdataLet’s go further superuser database PostgreSQL – postgressu postgrespsqlAnd create a new TABLESPACE, we determine placement in a folder mounted ramfspostgres = # CREATE TABLESPACE ram LOCATION ‘/ mnt / ramfs / pgdata’;Will issue the right to work with this TABLESPACE our users (for example, myuser)postgres = # GRANT CREATE ON TABLESPACE ram TO myuser;Now we just need to create a new table and point at its creation TABLESPACE ram.For example:CREATE TABLE mytesttable (begin_ip ip4 NOT NULL, end_ip ip4 NOT NULL, begin_num BIGINT NOT NULL, end_num BIGINT NOT NULL, country_code CHARACTER (2) NOT NULL, country_name CHARACTER VARYING (255) NOT NULL, ip_range ip4r)TABLESPACE ram;Now PostgreSQL will work with this table as the other without even knowing that it “lies” in RAM.