Hi everyone 🙂
Okay... I've got a nice database setup. To speed up the pages in my site that use the DB I'm going to use some indexes.
The DB gets new data all the time, so the indexes have to be continuously recreated. To do this, I'll use a Cron Task to run a PHP script every so often. The PHP script will simply take a new DB dump and make a new index. I was planning on setting the Cron to run every night at midnight.
My questions are:
1) First of all, does all of the above sound OK? Is there a better method?
2) How long will the pages on my site be out of action when the Cron is running. (Assume I've got 5 tables, each with around 300 records, and the index uses all of them. Imagine a big meaty WHERE clause in SQL. Oh and yes, my Tables have been Normalised, so don't worry about my DB design!)
2) What would actually happen if you tried to use the pages when the Cron is running. Will you get a big nasty DB error? Or will the page automatically use the orginal DB tables, because it can't find an index (slower, but better than an error)?
3) I'd love to recreate the indexes more often than once per day. Once per hour would be much better. Obviously this is only possible if the Cron runs really fast. What do you think?
Thanks in advance for all your help ,
Ryan.