vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Nightly Database Optimizer (https://vborg.vbsupport.ru/showthread.php?t=67711)

Gamingforce 07-27-2004 10:00 PM

Nightly Database Optimizer
 
[ Feature Description ]
This is a simple, very easy to install hack that automatically optimizes your database daily! The optimizer uses MySQL's 'optimize table' function. In simple terms, you can look at the optimize command as a hard drive defragmenter. It reclaims lost space and defragments the database file.

By default, this modification runs the optimize script nightly at 3:22 AM (which statistically on my board is the least busiest time). You can run it weekly, monthly or whenever you want by changing the settings under the Scheduled Task Manager.

The script includes all the tables that get heavy daily activity. You can easily add other tables if you wish by opening up the dboptimize.php file and simply adding extra table names to the end of the list.

[ Version Fix Log ]
1.00 -> 1.01 - July 28, 2004
  • Added sleep code that adds a pause after each database process. (Thanks KirbyDE)
Enjoy! :)

Ghostsuit 07-28-2004 01:08 AM

I think a PHP script might ground to a halt on my database but nice hack.

Gamingforce 07-28-2004 04:01 AM

The optimization happens at off peak times and content is still accessible during the optimization process. I have a board with almost a million posts and it works fine.

Phalynx 07-28-2004 07:17 AM

usefull, thanks! *install*

Skyline_GT 07-28-2004 08:01 AM

so this is similer to the repair feature in vb?

SaN-DeeP 07-28-2004 08:06 AM

thnx for nice hack GamingForce.
but just a small query is this useful for small boards ?
lets say which have 50,000 - 60,000 posts ?

Regards,

sabret00the 07-28-2004 10:05 AM

how long have you been running it gaming force as i would fear that it would currupt some data one in a freak accident that would cos me :(

nexialys 07-28-2004 11:10 AM

to make the script to not stuck the server and the db process, inside the code, just after
PHP Code:

    $tempcount++; 

add this, so it will add a second of pause:
PHP Code:

for ($i=0$i 1000$i++) {
   
// do nothing, 1000 times



Andreas 07-28-2004 11:23 AM

Quote:

Originally Posted by nexialys
PHP Code:

    $tempcount++; 

add this, so it will add a second of pause:
PHP Code:

for ($i=0$i 1000$i++) {
   
// do nothing, 1000 times



Erm ... that causes unnecessary CPU load (if PHP isn't smart enough to just skip this).

Better use
PHP Code:

sleep(1); 

:)

nexialys 07-28-2004 11:49 AM

hum, ya, i forgot sleep()... thanks KirbyDE

Mickie D 07-28-2004 04:23 PM

thanks :)

installed and clicked

Gamingforce 07-28-2004 04:55 PM

1.00 -> 1.01 - July 28, 2004
  • Added sleep code that adds a pause after each database process. (Thanks KirbyDE)
To update, simply upload the new dboptimize.php script found in the zip attachment in the first post of this thread.

Gamingforce 07-28-2004 09:40 PM

Quote:

Originally Posted by SaN-DeeP
thnx for nice hack GamingForce.
but just a small query is this useful for small boards ?
lets say which have 50,000 - 60,000 posts ?

Regards,

It's useful regardless of the amount of posts your board has.

Zoints 07-28-2004 11:32 PM

What is the difference between this and the vbulletin repair/optize function that is built in (other than being automatic of course).

Thanks.

Zachery 07-28-2004 11:55 PM

Quote:

Originally Posted by thegunowner149
What is the difference between this and the vbulletin repair/optize function that is built in (other than being automatic of course).

Thanks.

I dont think there is one, at least not that i can tell.

Highlander 07-29-2004 02:23 AM

its automatic thats different and it uses the sleep command :D

Erwin 07-29-2004 03:24 PM

I'm not too sure of running an optimize table function automatically like this. :) There is a small but real risk of database corruption. Make sure you run a backup script daily as well if you're going to do this before optimizing your tables (something you should always do anyway).

Gamingforce 07-29-2004 06:49 PM

I've never heard of database corruption through the optimize function?

Erwin 07-29-2004 07:03 PM

Quote:

Originally Posted by Gamingforce
I've never heard of database corruption through the optimize function?

Neither have I - in fact, OPTIMIZE TABLE has REPAIR built-in, so if a table is corrupted this will repair it as well. However, unless you are going to switch off your forums, running OPTIMIZE on a live database runs a small risk of something wrong happening. That's all I'm saying. :)

tcs 07-30-2004 01:30 AM

Erwin is correct. The hack is good and I will run it knowing the dangers. Wouldn't take much to add a repair to it before optimize.

Gamingforce 07-30-2004 04:12 AM

Okay I did a fun stress test earlier today running the Optimize command for 20,000 times on the heavily accessed/updated USER table with 200+ concurrent users on my board and no problems at all. :)

TCS: Repair is built into Optimize. No need to run both. :)

pixelpunk 07-31-2004 11:19 PM

what would it take for this script to turn the board off between time A and time B and possibly give the admin the choice to run it on certain days?

It'd be much like eBay (among other sites) closing for maintainence.

TheComputerGuy 08-01-2004 12:47 AM

Installed...but pixelpunk has a great idea!

Gamingforce 08-01-2004 01:27 AM

There is no need to close the board. It's just downtime for your users. vBulletin's CRON system doesn't allow you to select more than one day a week, but I can work around that by having the script run daily, but instead run the code within it only on certain days. I'll look into that.

TheComputerGuy 08-01-2004 01:29 AM

Quote:

Originally Posted by Gamingforce
There is no need to close the board. It's just downtime for your users.

True, I just thought since it would be a dead time on the board anyways...it would no matter

