Add data to second table on UPDATE (PostgreSQL only)
get rid of FOR EACH ROW: If N rows get updated, it would be nice if only one INSERT gets executed


How would that work, you wouldn't have access to OLD or NEW, because it'd be a statement-trigger.

  Don't use plpythonu


Python natively doesn't support running as a trusted language. You can easily use plpgsql.


Code for a plpgsql function,

CREATE OR REPLACE FUNCTION add_ticket_to_transfere_table()
RETURNS TRIGGER
AS $$
    BEGIN
      INSERT INTO transfere_table (ticket_id) VALUES (new.id);
      RETURN new;
    END;
$$
LANGUAGE plpgsql;


This isn't how I would personally run this though. What I would do is 


Create a boolean on the row for triaged or whatever the transfere_table represents.
When you insert, have that Boolean default to true. Effectively a column-trigger if no data is provided. When you update the ticket, have that boolean set in the update statement.


If you don't want to touch that the table itself, I'd run your process in reverse.


Create the table transfere_done

CREATE TABLE transfere_done (
  ticket_id int PRIMARY KEY REFERENCES ticket.ticket_id
)

Copy over all the ids to it. 
Create the below view,

CREATE VIEW transfere_queue
AS
  SELECT * FROM ticket
  WHERE NOT EXISTS (
    SELECT 1
    FROM transfere_done
    WHERE transfere_done.id = ticket.id
  );



Now, when you insert into ticket, it automagically shows up under transfere_queue until you insert into transfere_done. You may or may not want to MATERIALIZE the view. Either way, I really hate triggers when not needed and I try to engineer around them.