{"id":352795,"date":"2024-05-20T22:15:27","date_gmt":"2024-05-20T22:15:27","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=352795"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-20T22:15:27","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=352795","title":{"rendered":"<span>\u041d\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u043e \u043a\u0440\u0430\u0435\u0432: \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 PostgresQL<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>8 + 2 = 16 \u0438\u043b\u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u043b\u0438\u0448\u043d\u0438\u0435 \u0431\u0430\u0439\u0442\u044b<\/h3>\n<p>\u0412\u00a0\u044f\u0437\u044b\u043a\u0430\u0445 \u043d\u0438\u0437\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a\u00a0C, \u043d\u0430\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d Postgres, \u0434\u043b\u044f\u00a0\u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a\u00a0\u0434\u0430\u043d\u043d\u044b\u043c \u0432\u00a0\u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u044b, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442\u00a0\u0442\u043e\u0433\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u0442\u0430 \u043d\u0430\u00a0\u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 32-\u0431\u0438\u0442\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u043e\u0432, \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u00a0\u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430. \u0422\u043e \u0435\u0441\u0442\u044c, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u043b\u044e, \u043f\u043e\u0434\u00a0\u043d\u0435\u0433\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430 \u043f\u0430\u043c\u044f\u0442\u0438. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 (alignment).<\/p>\n<p>Postgres \u0442\u043e\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u00a0\u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442\u043e\u0432. \u041a\u0430\u043a\u00a0\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0432\u00a0\u0440\u044f\u0434\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u00a0\u0438\u0434\u0443\u0449\u0438\u0445 \u043f\u043e\u0434\u0440\u044f\u0434 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u0445 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0431\u0430\u0439\u0442\u0430\u043c\u0438 \u0434\u043b\u044f\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>SELECT    pg_column_size(row()) AS empty,    pg_column_size(row(0::SMALLINT)) AS byte2,    pg_column_size(row(0::BIGINT)) AS byte8,    pg_column_size(row(0::SMALLINT, 0::BIGINT)) AS byte16 ; --------------------------------  empty | byte2 | byte8 | byte16  -------+-------+-------+--------     24 |    26 |    32 |     40<\/code><\/pre>\n<p>\u041f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 24\u00a0\u0431\u0430\u0439\u0442\u0430 (\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0437\u0430\u043f\u0438\u0441\u0438), SMALLINT \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0431\u0430\u0439\u0442\u0430, BIGINT\u00a0\u2014 \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442\u043e\u0432, \u0430\u00a0\u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u043d\u0438 \u0434\u0430\u044e\u0442\u2026 16\u00a0\u0431\u0430\u0439\u0442\u043e\u0432? \u042d\u0442\u043e \u043d\u0435\u00a0\u043e\u0448\u0438\u0431\u043a\u0430: \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u043f\u043e\u00a0\u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0431\u0430\u0439\u0442\u0430\u043c\u0438 \u0434\u043b\u044f\u00a0\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0432\u00a0\u0446\u0435\u043b\u044f\u0445 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u043c\u0435\u0441\u0442\u043e 2\u00a0+ 8\u00a0= 10\u00a0\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 8\u00a0+ 8\u00a0= 16. <\/p>\n<p>\u041f\u043e\u043a\u0430 \u0447\u0442\u043e\u00a0\u044d\u0442\u043e \u043d\u0435\u00a0\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u043d\u043e\u00a0\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0435\u0431\u0435 \u043d\u0435\u043a\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u00a0\u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430:<\/p>\n<pre><code>CREATE TABLE user_order (   is_shipped    BOOLEAN NOT NULL DEFAULT false,   user_id       BIGINT NOT NULL,   order_total   NUMERIC NOT NULL,   order_dt      TIMESTAMPTZ NOT NULL,   order_type    SMALLINT NOT NULL,   ship_dt       TIMESTAMPTZ,   item_ct       INT NOT NULL,   ship_cost     NUMERIC,   receive_dt    TIMESTAMPTZ,   tracking_cd   TEXT,   id            BIGSERIAL PRIMARY KEY NOT NULL );<\/code><\/pre>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u043d\u043e\u00a0\u0442\u0430\u043a \u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043e. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u00a0\u0431\u044b\u043b\u0430 \u043d\u0430\u0431\u0440\u043e\u0441\u0430\u043d\u0430 \u0432\u00a0\u0441\u043f\u0435\u0448\u043a\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c, \u0430\u00a0\u043c\u043e\u0436\u0435\u0442\u00a0\u0431\u044b\u0442\u044c \u0435\u043c\u0443 \u043f\u043e\u043c\u043e\u0433\u043b\u0430 ORM. \u041d\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f\u00a0\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u0412\u043e\u0442 \u043a\u0430\u043a\u00a0\u0432\u0438\u0434\u0438\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 Postgres:<\/p>\n<pre><code>SELECT a.attname, t.typname, t.typalign, t.typlen   FROM pg_class c   JOIN pg_attribute a ON (a.attrelid = c.oid)   JOIN pg_type t ON (t.oid = a.atttypid) WHERE c.relname = 'user_order'    AND a.attnum >= 0  ORDER BY a.attnum;  -----------------------------------------------    attname   |   typname   | typalign | typlen  -------------+-------------+----------+--------  is_shipped  | bool        | c        |      1  user_id     | int8        | d        |      8  order_total | numeric     | i        |     -1  order_dt    | timestamptz | d        |      8  order_type  | int2        | s        |      2  ship_dt     | timestamptz | d        |      8  item_ct     | int4        | i        |      4  ship_cost   | numeric     | i        |     -1  receive_dt  | timestamptz | d        |      8  tracking_cd | text        | i        |     -1  id          | int8        | d        |      8 <\/code><\/pre>\n<p>\u0412\u00a0\u0441\u0442\u043e\u043b\u0431\u0446\u0435 typalign \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0442\u0438\u043f \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <a href=\"https:\/\/www.postgresql.org\/docs\/current\/catalog-pg-type.html\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0432\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <\/a> \u0434\u043b\u044f\u00a0pg_type). \u0414\u043b\u044f\u00a0\u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0441\u00a0\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u00a0\u0431\u0430\u0439\u0442\u0430\u0445. \u0414\u043b\u044f\u00a0NUMERIC \u0438 TEXT \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435; \u043a\u00a0\u043d\u0438\u043c \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043f\u043e\u043f\u043e\u0437\u0436\u0435. \u0410\u00a0\u043f\u043e\u043a\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u00a0\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u043b\u0435\u0439 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0435. <\/p>\n<h3>\u0420\u043e\u0432\u043d\u044f\u0435\u043c \u043f\u043e\u0434 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442<\/h3>\n<p>\u0414\u043b\u044f\u00a0\u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438, Postgres \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446, \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0447\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f (8\u00a0\u0431\u0430\u0439\u0442\u043e\u0432) \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u00a0\u043d\u0438\u043c. \u0412\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u00a0\u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u043e\u0439 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u0435 \u0431\u0430\u0439\u0442\u044b \u0432\u00a0\u0440\u043e\u043b\u0438 \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f.<\/p>\n<p>\u0417\u0430\u043b\u044c\u0451\u043c \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code>INSERT INTO user_order (     is_shipped, user_id, order_total, order_dt, order_type,     ship_dt, item_ct, ship_cost, receive_dt, tracking_cd ) SELECT true, 1000, 500.00, now() - INTERVAL '7 days',        3, now() - INTERVAL '5 days', 10, 4.99,        now() - INTERVAL '3 days', 'X5901324123479RROIENSTBKCV4' FROM generate_series(1, 1000000);  SELECT pg_relation_size('user_order') AS size_bytes,        pg_size_pretty(pg_relation_size('user_order')) AS size_pretty;  --------------------------  size_bytes | size_pretty  ------------+-------------   141246464 | 135 MB <\/code><\/pre>\n<p>\u0411\u0435\u0440\u0451\u043c \u044d\u0442\u0438 \u0446\u0438\u0444\u0440\u044b \u0437\u0430\u00a0\u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. \u0412\u043e\u043f\u0440\u043e\u0441: \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b? \u0412\u043e\u0442 \u043e\u0446\u0435\u043d\u043a\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0443\u0441\u0442\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432 \u043f\u043e\u00a0\u0434\u0430\u043d\u043d\u044b\u043c \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p> 7 \u0431\u0430\u0439\u0442 \u043c\u0435\u0436\u0434\u0443 is_shipped \u0438 user_id<\/p>\n<\/li>\n<li>\n<p> 4 \u0431\u0430\u0439\u0442\u0430 \u043c\u0435\u0436\u0434\u0443 order_total \u0438 order_dt<\/p>\n<\/li>\n<li>\n<p> 6 \u0431\u0430\u0439\u0442 \u043c\u0435\u0436\u0434\u0443 order_type \u0438 ship_dt<\/p>\n<\/li>\n<li>\n<p> 4 \u0431\u0430\u0439\u0442\u0430 \u043c\u0435\u0436\u0434\u0443 receive_dt \u0438 id<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f 21\u00a0\u043f\u0443\u0441\u0442\u043e\u0439 \u0431\u0430\u0439\u0442 \u0432\u00a0\u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438; \u043f\u0440\u0438\u00a0\u044d\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 59\u00a0\u0431\u0430\u0439\u0442\u043e\u0432, \u0430\u00a0\u043e\u0431\u0449\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 80\u00a0\u0431\u0430\u0439\u0442\u043e\u0432 \u0431\u0435\u0437\u00a0\u0443\u0447\u0435\u0442\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430. \u041f\u043e\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f\u00a0\u0442\u0438\u043f\u043e\u0432 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430. \u0414\u0430\u043d\u043d\u044b\u0435 \u0441\u00a0\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c: NUMERIC \u0438 TEXT \u043c\u0435\u043d\u044f\u044e\u0442 \u044d\u0442\u0443 \u043e\u0446\u0435\u043d\u043a\u0443, \u043d\u043e\u00a0\u0434\u043b\u044f\u00a0\u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u044f \u043e\u043d\u0430 \u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u044d\u0442\u0430 \u043e\u0446\u0435\u043d\u043a\u0430 \u0434\u0430\u0436\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0440\u043d\u0430, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0430 (21\/80\u00a0=) 26% \u0438\u043b\u0438\u00a0\u043d\u0430 37\u00a0\u041c\u0431. \u0421\u0442\u043e\u0438\u0442 \u043a\u043e\u043f\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h3>\u0414\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u00a0\u0442\u0438\u043f\u044b NUMERIC \u0438 TEXT. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u0442\u0438\u043f\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u043e\u043d\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u2011\u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u0412\u043e\u0437\u044c\u043c\u0435\u043c NUMERIC: <\/p>\n<pre><code>SELECT pg_column_size(row()) AS empty_row,        pg_column_size(row(0::NUMERIC)) AS zero_val,        pg_column_size(row(1::NUMERIC)) AS no_dec,        pg_column_size(row(1.1::NUMERIC)) AS with_dec,        pg_column_size(row(1::INT4)) AS int4,        pg_column_size(row(1::NUMERIC, 1::INT4)) AS num_int4,        pg_column_size(row(1::INT4, 1::NUMERIC)) AS int4_num,        pg_column_size(row(1.1::NUMERIC, 1::INT4)) AS num_dec_int4,        pg_column_size(row(1::INT4, 1.1::NUMERIC)) AS int4_num_dec ;  ------------------------------------------------------------------------------------------------------  empty_row | zero_val | no_dec | with_dec | int4 | num_int4 | int4_num | num_dec_int4 | int4_num_dec |  ------------------------------------------------------------------------------------------------------         24 |       27 |     29 |       31 |   28 |       36 |       33 |           36 |           35 | <\/code><\/pre>\n<p>\u041f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e\u00a0\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u00a0\u0441\u0442\u043e\u043b\u0431\u0446\u0435 NUMERIC \u043d\u0435\u00a0\u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u043d\u043e\u00a0\u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u00a0NUMERIC. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c TEXT:<\/p>\n<pre><code>SELECT pg_column_size(row()) AS empty_row,        pg_column_size(row(''::TEXT)) AS no_text,        pg_column_size(row('a'::TEXT)) AS min_text,        pg_column_size(row('a'::TEXT, 1::INT4)) AS txt_smint,        pg_column_size(row('ab'::TEXT, 1::INT4)) AS txt2_smint,        pg_column_size(row('abc'::TEXT, 1::INT4)) AS txt3_smint,        pg_column_size(row('abcd'::TEXT, 1::INT4)) AS txt4_smint,        pg_column_size(row('abcde'::TEXT, 1::INT4)) AS txt5_smint,        pg_column_size(row(1::INT4, 'a'::TEXT)) AS smint_txt,        pg_column_size(row(1::INT4, 'ab'::TEXT)) AS smint_txt2,        pg_column_size(row(1::INT4, 'abc'::TEXT)) AS smint_txt3,        pg_column_size(row(1::INT4, 'abcd'::TEXT)) AS smint_txt4,        pg_column_size(row(1::INT4, 'abcde'::TEXT)) AS smint_txt5 ;  -----------------------------------------------------------------------------------------------------------------------------------------------------------------  empty_row | no_text | min_text | txt_smint | txt2_smint | txt3_smint | txt4_smint | txt5_smint | smint_txt | smint_txt2 | smint_txt3 | smint_txt4 | smint_txt5 |  -----------------------------------------------------------------------------------------------------------------------------------------------------------------         24 |      25 |       26 |        32 |         32 |         32 |         36 |         36 |        30 |         31 |         32 |         33 |         34 |  <\/code><\/pre>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e\u00a0\u0441\u0442\u043e\u043b\u0431\u0435\u0446 TEXT \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0434\u043e\u00a0\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u00a0\u043d\u0438\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 (\u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430 \u0434\u043b\u044f\u00a0INT4, \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442\u043e\u0432 \u0434\u043b\u044f\u00a0INT8). \u0410\u00a0\u0432\u043e\u0442 \u0435\u0441\u043b\u0438 TEXT \u0438\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0441\u00a0\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c, \u0442\u043e \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0435\u00a0\u043e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u0442\u0441\u044f. <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043d\u0435\u00a0\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u00a0\u043a\u043e\u043d\u0446\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<h3>\u0414\u0430\u043d\u043d\u044b\u0435 \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u043a\u00a0\u0441\u0442\u043e\u043b\u0431\u0446\u0443 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u0435 \u0431\u0430\u0439\u0442\u044b \u0434\u043b\u044f\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u00a0\u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e\u00a0\u0441\u0430\u043c\u044b\u0435 \u00ab\u0448\u0438\u0440\u043e\u043a\u0438\u0435\u00bb \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0434\u0442\u0438 \u043f\u0435\u0440\u0432\u044b\u043c\u0438. \u041d\u043e, \u043c\u043e\u0436\u043d\u043e \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0430\u044f \u0448\u0438\u0440\u0438\u043d\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0430 \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442\u043e\u0432.<\/p>\n<pre><code>SELECT pg_column_size(row()) AS empty_row,        pg_column_size(row(1::SMALLINT)) AS int2,        pg_column_size(row(1::INT)) AS int4,        pg_column_size(row(1::BIGINT)) AS int8,        pg_column_size(row(1::SMALLINT, 1::BIGINT)) AS padded,        pg_column_size(row(1::INT, 1::INT, 1::BIGINT)) AS not_padded ;  ------------------------------------------------------  empty_row | int2 | int4 | int8 | padded | not_padded  -----------+------+------+------+--------+------------         24 |   26 |   28 |   32 |     40 |         40 <\/code><\/pre>\n<p> \u041a\u0430\u043a\u00a0\u0432\u0430\u043c?<\/p>\n<h3>\u0422\u0435\u0442\u0440\u0438\u0441 \u0441\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438<\/h3>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432\u00a0\u043f\u043e\u0434\u0431\u043e\u0440\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0443\u0441\u0442\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432. \u0418 \u0438\u0437\u00a0\u0432\u0441\u0435\u0433\u043e \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f: \u00ab\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u043f\u043e\u00a0\u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u0448\u0438\u0440\u0438\u043d\u044b \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u0432\u00a0\u043d\u0438\u0445 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u00a0pg_type\u00bb. \u042d\u0442\u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c, \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0432\u00a0\u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0434\u043b\u044f\u00a0\u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438 \u0438\u0445 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<pre><code>SELECT a.attname, t.typname, t.typalign, t.typlen   FROM pg_class c   JOIN pg_attribute a ON (a.attrelid = c.oid)   JOIN pg_type t ON (t.oid = a.atttypid)  WHERE c.relname = 'user_order'    AND a.attnum >= 0  ORDER BY t.typlen DESC ;  -----------------------------------------------    attname   |   typname   | typalign | typlen  -------------+-------------+----------+--------  id          | int8        | d        |      8  user_id     | int8        | d        |      8  order_dt    | timestamptz | d        |      8  ship_dt     | timestamptz | d        |      8  receive_dt  | timestamptz | d        |      8  item_ct     | int4        | i        |      4  order_type  | int2        | s        |      2  is_shipped  | bool        | c        |      1  tracking_cd | text        | i        |     -1  ship_cost   | numeric     | i        |     -1  order_total | numeric     | i        |     -1 <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u044d\u0442\u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043a\u00a0\u043d\u0430\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435:<\/p>\n<pre><code>DROP TABLE user_order;  CREATE TABLE user_order (   id            BIGSERIAL PRIMARY KEY NOT NULL,   user_id       BIGINT NOT NULL,   order_dt      TIMESTAMPTZ NOT NULL,   ship_dt       TIMESTAMPTZ,   receive_dt    TIMESTAMPTZ,   item_ct       INT NOT NULL,   order_type    SMALLINT NOT NULL,   is_shipped    BOOLEAN NOT NULL DEFAULT false,   order_total   NUMERIC NOT NULL,   ship_cost     NUMERIC,   tracking_cd   TEXT ); <\/code><\/pre>\n<p>\u0418 \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u0437\u0430\u043b\u0438\u0432\u043a\u0443 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u0435\u0439<\/p>\n<pre><code>INSERT INTO user_order (     is_shipped, user_id, order_total, order_dt, order_type,     ship_dt, item_ct, ship_cost, receive_dt, tracking_cd ) SELECT true, 1000, 500.00, now() - INTERVAL '7 days',        3, now() - INTERVAL '5 days', 10, 4.99,        now() - INTERVAL '3 days', 'X5901324123479RROIENSTBKCV4' FROM generate_series(1, 1000000);  SELECT pg_relation_size('user_order') AS size_bytes,        pg_size_pretty(pg_relation_size('user_order')) AS size_pretty;  --------------------------  size_bytes | size_pretty  ------------+-------------   117030912 | 112 MB<\/code><\/pre>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0432 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043c\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043b\u0438 21% \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430. <em>\u041e\u0442\u00a0\u0441\u0435\u0431\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044e, \u0447\u0442\u043e\u00a0\u0432\u0441\u0442\u0430\u0432\u043a\u0430 \u043f\u0440\u043e\u0448\u043b\u0430 \u043f\u043e\u0447\u0442\u0438 \u0432\u00a0\u0434\u0432\u0430 \u0440\u0430\u0437\u0430\u00a0\u0431\u044b\u0441\u0442\u0440\u0435\u0435: 5,2\u00a0\u0441\u00a0\u043f\u0440\u043e\u0442\u0438\u0432 8,7\u00a0\u0441\u00a0\u0432 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435.<\/em><\/p>\n<p>\u0414\u043b\u044f\u00a0\u043e\u0434\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442\u00a0\u0431\u044b\u0442\u044c \u0438 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043d\u043e\u00a0\u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u0435 \u044d\u0442\u043e \u0434\u043b\u044f\u00a0\u0432\u0441\u0435\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0438 \u044d\u0442\u043e, \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a\u00a0\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c\u0443 \u0441\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u0438\u044e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043a\u00a0\u0435\u043c\u043a\u043e\u0441\u0442\u0438 \u0434\u0438\u0441\u043a\u043e\u0432 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0412\u00a0\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u00a0\u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043c\u0430 \u043d\u0430 10\u201320%. \u042f \u0432\u0438\u0434\u0435\u043b \u0431\u0430\u0437\u044b Postgres \u043e\u0431\u044a\u0435\u043c\u043e\u043c \u043f\u043e\u0434 60\u00a0\u0422\u0411; \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0447\u0442\u043e\u00a0\u0432\u0430\u043c \u043f\u043e\u0434\u0430\u0440\u0438\u043b\u0438 \u0434\u0438\u0441\u043a\u043e\u0432 \u043d\u0430 6\u201312\u00a0\u0422\u0411.<\/p>\n<p>\u0415\u0441\u0442\u044c \u0441\u0442\u0430\u0440\u0430\u044f \u043f\u0440\u0438\u0442\u0447\u0430 \u043e\u00a0\u0442\u043e\u043c \u043a\u0430\u043a\u00a0\u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0443\u0441\u0442\u0443\u044e \u0431\u0430\u043d\u043a\u0443: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u0430\u043c\u043d\u0438, \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0441\u043e\u043a, \u043f\u043e\u0442\u043e\u043c \u0432\u043e\u0434\u0430. \u041f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u00a0\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u00a0Postgres \u0441\u00a0\u0443\u0447\u0435\u0442\u043e\u043c \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0434\u0443\u0442 \u0448\u0438\u0440\u043e\u043a\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b, \u0437\u0430\u0442\u0435\u043c \u0441\u0440\u0435\u0434\u043d\u0438\u0435, \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0432\u00a0\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0430\u00a0\u0441\u0442\u043e\u043b\u0431\u0446\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a\u00a0NUMERIC \u0438 TEXT, \u0432\u00a0\u0441\u0430\u043c\u043e\u043c \u043a\u043e\u043d\u0446\u0435. \u0422\u0430\u043a\u043e\u0432\u044b \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0438\u043a\u0442\u0443\u044e\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438.<\/p>\n<p>\u041d\u043e, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0430\u043c \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0439, \u0431\u043e\u043b\u0435\u0435 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u044b\u0439, \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code>CREATE TABLE user_order (   id            BIGSERIAL PRIMARY KEY NOT NULL,   user_id       BIGINT NOT NULL,   order_type    SMALLINT NOT NULL,   order_total   NUMERIC NOT NULL,   order_dt      TIMESTAMPTZ NOT NULL,   item_ct       INT NOT NULL,   ship_dt       TIMESTAMPTZ,   is_shipped    BOOLEAN NOT NULL DEFAULT false,   ship_cost     NUMERIC,   tracking_cd   TEXT,   receive_dt    TIMESTAMPTZ ); <\/code><\/pre>\n<p>\u0412\u00a0\u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043d\u0430 8\u00a0\u041c\u0411 \u0438\u043b\u0438 7,7% \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u0432\u00a0\u0438\u0434\u0435\u0430\u043b\u0435. \u0420\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0433\u0434\u0435\u2011\u0442\u043e \u043c\u0435\u0436\u0434\u0443 \u043b\u0443\u0447\u0448\u0438\u043c \u0438 \u0445\u0443\u0434\u0448\u0438\u043c \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u043c\u0438, \u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0431\u0430\u043b\u0430\u043d\u0441\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u0438 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<h3>\u0417\u0430\u043a\u043e\u043d\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u0438 \u0432\u044b\u0432\u043e\u0434<\/h3>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u0434\u043e\u00a0\u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0435\u00a0\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0432\u00a0Postgres? \u041d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0438 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432: \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u043e\u0435\u00a0\u2014 \u0432\u00a0\u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f\u00a0\u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0443\u0441\u0442\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432, \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435\u00a0\u2014 \u0432\u00a0\u0442\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0447\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u0412\u043e\u043f\u0440\u043e\u0441 \u0445\u043e\u0440\u043e\u0448\u0438\u0439, \u043d\u043e\u00a0\u043e\u0442\u0432\u0435\u0442\u0430 \u043d\u0430\u00a0\u043d\u0435\u0433\u043e \u043d\u0435\u0442.<\/p>\n<p>\u0412\u0438\u0434\u0438\u043c\u043e, \u0434\u0435\u043b\u043e \u0432\u00a0\u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430\u0445. \u0415\u0449\u0435 \u0432 2006\u00a0\u0433\u043e\u0434\u0443 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u043f\u0443\u043d\u043a\u0442 TODO \u0434\u043b\u044f\u00a0\u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u0421\u00a0\u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u0430\u0442\u0447\u0438 \u0438 \u0440\u0435\u043b\u0438\u0437\u044b \u0432\u044b\u0445\u043e\u0434\u0438\u043b\u0438 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e, \u043d\u043e\u00a0\u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0440\u0435\u0448\u0438\u0442\u044c \u0435\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e, \u0430\u00a0\u0432\u00a0\u043f\u0440\u0443\u0434\u0443 \u0441\u00a0TODO \u043f\u043b\u0430\u0432\u0430\u0435\u0442 \u0440\u044b\u0431\u0430 \u0438 \u043f\u043e\u043a\u0440\u0443\u043f\u043d\u0435\u0435. (<em>\u041e\u0442\u00a0\u0441\u0435\u0431\u044f\u00a0\u2014 \u0432\u0441\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u044b \u043d\u0430\u00a0Postgres 15.1\u00a0\u0432 2023; \u0446\u0438\u0444\u0440\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0432\u043f\u0430\u043b\u0438<\/em>).<\/p>\n<p>\u041d\u043e, \u0443\u0436 \u0435\u0441\u043b\u0438 \u044d\u0442\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0442\u043e \u0443\u0447\u0435\u0441\u0442\u044c \u0435\u0451 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e: \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u0447\u0442\u043e\u00a0\u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u0443\u044e \u043f\u0440\u0438\u0431\u0430\u0432\u043a\u0443 \u043a\u00a0\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438. <\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/756074\/\"> https:\/\/habr.com\/ru\/articles\/756074\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>8 + 2 = 16 \u0438\u043b\u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u043b\u0438\u0448\u043d\u0438\u0435 \u0431\u0430\u0439\u0442\u044b<\/h3>\n<p>\u0412\u00a0\u044f\u0437\u044b\u043a\u0430\u0445 \u043d\u0438\u0437\u043a\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a\u00a0C, \u043d\u0430\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d Postgres, \u0434\u043b\u044f\u00a0\u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a\u00a0\u0434\u0430\u043d\u043d\u044b\u043c \u0432\u00a0\u043f\u0430\u043c\u044f\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0440\u0430\u0437\u043c\u0435\u0440\u044b, \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442\u00a0\u0442\u043e\u0433\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u0442\u0430 \u043d\u0430\u00a0\u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 32-\u0431\u0438\u0442\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u043e\u0432, \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u00a0\u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430. \u0422\u043e \u0435\u0441\u0442\u044c, \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u043b\u044e, \u043f\u043e\u0434\u00a0\u043d\u0435\u0433\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430 \u043f\u0430\u043c\u044f\u0442\u0438. \u042d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 (alignment).<\/p>\n<p>Postgres \u0442\u043e\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0432\u00a0\u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442\u043e\u0432. \u041a\u0430\u043a\u00a0\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u0432\u00a0\u0440\u044f\u0434\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u00a0\u0438\u0434\u0443\u0449\u0438\u0445 \u043f\u043e\u0434\u0440\u044f\u0434 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u0445 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0431\u0430\u0439\u0442\u0430\u043c\u0438 \u0434\u043b\u044f\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>SELECT    pg_column_size(row()) AS empty,    pg_column_size(row(0::SMALLINT)) AS byte2,    pg_column_size(row(0::BIGINT)) AS byte8,    pg_column_size(row(0::SMALLINT, 0::BIGINT)) AS byte16 ; --------------------------------  empty | byte2 | byte8 | byte16  -------+-------+-------+--------     24 |    26 |    32 |     40<\/code><\/pre>\n<p>\u041f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 24\u00a0\u0431\u0430\u0439\u0442\u0430 (\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0437\u0430\u043f\u0438\u0441\u0438), SMALLINT \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u0434\u0432\u0430 \u0431\u0430\u0439\u0442\u0430, BIGINT\u00a0\u2014 \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442\u043e\u0432, \u0430\u00a0\u0432\u043c\u0435\u0441\u0442\u0435 \u043e\u043d\u0438 \u0434\u0430\u044e\u0442\u2026 16\u00a0\u0431\u0430\u0439\u0442\u043e\u0432? \u042d\u0442\u043e \u043d\u0435\u00a0\u043e\u0448\u0438\u0431\u043a\u0430: \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u043f\u043e\u00a0\u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0431\u0430\u0439\u0442\u0430\u043c\u0438 \u0434\u043b\u044f\u00a0\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0432\u00a0\u0446\u0435\u043b\u044f\u0445 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u043c\u0435\u0441\u0442\u043e 2\u00a0+ 8\u00a0= 10\u00a0\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 8\u00a0+ 8\u00a0= 16. <\/p>\n<p>\u041f\u043e\u043a\u0430 \u0447\u0442\u043e\u00a0\u044d\u0442\u043e \u043d\u0435\u00a0\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u043d\u043e\u00a0\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0435\u0431\u0435 \u043d\u0435\u043a\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u00a0\u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430:<\/p>\n<pre><code>CREATE TABLE user_order (   is_shipped    BOOLEAN NOT NULL DEFAULT false,   user_id       BIGINT NOT NULL,   order_total   NUMERIC NOT NULL,   order_dt      TIMESTAMPTZ NOT NULL,   order_type    SMALLINT NOT NULL,   ship_dt       TIMESTAMPTZ,   item_ct       INT NOT NULL,   ship_cost     NUMERIC,   receive_dt    TIMESTAMPTZ,   tracking_cd   TEXT,   id            BIGSERIAL PRIMARY KEY NOT NULL );<\/code><\/pre>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u0442\u0440\u0430\u043d\u043d\u043e, \u043d\u043e\u00a0\u0442\u0430\u043a \u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043e. \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u00a0\u0431\u044b\u043b\u0430 \u043d\u0430\u0431\u0440\u043e\u0441\u0430\u043d\u0430 \u0432\u00a0\u0441\u043f\u0435\u0448\u043a\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c, \u0430\u00a0\u043c\u043e\u0436\u0435\u0442\u00a0\u0431\u044b\u0442\u044c \u0435\u043c\u0443 \u043f\u043e\u043c\u043e\u0433\u043b\u0430 ORM. \u041d\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f\u00a0\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u0438. \u0412\u043e\u0442 \u043a\u0430\u043a\u00a0\u0432\u0438\u0434\u0438\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 Postgres:<\/p>\n<pre><code>SELECT a.attname, t.typname, t.typalign, t.typlen   FROM pg_class c   JOIN pg_attribute a ON (a.attrelid = c.oid)   JOIN pg_type t ON (t.oid = a.atttypid) WHERE c.relname = 'user_order'    AND a.attnum >= 0  ORDER BY a.attnum;  -----------------------------------------------    attname   |   typname   | typalign | typlen  -------------+-------------+----------+--------  is_shipped  | bool        | c        |      1  user_id     | int8        | d        |      8  order_total | numeric     | i        |     -1  order_dt    | timestamptz | d        |      8  order_type  | int2        | s        |      2  ship_dt     | timestamptz | d        |      8  item_ct     | int4        | i        |      4  ship_cost   | numeric     | i        |     -1  receive_dt  | timestamptz | d        |      8  tracking_cd | text        | i        |     -1  id          | int8        | d        |      8 <\/code><\/pre>\n<p>\u0412\u00a0\u0441\u0442\u043e\u043b\u0431\u0446\u0435 typalign \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0442\u0438\u043f \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <a href=\"https:\/\/www.postgresql.org\/docs\/current\/catalog-pg-type.html\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0432\u00a0\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <\/a> \u0434\u043b\u044f\u00a0pg_type). \u0414\u043b\u044f\u00a0\u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0441\u00a0\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u00a0\u0431\u0430\u0439\u0442\u0430\u0445. \u0414\u043b\u044f\u00a0NUMERIC \u0438 TEXT \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435; \u043a\u00a0\u043d\u0438\u043c \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043f\u043e\u043f\u043e\u0437\u0436\u0435. \u0410\u00a0\u043f\u043e\u043a\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u00a0\u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u043b\u0435\u0439 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u00a0\u0442\u0430\u0431\u043b\u0438\u0446\u0435. <\/p>\n<h3>\u0420\u043e\u0432\u043d\u044f\u0435\u043c \u043f\u043e\u0434 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442<\/h3>\n<p>\u0414\u043b\u044f\u00a0\u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438, Postgres \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446, \u043c\u0435\u043d\u044c\u0448\u0438\u0439 \u0447\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f (8\u00a0\u0431\u0430\u0439\u0442\u043e\u0432) \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u00a0\u043d\u0438\u043c. \u0412\u00a0\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u00a0\u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u043e\u0439 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u0435 \u0431\u0430\u0439\u0442\u044b \u0432\u00a0\u0440\u043e\u043b\u0438 \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f.<\/p>\n<p>\u0417\u0430\u043b\u044c\u0451\u043c \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<pre><code>INSERT INTO user_order (     is_shipped, user_id, order_total, order_dt, order_type,     ship_dt, item_ct, ship_cost, receive_dt, tracking_cd ) SELECT true, 1000, 500.00, now() - INTERVAL '7 days',        3, now() - INTERVAL '5 days', 10, 4.99,        now() - INTERVAL '3 days', 'X5901324123479RROIENSTBKCV4' FROM generate_series(1, 1000000);  SELECT pg_relation_size('user_order') AS size_bytes,        pg_size_pretty(pg_relation_size('user_order')) AS size_pretty;  --------------------------  size_bytes | size_pretty  ------------+-------------   141246464 | 135 MB <\/code><\/pre>\n<p>\u0411\u0435\u0440\u0451\u043c \u044d\u0442\u0438 \u0446\u0438\u0444\u0440\u044b \u0437\u0430\u00a0\u043e\u0442\u043f\u0440\u0430\u0432\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443. \u0412\u043e\u043f\u0440\u043e\u0441: \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442\u043e\u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0434\u043b\u044f\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f, \u0442\u043e \u0435\u0441\u0442\u044c \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u043d\u044b? \u0412\u043e\u0442 \u043e\u0446\u0435\u043d\u043a\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0443\u0441\u0442\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432 \u043f\u043e\u00a0\u0434\u0430\u043d\u043d\u044b\u043c \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p> 7 \u0431\u0430\u0439\u0442 \u043c\u0435\u0436\u0434\u0443 is_shipped \u0438 user_id<\/p>\n<\/li>\n<li>\n<p> 4 \u0431\u0430\u0439\u0442\u0430 \u043c\u0435\u0436\u0434\u0443 order_total \u0438 order_dt<\/p>\n<\/li>\n<li>\n<p> 6 \u0431\u0430\u0439\u0442 \u043c\u0435\u0436\u0434\u0443 order_type \u0438 ship_dt<\/p>\n<\/li>\n<li>\n<p> 4 \u0431\u0430\u0439\u0442\u0430 \u043c\u0435\u0436\u0434\u0443 receive_dt \u0438 id<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f 21\u00a0\u043f\u0443\u0441\u0442\u043e\u0439 \u0431\u0430\u0439\u0442 \u0432\u00a0\u043a\u0430\u0436\u0434\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438; \u043f\u0440\u0438\u00a0\u044d\u0442\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 59\u00a0\u0431\u0430\u0439\u0442\u043e\u0432, \u0430\u00a0\u043e\u0431\u0449\u0430\u044f \u0434\u043b\u0438\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 80\u00a0\u0431\u0430\u0439\u0442\u043e\u0432 \u0431\u0435\u0437\u00a0\u0443\u0447\u0435\u0442\u0430 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430. \u041f\u043e\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f\u00a0\u0442\u0438\u043f\u043e\u0432 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430. \u0414\u0430\u043d\u043d\u044b\u0435 \u0441\u00a0\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c: NUMERIC \u0438 TEXT \u043c\u0435\u043d\u044f\u044e\u0442 \u044d\u0442\u0443 \u043e\u0446\u0435\u043d\u043a\u0443, \u043d\u043e\u00a0\u0434\u043b\u044f\u00a0\u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u044f \u043e\u043d\u0430 \u0433\u043e\u0434\u0438\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u044d\u0442\u0430 \u043e\u0446\u0435\u043d\u043a\u0430 \u0434\u0430\u0436\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0435\u0440\u043d\u0430, \u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0430 (21\/80\u00a0=) 26% \u0438\u043b\u0438\u00a0\u043d\u0430 37\u00a0\u041c\u0431. \u0421\u0442\u043e\u0438\u0442 \u043a\u043e\u043f\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h3>\u0414\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430\u00a0\u0442\u0438\u043f\u044b NUMERIC \u0438 TEXT. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u044d\u0442\u043e \u0442\u0438\u043f\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u043e\u043d\u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u043e\u2011\u0434\u0440\u0443\u0433\u043e\u043c\u0443. \u0412\u043e\u0437\u044c\u043c\u0435\u043c NUMERIC: <\/p>\n<pre><code>SELECT pg_column_size(row()) AS empty_row,        pg_column_size(row(0::NUMERIC)) AS zero_val,        pg_column_size(row(1::NUMERIC)) AS no_dec,        pg_column_size(row(1.1::NUMERIC)) AS with_dec,        pg_column_size(row(1::INT4)) AS int4,        pg_column_size(row(1::NUMERIC, 1::INT4)) AS num_int4,        pg_column_size(row(1::INT4, 1::NUMERIC)) AS int4_num,        pg_column_size(row(1.1::NUMERIC, 1::INT4)) AS num_dec_int4,        pg_column_size(row(1::INT4, 1.1::NUMERIC)) AS int4_num_dec ;  ------------------------------------------------------------------------------------------------------  empty_row | zero_val | no_dec | with_dec | int4 | num_int4 | int4_num | num_dec_int4 | int4_num_dec |  ------------------------------------------------------------------------------------------------------         24 |       27 |     29 |       31 |   28 |       36 |       33 |           36 |           35 | <\/code><\/pre>\n<p>\u041f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e\u00a0\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u00a0\u0441\u0442\u043e\u043b\u0431\u0446\u0435 NUMERIC \u043d\u0435\u00a0\u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u043d\u043e\u00a0\u0432\u043b\u0438\u044f\u044e\u0442 \u043d\u0430\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u00a0NUMERIC. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c TEXT:<\/p>\n<pre><code>SELECT pg_column_size(row()) AS empty_row,        pg_column_size(row(''::TEXT)) AS no_text,        pg_column_size(row('a'::TEXT)) AS min_text,        pg_column_size(row('a'::TEXT, 1::INT4)) AS txt_smint,        pg_column_size(row('ab'::TEXT, 1::INT4)) AS txt2_smint,        pg_column_size(row('abc'::TEXT, 1::INT4)) AS txt3_smint,        pg_column_size(row('abcd'::TEXT, 1::INT4)) AS txt4_smint,        pg_column_size(row('abcde'::TEXT, 1::INT4)) AS txt5_smint,        pg_column_size(row(1::INT4, 'a'::TEXT)) AS smint_txt,        pg_column_size(row(1::INT4, 'ab'::TEXT)) AS smint_txt2,        pg_column_size(row(1::INT4, 'abc'::TEXT)) AS smint_txt3,        pg_column_size(row(1::INT4, 'abcd'::TEXT)) AS smint_txt4,        pg_column_size(row(1::INT4, 'abcde'::TEXT)) AS smint_txt5 ;  -----------------------------------------------------------------------------------------------------------------------------------------------------------------  empty_row | no_text | min_text | txt_smint | txt2_smint | txt3_smint | txt4_smint | txt5_smint | smint_txt | smint_txt2 | smint_txt3 | smint_txt4 | smint_txt5 |  -----------------------------------------------------------------------------------------------------------------------------------------------------------------         24 |      25 |       26 |        32 |         32 |         32 |         36 |         36 |        30 |         31 |         32 |         33 |         34 |  <\/code><\/pre>\n<p>\u041e\u0442\u0441\u044e\u0434\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e\u00a0\u0441\u0442\u043e\u043b\u0431\u0435\u0446 TEXT \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0434\u043e\u00a0\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u0447\u0438\u0441\u043b\u0430, \u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0437\u0430\u00a0\u043d\u0438\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 (\u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0430\u0439\u0442\u0430 \u0434\u043b\u044f\u00a0INT4, \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442\u043e\u0432 \u0434\u043b\u044f\u00a0INT8). \u0410\u00a0\u0432\u043e\u0442 \u0435\u0441\u043b\u0438 TEXT \u0438\u0434\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0441\u00a0\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c, \u0442\u043e \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u043d\u0435\u00a0\u043e\u043a\u0440\u0443\u0433\u043b\u044f\u0435\u0442\u0441\u044f. <\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043d\u0435\u00a0\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u043d\u0430\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u00a0\u043a\u043e\u043d\u0446\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<h3>\u0414\u0430\u043d\u043d\u044b\u0435 \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u043a\u00a0\u0441\u0442\u043e\u043b\u0431\u0446\u0443 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u0435 \u0431\u0430\u0439\u0442\u044b \u0434\u043b\u044f\u00a0\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u00a0\u0440\u0430\u0437\u043c\u0435\u0440\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e\u00a0\u0441\u0430\u043c\u044b\u0435 \u00ab\u0448\u0438\u0440\u043e\u043a\u0438\u0435\u00bb \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u0438\u043f\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0434\u0442\u0438 \u043f\u0435\u0440\u0432\u044b\u043c\u0438. \u041d\u043e, \u043c\u043e\u0436\u043d\u043e \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u0430\u044f \u0448\u0438\u0440\u0438\u043d\u0430 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0430 \u0432\u043e\u0441\u0435\u043c\u044c \u0431\u0430\u0439\u0442\u043e\u0432.<\/p>\n<pre><code>SELECT pg_column_size(row()) AS empty_row,        pg_column_size(row(1::SMALLINT)) AS int2,        pg_column_size(row(1::INT)) AS int4,        pg_column_size(row(1::BIGINT)) AS int8,        pg_column_size(row(1::SMALLINT, 1::BIGINT)) AS padded,        pg_column_size(row(1::INT, 1::INT, 1::BIGINT)) AS not_padded ;  ------------------------------------------------------  empty_row | int2 | int4 | int8 | padded | not_padded  -----------+------+------+------+--------+------------         24 |   26 |   28 |   32 |     40 |         40 <\/code><\/pre>\n<p> \u041a\u0430\u043a\u00a0\u0432\u0430\u043c?<\/p>\n<h3>\u0422\u0435\u0442\u0440\u0438\u0441 \u0441\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438<\/h3>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432\u00a0\u043f\u043e\u0434\u0431\u043e\u0440\u0435 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0443\u0441\u0442\u044b\u0445 \u0431\u0430\u0439\u0442\u043e\u0432. \u0418 \u0438\u0437\u00a0\u0432\u0441\u0435\u0433\u043e \u0432\u044b\u0448\u0435\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f: \u00ab\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u043f\u043e\u00a0\u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u0448\u0438\u0440\u0438\u043d\u044b \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u0432\u00a0\u043d\u0438\u0445 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437\u00a0pg_type\u00bb. \u042d\u0442\u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c, \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0443 \u0432\u00a0\u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0434\u043b\u044f\u00a0\u0432\u044b\u0432\u043e\u0434\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438 \u0438\u0445 \u0442\u0438\u043f\u043e\u0432:<\/p>\n<pre><code>SELECT a.attname, t.typname, t.typalign, t.typlen   FROM pg_class c   JOIN pg_attribute a ON (a.attrelid = c.oid)   JOIN pg_type t ON (t.oid = a.atttypid)  WHERE c.relname = 'user_order'    AND a.attnum >= 0  ORDER BY t.typlen DESC ;  -----------------------------------------------    attname   |   typname   | typalign | typlen  -------------+-------------+----------+--------  id          | int8        | d        |      8  user_id     | int8        | d        |      8  order_dt    | timestamptz | d        |      8  ship_dt     | timestamptz | d        |      8  receive_dt  | timestamptz | d        |      8  item_ct     | int4        | i        |      4  order_type<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-352795","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/352795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=352795"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/352795\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=352795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=352795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=352795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}