added fields to SQL to ratings and improved speed