user1642018
user1642018

Reputation:

Which is better for storing Meta-description of categories , php var or mysql db

i am working on image site where, images belongs to the specific categories,

there are 70+ category types/name (i.e. books,trees,people,watches,cars,mobiles etc) as of now and will be near about 80-90 categories in near future , and each category has meta description, meta keywords , title specific to that category.

my question is where should i store this data ?

  1. in php using 3-4 types of array and then using array lookup to find and show the meta data specific to that directory ?

e.g.

$meta_description = array('books' => 'books meta description', 'trees' => 'trees meta description')

and then doing

if(isset($meta_description[$_GET['category']])){
echo $meta_description[$_GET['category']]);
}

  1. in MySQL db table and then doing mysql query on each page load for getting meta description, title data from db ?

e.g.

table

+------------+--------------+------+-----+---------+----------------+
| Field      | Type         | Null | Key | Default | Extra          |
+------------+--------------+------+-----+---------+----------------+
| cat_name   | varchar(50)  | NO   | MUL |         |                |
| title      | varchar(100) | NO   |     | NULL    |                |
| metakw     | varchar(100) | NO   |     | NULL    |                |
| metadesc   | varchar(100) | NO   |     | NULL    |                |
| record_num | tinyint(2)   | NO   | PRI | NULL    | auto_increment |
+------------+--------------+------+-----+---------+----------------+

and then getting info using mysql query on each page load.

i am looking for high performance as there are 20+ million records in the main table and there are already lots of mysql queries are fired every second, so i am lloking to lower the mysql burden .

Upvotes: 1

Views: 234

Answers (1)

Michal Wilkowski
Michal Wilkowski

Reputation: 747

Good practice is to keep as much cached as possible, therefore no. 1 is much better choice (as long as categories do not have to be configurable by user). However if you need to make it configurable then you should keep in the database and cache it using i.e. memcached http://www.memcached.org/

Upvotes: 1

Related Questions