2

Yes I am talking about manually indexing drupal cache table.

Is it helpful to improve site performance by indexing cache table?

For ex::

SELECT cid, data, created, expire, serialized, tags, checksum FROM cache_default WHERE cid IN ( 'locale:en::anonymous' ) ORDER BY cid;

2 Answers 2

6

The cache_default table already has an index by CID (as well as indexes by creation and expiry date that allow old entries to be discarded).

Since almost all queries to the table are by CID there's not really any need for other indexes and it's not clear what benefit you would hope to see.

Adding extra indexes to tables does not result in cost-free performance enhancement. Every additional index makes write operations to the table more expensive, so you should not add any new index to a table until you have clear evidence of slow queries resulting from its absence.

0

Obviously id you add an index of a correct way to some specific fields/tables you can improve your performance. Sometimes is mandatory if you have thousands (or maybe millions) of rows.

Depends of the table you can add it using Drupal tools (and you should). I do not recommend add it manually in the database because if you manage more than one environment (that it's usual) you have to do it everywhere. To make a quick test you can add it directly in MySQL (for example using Workbenck) and test the queries using the EXPLAIN MySQL query tool (and obviously compare the performance results). After that, you can create the code to create the index programmatically using the Drupal Apis.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.