I have below table in my project.
For each user we can have around 50 menus mapped in menus_users table.
I have written a cron job for testing purpose which create users with menu permissions.
so for 15000 users we will have around 750000 records in menus_users table.
below is the logic to create user
//create new user.
$user = $this->Users->newEntity();
//find all menu items.
$menus = $this->Users->Menus->find('all');
//set the menus array so assoicated data will be mapped in menus_users.
$user->menus = $menus->toArray();
//now save the data
but problem is when the data is increasing in menus_users table the saving function of Users->save($user) is becoming slow. after 15000 users it is talking around 20 seconds.
Is there anyone who can suggest me a better way to save it?