"Inner" Group By Query sequential scan
I think this is a good candidate for using LATERAL join:

SELECT id, 
       shared.views     AS views_count, 
       is_shared, 
       shared.views &gt; 0 AS tracked 
FROM   pages 
       LEFT JOIN LATERAL
                 (SELECT sum(shares.view_counter) AS views
                  FROM   shares 
                  WHERE  shares.page_id = pages.id
                 ) AS shared 
              ON TRUE
WHERE pages.id IN (1, 2, 3) ;