Add instance processing to the SQL