views:

38

answers:

2

We have a table in mysql of 18GB which has a column "html_view" which stores HTML source data, which we are displaying on the page, but now its taking too much time to fetch html data from "html_view" column, which making the page load slow.

We want an approach which can simplify our existing structure to load the html data faster from db or from any other way.

One idea which we are planning is to store HTML data in .txt files and in db we'll just store path of the txt file and will fetch the data from that particular file by reading file. But we fear that it will make extensive read write operations n our server and may slowdown the server then.

Is there any better approach, for making this situation faster?

+1  A: 

First of all, why store HTML in database? Why not render it on demand?

For big text tables, you could store compressed text in a byte array, or compressed and encoded in base64 as plain text.

When you have an array with large text column, how many other columns does the table have? If it's not too many, you could partition the table and create a two column key-value store. That should be faster and simpler than reading files from disk.

Konrad Garus
Our old structure is based on storing HTML in database so its not possible to change it so early, so we are planning to make some less changes which can improve the performance for now. Out of "store compressed text in a byte array", or "compressed and encoded in base64 as plain text" which one will be faster and how to implement that, could you please share any PHP example?
Prashant
I don't know PHP, but this may help: http://php.net/manual/en/ref.zip.php. Byte array will be simpler, smaller and faster than base64.
Konrad Garus
+1  A: 

Have a look at the Apache Caching guide.
It explains disk and memory caching - from my pov if the content is static (as the databae table indicates), you should use Apaches capabilities instead of writing your own slower mechanisms because you add multiple layers on top.
The usual measure instead of estimating does still apply though ;-).

weismat