Have a table in my database with around 9,000,000 data.
My problem occurs at the time of
and consult that table through Laravel, since when doing only the query to extract all the data with Number::all();
Well, my server obviously collapses because of its capacity, but my detail is that I need to extract around 50,000 data randomly from that table and I don't know how to do it. Since the Random method of the Collection does not execute it since the server falling does not generate anything for me.
What could you propose to be able to generate my query? How could I do it? It's a matter of my company and I really don't know what else to do.
This is the error that always generates me when consulting:
PHP Fatal error: Allowed memory size of 2097152 bytes exhausted
When testing with chunk
it generates values in less than 2 seconds, the detail is that it brings me the values starting with the first index of the table when random values are needed.
I did the test with this code
$numeros = Number::select('NUMBERS_ID', 'NUMBER')
->inRandomOrder()
->take(1000)
->get()
->chunk(100);
But it still generates an amount of time of about 2 minutes
I need to generate random data in a considered amount of time of about 30 seconds, but I am receiving random responses with an approximate 2 minutes.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire