Fast way to view data in PHP

I have a data table with 600,000 records about 25 megabytes in size. It is indexed using a 4-byte key.

Is there a way to quickly find a string in such a dataset with PHP without resorting to MySQL?

This website is mostly static with little PHP code and is database independent and therefore fast. I would like to add this data without using MySQL, if possible.

In C ++, I would make a memory card and do a binary search in it. Is there a way to do something like this in PHP?

+4
source share
3 answers

PHP (at least 5.3) should be optimized to use mmap, if available, and this is probably beneficial. Therefore, you can use the same strategy that you say you use with C ++:

EDIT: it actually seems to use mmap only in some other circumstances, such as file_get_contents . It doesn't matter, but you can also try file_get_contents .

+1
source

I would suggest memcachedb or something similar. If you intend to fully process this in PHP, the script will have to read the entire / datastruct file for each request. This cannot be done dynamically in a reasonable amount of time.

+1
source

In C ++, you would stop and run the application every time the user would like to view the file in a different way, so download and upload the file? Probably not, but that’s how php differs from application and application programming languages.

PHP has tools to help you deal with tearing / building up your environment. These tools are database and / or key caching utilities, such as memcache. Use the right tool for the right job.

+1
source

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


All Articles