Gamingforce 08-01-2004 01:30 AM

If it's a dead time, then why close it?

TheComputerGuy 08-01-2004 02:53 AM

Quote:

Originally Posted by Gamingforce
If it's a dead time, then why close it?

exactly. great point sir!

pixelpunk 08-03-2004 08:07 AM

Statistics can't predict exactly when someone will post during your boards 'dead time.'

There is still that risk of the database becoming corrupt because someone's inserting data into it while it's optimizing so why not kill it 100% just to be safe.

Still a kickin-rad hack though! Thanks GamingForce.

Ghostsuit 08-03-2004 02:24 PM

Quote:

Originally Posted by Gamingforce
The optimization happens at off peak times and content is still accessible during the optimization process. I have a board with almost a million posts and it works fine.


Ahh cool sounds good then :)

Gamingforce 08-03-2004 09:37 PM

Quote:

Originally Posted by pixelpunk
Statistics can't predict exactly when someone will post during your boards 'dead time.'

There is still that risk of the database becoming corrupt because someone's inserting data into it while it's optimizing so why not kill it 100% just to be safe.

Still a kickin-rad hack though! Thanks GamingForce.

I really do think it's 100% safe because MySQL locks the table from updates/inserts while it's optimizing it.

nintendo 08-03-2004 10:16 PM

Today I wad doing an optimizing/repair from admincp. I had to do it about five or six times since it never repairs completly in one run, and that crashed the database!!! I had to go into phpMYAdmin and repair the user table to get the boards back-up. It was the first time the database had ever crashed while doing a repair/optimizing. It might be the php version. Yesterday I had a Pro upgrade me from the buggy 4.2.2 version to 4.3.3.

Sadie Frost 08-03-2004 10:27 PM

Just a quick question - I installed this and ran it, and I got no message just a white screen and my broswer window said "Done". Just making sure it wasn't supposed to give a message when it's done? (Want to make sure it's actually working.) Thanks! :D

PS I ran the file manually because I wanted to close the board while I did it. :)

manguish 08-12-2004 04:10 PM

Hmm. Nice idea, but i get this :

Warning: main(./includes/dboptimize.php): failed to open stream: No such file or directory in /home/minimoto/public_html/vb/admincp/cronadmin.php on line 56

Fatal error: main(): Failed opening required './includes/dboptimize.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/minimoto/public_html/vb/admincp/cronadmin.php on line 56

Any ideas?

manguish 08-12-2004 04:13 PM

Edit : Scrap that found the mistake :

In your install.txt file you have :


5) Change Filename to: ./includes/dboptimize.php

It should be :

5) Change Filename to: ./includes/CRON/dboptimize.php

;)

venomx 09-10-2004 06:55 AM

5) Change Filename to: ./includes/dboptimize.php

should be ./includes/cron/dboptimize.php

Megareus Rex 09-10-2004 09:23 AM

Thanks for this hack :)

*installs*

Loki12 10-24-2004 03:57 PM

Quote:

Originally Posted by thegunowner149
What is the difference between this and the vbulletin repair/optize function that is built in (other than being automatic of course).

Thanks.

I would like to know the answer to this question too, please. :)

Zachery said there was none built in, but I think thegunowner149 referred to this:

wirewolf 11-03-2004 11:26 AM

Be carefull running Optimize every day. It's really not needed, but once a week or even once a month. It depends on your boards' traffic.
I see your running the query "OPTIMIZE TABLE" . From the MySQL site:
Quote:

"OPTIMIZE TABLE" should be used if you have deleted a large part of a table or if you have made many changes to a table with variable-length rows (tables that have VARCHAR, BLOB, or TEXT columns). Deleted records are maintained in a linked list and subsequent INSERT operations reuse old record positions. You can use OPTIMIZE TABLE to reclaim the unused space and to defragment the data file.

In most setups, you need not run OPTIMIZE TABLE at all. Even if you do a lot of updates to variable-length rows, it's not likely that you need to do this more than once a week or month and only on certain tables.

OPTIMIZE TABLE works as follows:
* If the table has deleted or split rows, repair the table.
* If the index pages are not sorted, sort them.
* If the statistics are not up to date (and the repair couldn't be done by sorting the index), update them.

Note that MySQL locks the table during the time OPTIMIZE TABLE is running.
Click here to read the rest from MySQL 14.5.2.5 OPTIMIZE TABLE Syntax
You may want to set the query to run once a week, or month, by adding the info in to the Scheduled Tasks manager and change the wording from "Daily" to "Weekly" or "Monthly" Database Optimization.
Also, look at your tables over a few days, and you will see the ones that consistantly need optimizing. You'll find that not all of the tables need constant optimizing.
The ones that Gamingforce has on the list of ############ TABLES TO OPTIMIZE ################ are about the most common ones, but you can add and/or delete tables on the list according to your own database usage.
You could also split up the optimizing in to two cron tasks. One for daily (most used tables), and one for weekly/monthly, etc.
John

Loki12 11-07-2004 10:58 AM

Quote:

Originally Posted by Loki12

Quote:

Originally Posted by thegunowner149
What is the difference between this and the vbulletin repair/optize function that is built in (other than being automatic of course).

Thanks.

I would like to know the answer to this question too, please. :)

Zachery said there was none built in, but I think thegunowner149 referred to this:

Is anyone going to answer this question? Is this hack still supported?

neocorteqz 11-07-2004 10:59 PM

Quote:

Originally Posted by Loki12
Is anyone going to answer this question? Is this hack still supported?

no real difference as far as i can see, this just allows for you to do it automatically via vBull's cron scheduler.


All times are GMT. The time now is 04:43 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01472 seconds
  • Memory Usage 1,828KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_php_printable
  • (13)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete