Large PHP arrays or temporary MySQL memory tables?

How would you temporarily store several thousand pairs key => valueor key => arrayas part of a single process. A search in keywill be performed continuously in the process, and data will be discarded when the process is completed.

Should I use arrays? MySQL temporary tables? Or something in between?

+3
source share
6 answers

It depends on how many thousands of thousands means and how big the array gets into memory. If you can handle this in PHP, you have to do it because using mysql creates a little overhead here.

memory_limit php.ini , MySQL.

, Memcached Redis, (Redis promises O (1))

+6

?! , KILObytes?!

, ? , , , . , , . - ...

+4

Memcached - .

, php. , , .

+2

. , ( MySQL) . , . (, Informix), , , MySQL . , PHP, .

. , PHP .

+1

, . .

  • If your data is in a database, you better keep it there and manipulate it there, and just get the items you need. Use temporary tables if necessary

  • If you are already in PHP, you are probably better off there. Although data processing in PHP is quite intense

+1
source
  • If the data search will be performed with only a few queries, use it with the mysql temporary table.

  • If there will be a lot of data searching, it is almost always better to store it on the php side. (connection overhead)

0
source

Source: https://habr.com/ru/post/1749985/


All Articles