'How to Speed Up Flag Procces (Update Data) in foreach using php?

i have data in foreach. The data entered in the foreac will be given a 'Y' flag. If the data is small, the flag process runs normally. But if the data is big, the flag process is very slow.

How to speed up flag processing inside foreach ?

my code :

 foreach ($results as $key=>$row) {
        $data[$key]         = $row;
        $data[$key]['_id']  = (string) Application_Helper_General::generateIdJsonFile();

        $queryUdateMemberFlag = 'UPDATE M_MEMBER SET SYNC_FLAG = "Y" WHERE MEMBER_ID = '.$row['MEMBER_ID'].'';
        $db->query($queryUdateMemberFlag);
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source