М
set proc = good/all::float*100
так норм?
Size: a a a
М
set proc = good/all::float*100
NB
NB
ア
NB
NB
YS
set proc = good/all::float*100
М
YS
М
СК
alter table subscription add constraint subscription_car_id_tstzrange_excl exclude using gist(cast(car_id as text) with =, tstzrange(started_at, finished_at, '[]') with &&);. Оно не позволяет создать подписку на одну и ту же машину, у которой время действия пересекает время действия другой. Но теперь нужно добавить условие where deleted_at is null (если подписка не удалена). Но в constraint же нельзя добавлять where. А в create index нет exclude. Как это провернуть?
YS
WITH x (id, f1, f2, f3, f4, f5, f6, f7, f8, f9) AS (
VALUES
(1, NULL, 'test', NULL, 'test1', 'test3', NULL, NULL, 'test4', 'test5'),
(2, NULL, NULL, 'test', 'test1', NULL, 'test3', NULL, NULL, NULL)
)
SELECT x.*,
a.s[1] AS g1, a.s[2] AS g2, a.s[3] AS g3, a.s[4] AS g4, a.s[5] AS g5,
a.s[6] AS g6, a.s[7] AS g7, a.s[8] AS g8, a.s[9] AS g9
FROM x
CROSS JOIN LATERAL (
SELECT array_agg(u.e ORDER BY u.n) FILTER (WHERE u.e IS NOT NULL) AS s
FROM unnest(ARRAY[x.f1, x.f2, x.f3, x.f4, x.f5, x.f6, x.f7, x.f8, x.f9]) WITH ORDINALITY AS u(e, n)
) AS a;
YS
EXCLUDE [ USING index_method ] ( exclude_element WITH operator [, ... ] ) index_parameters [ WHERE ( predicate ) ]
NB
WITH x (id, f1, f2, f3, f4, f5, f6, f7, f8, f9) AS (
VALUES
(1, NULL, 'test', NULL, 'test1', 'test3', NULL, NULL, 'test4', 'test5'),
(2, NULL, NULL, 'test', 'test1', NULL, 'test3', NULL, NULL, NULL)
)
SELECT x.*,
a.s[1] AS g1, a.s[2] AS g2, a.s[3] AS g3, a.s[4] AS g4, a.s[5] AS g5,
a.s[6] AS g6, a.s[7] AS g7, a.s[8] AS g8, a.s[9] AS g9
FROM x
CROSS JOIN LATERAL (
SELECT array_agg(u.e ORDER BY u.n) FILTER (WHERE u.e IS NOT NULL) AS s
FROM unnest(ARRAY[x.f1, x.f2, x.f3, x.f4, x.f5, x.f6, x.f7, x.f8, x.f9]) WITH ORDINALITY AS u(e, n)
) AS a;
СК
EXCLUDE [ USING index_method ] ( exclude_element WITH operator [, ... ] ) index_parameters [ WHERE ( predicate ) ]
ВС
GS
ВС
ВС
GS