DRYing two very similar SQL conditional inserts
You'll want to create a stored procedure that takes your setting ID

    CREATE OR REPLACE FUNCTION InsertUserProfile(id INTEGER) 
RETURNS void AS $$
 BEGIN
   INSERT  INTO user_profile
     ( user_id ,
       setting_id ,
       value
     )
     SELECT  id ,
       id ,
       true
     FROM    users
     WHERE   NOT EXISTS ( SELECT user_id ,
            setting_id
           FROM   user_profile
           WHERE  id = id
            AND setting_id = @ID );
 END;
 $$ LANGUAGE plpgsql;


You'll then want to call it like this:

SELECT usp_InsertUserProfile(16)