Q:

Any way to optimize this query since I only update the table instead of inserting new rows?

The structure of the new_table is that it will never insert new rows, but will only update the existing ones.
Currently I am using the following query. Is there any way to optimize this (in terms of performance) to achieve faster updates of the rows?
INSERT INTO new_table (hash, pages, visits, last_visit)
   SELECT A.hash, COUNT(B.id), A.visits, MAX(B.timestamp)
      FROM audience A
JOIN behaviour B ON B.hash = A.hash
GROUP BY A.hash
   ON DUPLICATE KEY UPDATE
      new_table.pages=VALUES(pages), 
      new_table.visits=VALUES(visits), 
      new_table.last_visit=VALUES(last_visit)

A:

Use UPDATE rather than INSERT.
UPDATE new_table n
JOIN audience AS a on a.hash = n.hash
JOIN (
    SELECT hash, COUNT(*) AS pages, MAX(timestamp) AS last_visit
    FROM behaviour
    GROUP BY hash) AS b ON b.hash = n.hash
SET n.pages = b.pages, n.visits = a.visits, n.last_visit = b.last_visits

