Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP performance, reading from a file or reading for database? [closed]

Tags:

php

caching

I need to know this information please, I use the file() function in PHP which reads an entire file into an array; that file contains serialized objects that I unserialize and use.

On the other hand, I have the option of storing information in MySQL and retrieving it using a query.

Knowing that this operation is expected to be done millions of times a day, is it better for PHP to read and unserialize data from file or from database? I have no statistics in hand :(

Thank you in advance.

like image 666
user1997620 Avatar asked Dec 09 '25 20:12

user1997620


1 Answers

Memory is going to be faster, and generally mysql will cache common queries in memory (unless the query cache is disabled for some reason). If the server is remote network latency may need to be accounted for.

Now, there is a better way to do this. Use APC or a local memcached server to store this information. This is your best option if it doesn't change or changes infrequently.

like image 115
datasage Avatar answered Dec 12 '25 09:12

datasage