Removing values from array in postgreSQL
This should perform nicely:

UPDATE books AS b
SET    users = bu.users
FROM  (
   SELECT b1.name, u.users
   FROM   books b1
   CROSS  JOIN LATERAL (
      SELECT ARRAY(
         SELECT user_id
         FROM   unnest(b1.users) WITH ORDINALITY u(user_id, ord)
         JOIN   users u USING (user_id)
         ORDER  BY u.ord
         ) 
      ) u(users)
   ) bu
WHERE   b.name = bu.name
AND     b.users &lt;&gt; bu.users;


Preserves original order of array elements. If you don't need to, drop ORDINALITY &amp; friends from the query.

Can result in empty arrays.

Assuming ...


books.name is the PK. Else use some other UNIQUE column from books instead.
users.user_id is at least UNIQUE.
books.users does not contain NULL values. Else those are eliminated as well.