improved database performance by changing models and using SQL insert transactions