Is the palavra field indexed in the database ? If not, you could index this field, the query should be faster.
I also have a question ;) ... I never used [[:<:]]. What's that ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm running the following code to make a fix in mysql database:
public function correcaop(Request $request)
{
$palavras = palavras_br::whereBetween('id', [1, 150000])->get();
foreach($palavras as $p){
$busca = nvi::where('palavra', 'RLIKE','[[:<:]]'.$p->palavras.'[[:>:]]')->count();
$update = palavras_br::where('id', $p->id)->first()->update(['total_versiculos' => $busca]);
}
}
I'm running the following code to make a fix in mysql database:
the "palavras_br" table contains 320k lines and the nvi table 32k lines. I need to take each word of the table "palavras_br" and count in how many rows of the table "nvi" it exists.
Everything is working, except for the delay. In 3 hours, it only corrected 30k lines. As it is, it takes almost 1 full day to finish. It seems extremely slow to me as my VPS server has 4gb of ram and ssd storage.
Does this slowness make sense or is there something I can do to make this adjustment to the tables faster?
Please or to participate in this conversation.