user1575780
user1575780

Reputation: 9

Use my mysql or text file to store data for fast access

I need to display country name of 100000 mobile numbers each second. so

  1. from mobile number i need to find the prefix
  2. from prefix, find the country name.

Method 1: (Mysq1) store prifix, country name in the database and access

Method 2: (Text file) Store country name in text file. example for Malaysia prefix is 60. so store "Malaysia" in a test file "60.test" to get country name use file_get_contents("country/60.txt")

which method will be fast?

Upvotes: 1

Views: 403

Answers (1)

Patrick Savalle
Patrick Savalle

Reputation: 4436

Assuming a 'normal' webserver, You have several options:

  1. Use a database. This will be fast and simple. For maximum speed use Memory-tables and if possible use persistent connection (not recommended under normal circumstances certainly not when using transactions)
  2. Use the filesystem, will work, but is not where it is designed for, maintainance of the dataset will be hell, won't be fast enough either
  3. Use memcache or something similar to cache a memory structure (associative array or so) across requests, initially loading it from either file or database.

I would go for option 1 unless the performance is not enough, then use option 3.

Upvotes: 1

Related Questions