иногда есть фризы, например, если открыть пхпшторм, который я уже 2 часа не открывал, или резко перейти с него на фотошоп
INSTEAD OF DELETE ON all_abonents
Не могу удалить foreign table из postgres запросом
Если делать элементарный запрос SELECT * FROM fwd_orders LIMIT 500, то все исполняется за 600ms . А если в этот запрос добавить любой ORDER BY, то выполнение запроса идет 10 и более минут (в таблице более 20млн. строк). Почему так происходит? И как можно ускорить работу?
melkij=> \da pg_catalog.sum
Список агрегатных функций
Схема | Имя | Тип данных результата | Типы данных аргументов | Описание
------------+-----+-----------------------+------------------------+--------------------------------------------------
pg_catalog | sum | numeric | bigint | sum as numeric across all bigint input values
pg_catalog | sum | double precision | double precision | sum as float8 across all float8 input values
pg_catalog | sum | bigint | integer | sum as bigint across all integer input values
pg_catalog | sum | interval | interval | sum as interval across all interval input values
pg_catalog | sum | money | money | sum as money across all money input values
pg_catalog | sum | numeric | numeric | sum as numeric across all numeric input values
pg_catalog | sum | real | real | sum as float4 across all float4 input values
pg_catalog | sum | bigint | smallint | sum as bigint across all smallint input values
Просто работаю через Valentina Studio и не совсем понятно что происходит под капотом.
DO UPDATE SET ... WHERE condition
melkij=> create temp table foo (item int primary key, d date, price numeric);
CREATE TABLE
melkij=> insert into foo values (1, '2021-07-30', 100) on conflict (item) do update set price = excluded.price, d = excluded.d where excluded.d > foo.d;
INSERT 0 1
melkij=> table foo;
item | d | price
------+------------+-------
1 | 2021-07-30 | 100
(1 строка)
melkij=> insert into foo values (1, '2021-08-01', 110) on conflict (item) do update set price = excluded.price, d = excluded.d where excluded.d > foo.d;
INSERT 0 1
melkij=> table foo;
item | d | price
------+------------+-------
1 | 2021-08-01 | 110
(1 строка)
melkij=> insert into foo values (1, '2021-07-20', 80) on conflict (item) do update set price = excluded.price, d = excluded.d where excluded.d > foo.d;
INSERT 0 0
melkij=> table foo;
item | d | price
------+------------+-------
1 | 2021-08-01 | 110
(1 строка)