A
A
Alexey Yarkov2015-09-28 16:41:39
PHP
Alexey Yarkov, 2015-09-28 16:41:39

How will it work faster and by how much?

There is a function that generates a set of random user data. With the number of iterations < 100, it still works all right, but most of all, it’s just slowly, slowly. The brake is that with each iteration there are 2 calls to the muscle. A region is selected based on the country_id, and a city is selected based on the country_id and region_id. There is an idea to make a selection from these tables immediately at the beginning of the function and access associative arrays in a loop. How much will it speed up the work?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
lyeskin, 2015-09-28
@yarkov

It will speed up, of course, and much more. Weird question. The main thing is that there is not much data, otherwise your memory will overflow.

C
Cat Anton, 2015-09-28
@27cm

Take it and check it by measuring the speed of work and consumed memory.
You can go even further - save the array to RAM, for example, using memcache . And in general, the base will not have to be pulled.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question