I want to select all columns where the dates are not older than start_time to avoid older dates.
What would be a good statement without performance issues?
here is my code:
SELECT
u.id,
u.firstname,
u.lastname,
json_agg(json_build_object('plan_id', wp.id, 'start_time', wp.start_time, 'end_time', wp.end_time)) as times
FROM workers_plan wp
JOIN users u
ON wp.user_id = u.id
WHERE wp.user_id = ANY($1::uuid[]) AND wp.tenant_id = $2 AND wp.start_time > NOW()
GROUP BY u.id;
I added wp.start_time > NOW() but is there a better statement on what I can do?