What must i use within this situation (Apache + PHP)? Database or simply a TXT file? My priority #1 is speed.


  • Adding new products
  • Reading through products
  • Max. 1 000 records


Database (MySQL)

| Name     | Age |
| Joshua   | 32  |
| Thomas   | 21  |
| James    | 34  |
| Daniel   | 12  |

TXT file

Joshua 32
Thomas 21
James 34
Daniel 12

For speed and enhanced memory usage, I'd say opt for a database hands lower. Putting a catalog around the title column alone will most likely boost performance in ways never achievable having a text file.

A database has additionally other advantages like some sanitation (no breaking of delimiters, newlines etc.) and fewer danger of access conflicts when multiple instances attempt to read in the table - and various from the file-based approach, writing conflicts are restricted towards the record under consideration only.

Perhaps you have investigated other DHTs?

Project Voldemort

Memcached + MySQL

Update 1

Without having memcached and Voldemort in your servers, then apply for embedded key-value databases like BDB

The suggested text file is essentially a database. Writing the procedures you to ultimately manipulate it is only reinventing the wheel, so only use something which already is available. 1,000 records is quite small-scale so using something simple like SQLite could be fine.

Utilizing a database could be more efficient. You'll have the ability to query and do procedures to choose data a lot more easily than if it's inside a text file. The written text file would need to be constantly opened up, closed and also the contents skyrocketed to attain to iterate data or find rows - this is slow along with a discomfort to code.

You will find classes and prepared made scripts available which may permit you to store such data in text files but in the finish during the day this is exactly what databases specified for for so I'd play one.

With no more than 1000 records that contains only title and age posts, I doubt there's any factor in speed involving the options likely additional factors like server load will dominate your speed.

For simple, reliable access, MySQL may be a little simpler, however with a text file it's not necessary to setup a MySQL server.

I recieve the sensation we do not have sufficient information to provide you with an informed answer.

As some have stated above, you will find options for this problem. The energy from the database might be helpful (in the end, you won't want to code individuals features yourself when you may be doing another thing) but you won't want to go overkill.

SQLite might be worth searching at as possible treated like a file (no server to bother with) but provides you with the energy of SQL querying.

You might try something similar to Memcached like a cache on the top of whatever data storage layer you select.

If speed is usually the only factor that's important, I would suggest using var_export to create a .php file that may be packed with PHP. As lengthy as the amount of reads-to-creates is sufficient and when APC is installed, the PHP file will have the ability to exploit the opcode cache of APC. This is way faster than Other things since the data is going to be loaded natively in as PHP rather than needing to undergo medium difficulty layer (memcache, mysql, etc).