begin;
create role specific_activity;
create function stat_activity() .. security definer;
revoke execute on function stat_activity() from public; -- права на запуск не всем
grant execute on function stat_activity() to specific_activity; -- а только этой роли
commit;
grant specific_activity to someuser;
insert into appointments (customer_id, in_trash, status, filial_id, invoice_id, time_start) values
(5, false, 4, 1, null, '2023-12-23'),
(5, false, 4, 1, 123, '2024-01-13')
postgres=# create database mydb;
Я выполняю 2 одинаковых запроса
Bitmap Index Scan on ix_friends_user_id (cost=0.00..61.56 rows=5465 width=0) (actual time=0.742..0.743 rows=88 loops=1)