QUERY PLAN
GroupAggregate (cost=92.88..94.38 rows=20 width=92)
Group Key: (CASE WHEN (bargain_date >= ((to_char((bargain_date)::timestamp with time zone, 'YYYY-'::text) || '01-01'::text))::date) THEN (to_char((bargain_date)::timestamp with time zone, 'YYYY'::text))::integer ELSE ((to_char((bargain_date)::timestamp with time zone, 'YYYY'::text))::integer - 1) END)
-> Sort (cost=92.88..92.93 rows=20 width=26)
Sort Key: (CASE WHEN (bargain_date >= ((to_char((bargain_date)::timestamp with time zone, 'YYYY-'::text) || '01-01'::text))::date) THEN (to_char((bargain_date)::timestamp with time zone, 'YYYY'::text))::integer ELSE ((to_char((bargain_date)::timestamp with time zone, 'YYYY'::text))::integer - 1) END)
-> Bitmap Heap Scan on tbl_projects p (cost=4.58..92.45 rows=20 width=26)
Recheck Cond: (client_id = 5)
Filter: ((bargain_date IS NOT NULL) AND (project_status = 3))
-> Bitmap Index Scan on tbl_projects_client_id_idx (cost=0.00..4.57 rows=39 width=0)
Index Cond: (client_id = 5)