14 Mart 2023 Salı

Tablespaces

Giriş
Açıklaması şöyle
Besides the logical order, tablespaces define the physical location of the data. An actual tablespace is a filesystem directory. For example, you can locate the archive data on a slow HDD, but the hot data on a fast SDD.

The same tablespace may be used by a few databases at the same time. And a single database may store its data in a few tablespaces. It means that the logical and physical structures are independent.

Every database has its own default tablespace. It’s used for the creation of every object if the defaults are not changed. It also stores the system catalog objects.

On cluster initialization, two tablespaces are created:
  • pg_default — located in PGDATA/base and used as default tablespace for all databases;
  • pg_global — located in PGDATA/global and stores common objects for the whole cluster system catalog;
Açıklaması şöyle
On used tablespace creation, any filesystem catalog may be specified. PostgreSQL creates a symlink to the specified catalog in PGDATA/pg_tblspc. By the way, all the PostgreSQL paths are relative and are calculated from PGDATA. It allows you to move PGDATA wherever you want.
Örnek
Şöyle yaparız
CREATE TABLE IF NOT EXISTS public.factinternetsales_streaming
(
   ...
)
TABLESPACE pg_default;

Hiç yorum yok:

Yorum Gönder