caching table

  • Filter
  • Time
  • Show
Clear All
new posts

  • caching table


    In my page, I have multiple queries to fetch data from same table with different scenarios. These multiple queries give me performance issues. So I am trying to cache the table and then query that with different scenarios and in this way I don't need to hit the database all the time.

    But, I don't know how to cache the table and query from it.

    Can anyone help?

    Is there any other way to improve the performance?

  • #2

    What type of storage engine have you chosen for those tables? Depending storage engine you can have multiple options to try and improve your performance.

    Kind regards,



    • georgenight
      georgenight commented
      Editing a comment
      storage engine is InnoDB

  • #3

    If you are using InnoDB and if table is small enough to fit in the memory/buffer pool then whenever you select, the table data will be stored in buffer only. So If InnoDB buffer pool set big enough then frequently used tables will be always resides in buffer pool and no need to read from disk every time which will be improve the performance. But there is nothing you can do to force this table to stay in memory if there are other actively used tables and there is not enough RAM space to keep them all.

    You can get more information here http://www.mysqlperformanceblog.com/...b-buffer-pool/

    In case of MyISAM tables , it's different. There is no cache in MySQL for data, only indexes can be cached in MyISAM. and OS filecache is used for caching MyISAM tables. so if you have large myisam tables and you read them - they will be cached in filesystem cache for further speeding the reads. Caching for MyISAM is less intelligent, whole tables only if they fit in memory.

    There are also couple of more options for caching like Query Cache and Memcached. Query cache is very simple but only efficient solution if you have exactly the same query repeating many times, and you don't change your data too often. You can get more information here.