Reputation:
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 ?
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']]);
}
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
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