POSTGRESQL: Refresh the materialized view which effect when there are change based on columns
The most efficient solution is to not fire the trigger in that case:

CREATE TRIGGER trigger_tabel 
AFTER INSERT 
   OR UPDATE OF (column_a) --&lt;&lt; only fire the trigger if column_a is updated
   OR DELETE 
ON name_table
FOR EACH ROW EXECUTE PROCEDURE sp_refresh_matview();


If you have multiple columns that should trigger the refresh, you can separate them using commas: OR UPDATE OF (column_a, column_c, column_d)



A less efficient solution is to check if the column changed inside the trigger function:

CREATE OR REPLACE FUNCTION sp_refresh_matview() RETURNS trigger A
$$
DECLARE
rec RECORD;
BEGIN
    IF TG_OP = 'INSERT' OR TG_OP = 'DELETE' OR 
       -- add all columns that need to be checked for changes
       (old.column_b IS DISTINCT FROM new.column_b) 
    THEN
      FOR rec IN
        SELECT *
        FROM pg_matviews WHERE (
            definition LIKE '%'||TG_TABLE_NAME||'%')        
      LOOP
        EXECUTE 'REFRESH MATERIALIZED VIEW '|| rec.matviewname; 
      END LOOP; 
    END IF;
    RETURN NULL;
END;
$$
LANGUAGE plpgsql ;


If you are using the same trigger function for all tables, then obviously this only works if all tables have the same columns that you want to check. But not firing the trigger to begin with will be much more efficient and should be your preferred solution.