Jump to content

Reading a menu from database or file?


etrader

Recommended Posts

Where is the best to store the list of categories and menu? Obviously it is better to reduce mysql queries. From a plain list in file, we can create desirable list (menu) from an array. This is quite faster (though SELECT from an indexed table is fast too; but I do know if it is as fast as reading from a php file). Any idea how to code this to create the menu faster ?

Link to comment
Share on other sites

What is important is not which is faster, but what are the requirements for menus.  Is it a requirement that a user should be able to go into an admin system and add/change/delete menus?  If so, then you are better off storing them in a database.  You can then cache the results in a variety of ways.  Changing the menu would need to invalidate the cache.  Even without caching, if your database server had plenty of memory and your database contents could be kept in the database cache, it would always be extremely fast.

 

However, if you rarely change the menu, or the menu will be changed only by developers, then you are better off with a code based menu.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.