Log in

View Full Version : I Can't Believe the Difference in Speed


amykhar
03-16-2003, 02:22 AM
Google has finally started crawling my board and guest traffic has started to increase. Things started to get rather sluggish. I upgraded my hosting plan to get more RAM and it helped somewhat, but not dramatically.

Then, I put an index on the dateline column in the posts table. OMG I can't believe the difference. Parts of the VBstats hack used to drive server load way up before. Now, I can actually use it without a wimper from the server. I can also use the hack that shows how many posts were made since the last visit now. Before, it just wasn't feasible.

My board isn't huge, but a decent size. If your medium to large board is starting to struggle, you might want to try this. I didn't do it in the past because I kept seeing Freddie telling people that it wasn't necessary. But I am really seeing a huge improvement.

Amy

Freddie Bingham
03-16-2003, 03:47 AM
If I say anything I am only referencing a non hacked forum when I say we are happy with the indexes that we have.

Boofo
03-16-2003, 04:00 AM
Today at 10:22 PM amykhar said this in Post #1 (https://vborg.vbsupport.ru/showthread.php?postid=367149#post367149)
Google has finally started crawling my board and guest traffic has started to increase. Things started to get rather sluggish. I upgraded my hosting plan to get more RAM and it helped somewhat, but not dramatically.

Then, I put an index on the dateline column in the posts table. OMG I can't believe the difference. Parts of the VBstats hack used to drive server load way up before. Now, I can actually use it without a wimper from the server. I can also use the hack that shows how many posts were made since the last visit now. Before, it just wasn't feasible.

My board isn't huge, but a decent size. If your medium to large board is starting to struggle, you might want to try this. I didn't do it in the past because I kept seeing Freddie telling people that it wasn't necessary. But I am really seeing a huge improvement.

Amy

Will the only help with vbststs or will it also help if you are not running that? If so, what do we need to do to accomplish that?

Weasel
03-16-2003, 04:39 AM
What happens when two people post at the exact same second?

doesnt index make sure there are no duplicate values?

Dean C
03-16-2003, 08:40 AM
So you simple add an index to one column and it fixed all your problems :)?

How do we do this :D?

And your board is HUGEEE!! Do you make the ea games?

- miSt

N9ne
03-16-2003, 12:50 PM
Today at 10:40 AM Mist said this in Post #5 (https://vborg.vbsupport.ru/showthread.php?postid=367248#post367248)
So you simple add an index to one column and it fixed all your problems :)?

How do we do this :D?

And your board is HUGEEE!! Do you make the ea games?

- miSt

Amy's forum has nothing to do with EA Games or anything lol.

Amy, please share how you did this ;).

Dean C
03-16-2003, 01:04 PM
I'm getting confused with electronic arts's forums :)

- miSt

amykhar
03-16-2003, 01:33 PM
1. We don't make EA games. However, a teenager joined once who thought we did and ripped us a new one because "our" games suck. Once we explained who we were, we figured we would never see him again. However, he still comes back from time to time when he needs help or wants to chat :D

2. Back on topic. The query I used was:

ALTER TABLE `post` ADD INDEX(`dateline`);

3. It helps quite a bit with vbstats, but I am also seeing a general speed increase. I did notice that takes a wee bit longer to post - but that is to be expected. From what I have read an index makes an insert take longer but a select faster.

4. Freddie, sorry I misunderstood.

I honestly don't believe we are a "huge" board. I prune periodically and keep things a reasonable size.

Amy

RS25com
05-06-2003, 06:03 PM
Hm, I tried this and it does seem to be significantly faster. I simply used PhpMyAdmin and clicked the "Index" link next to the appropriate column. :D

I run a small-ish board - 2200 members, 7900 threads and 104000 posts - on an IIS box - for those who are interested.

Dean C
05-06-2003, 06:41 PM
How does it makes things faster?

- miSt

amykhar
05-06-2003, 07:04 PM
It makes queries to the post table faster because the index orders the posts. So, queries that look for posts since a given date are significantly sped up.

Boofo
05-06-2003, 07:27 PM
Today at 03:04 PM amykhar said this in Post #11 (https://vborg.vbsupport.ru/showthread.php?postid=392417#post392417)
It makes queries to the post table faster because the index orders the posts. So, queries that look for posts since a given date are significantly sped up.

Does it do it retroactively or just with posts made after adding the query?

Xenon
05-06-2003, 07:34 PM
an DB index is for all data in the table, not just for the new ones ;)

btw. to speed up the getnew post you can add also an index to thread.lastpost :)

it reduced the gen time on vb.org from .27 to .07 ;)

Erwin
05-07-2003, 02:24 AM
Good tips. :)

Boofo
05-07-2003, 05:04 AM
Any other places where an index might help speed things up?

Dolby
05-07-2003, 07:32 AM
Any drawbacks to doing this? Can it be un-done?

Xenon
05-07-2003, 08:28 AM
@boofo: currently i don't know any others, but i'm sure there can be some.
but it's also depending on your hacks and so on, where you could need an index :)

@Dolby: well each index requires DB Space
you can see on the tablestatistics how much space the data takes and how much the indexes take.
yes it can be un-done :)

Erwin
05-07-2003, 10:26 AM
FWIW, I added indexes to post.dateline, thread.lastpost as well as thread.lastposter - did speed things up at my site. :)

Boofo
05-07-2003, 10:34 AM
Today at 06:26 AM Erwin said this in Post #18 (https://vborg.vbsupport.ru/showthread.php?postid=392659#post392659)
FWIW, I added indexes to post.dateline, thread.lastpost as well as thread.lastposter - did speed things up at my site. :)

How much overhead does each index add to the db? Just curious. ;)

cinq
05-07-2003, 12:46 PM
Is there any downsides to doing this ?

Also what should i do to implement this ?
Basic instructions would be appreciated ( nooB here )

Xenon
05-07-2003, 12:59 PM
cinq, everything is exactly mentioned here, i posted the downsides 3 posts above.

cinq
05-07-2003, 01:14 PM
Dbspace ie. the database just gets bigger right ?
Will the increase be so substantial that it is something to worry about ?

So the command i use in phpmyadmin is run this query ?

ALTER TABLE `post` ADD INDEX(`dateline`);

Just wish to confirm and not do something wrong and foul up the board :)

Thanks

Dolby
05-07-2003, 06:20 PM
Since it can be un-done ( looks like you just go into phpmyadmin and click on the drop button where it lists the indexs) I tried it and vbstats show some increase in speed. I was at about "Page generated in .8xxx" and its now about "Page generated in .06xxx" on my forum index.

Currently have 112 online browseing.

okrogius
05-07-2003, 07:24 PM
Downsize to too much indexes is not just extra database space. While adding an index to thread.lastpost speeds up Get New Posts, it also slows down New Thread/Reply.

Dolby
05-07-2003, 09:14 PM
Hmmm seems just as fast if not faster on my busy board to make a new thread or reply. *shrug*

Erwin
05-08-2003, 09:46 AM
Downsize to too much indexes is not just extra database space. While adding an index to thread.lastpost speeds up Get New Posts, it also slows down New Thread/Reply.

As most of the database load is from guests browsing the forums, rather than posting, the trade-off is well worth it.

TTG
07-02-2004, 10:55 AM
I added the ALTER TABLE `post` ADD INDEX(`dateline`); and must admit my board seem to load a lot faster.

What are the codes to add for post.dateline, thread.lastpost as well as thread.lastposter

chris2707
07-02-2004, 02:09 PM
Can this be done with the board open and users using the vB?

Xenon
07-02-2004, 02:11 PM
yes :)

RichieBoy67
07-02-2004, 03:48 PM
Great Tip! Amazing speedup!!!

Thanks-- I just did this to both my sites and it is awesome and so dam simple...

Jolten
07-02-2004, 04:24 PM
Wow. Although I wasn't at all unhappy with the speed of my tiny little forum adding indexes to post.dateline, thread.lastpost, and thread.lastposter has made pages load exceptionally fast. Thanks for this Amy!

soopa
07-02-2004, 05:22 PM
good stuff :devious:

Gamingforce
07-03-2004, 01:07 AM
I just added an index to post.dateline and thread.lastpost. Speed seems a little faster and database insertions into the post/thread tables don't seem too bad. My board has 150-300 users, on average and has around 850,000 posts.

I would recommend this simple modification to anyone.

Velocd
07-03-2004, 03:17 AM
In addition to regularly optimizing your index tables, indexing can be a big help on columns when quering.

More information:
http://dev.mysql.com/doc/mysql/en/MySQL_indexes.html

Another good read on general database optimization:
http://dev.mysql.com/doc/mysql/en/Optimising_Database_Structure.html

Boofo
07-03-2004, 03:37 AM
In phpmyadmin, how can you tell if something already has an index for it?

Natch
07-03-2004, 04:19 AM
In the Structure layout, roll down the the bottom - there is an Index summary table below the main layout...

Boofo
07-03-2004, 04:49 AM
In the Structure layout, roll down the the bottom - there is an Index summary table below the main layout...
Thank you, sir. I needed to check if I had more then 1 index for a couple of these and I did. Now all is well. ;)

Oblivion Knight
07-03-2004, 01:28 PM
I added the ALTER TABLE `post` ADD INDEX(`dateline`); and must admit my board seem to load a lot faster.

What are the codes to add for post.dateline, thread.lastpost as well as thread.lastposterALTER TABLE `thread` ADD INDEX(`lastpost`);

ALTER TABLE `thread` ADD INDEX(`lastposter`);



Strangely, my forum seems to load faster, but the Microstats don't reflect this..

Viewing a thread before:
Page generated in 0.11889291 seconds (92.06% PHP - 7.94% MySQL) with 13 queries

Viewing a thread after:
Page generated in 0.50758195 seconds (96.13% PHP - 3.87% MySQL) with 13 queries

MickDoneDee
07-18-2004, 04:25 PM
I indexed the following as mentioned in the previous posts:

post.dateline
thread.lastpost
thread.lastposter

Adding indexes for thread.lastpost and thread.lastposter only increased the space usage by about 10,000 bytes.

I didn't notice a discernable difference in speed when loading the index page or forumdisplay page.

I turned the debug mode on in the config.php file so that the controls appeared at the bottom of the forum pages. Then I clicked (Explain) which loaded http://www.myforum.com/?explain=1

This detailed all the Queries that were run. I checked through this for the index page and forumdisplay page. I couldn't find any reference to post.dateline, thread.lastpost or thread.lastposter. So page load speed for the index page or forumdisplay page can't be influenced by those three new indexes. Question is: which pages do load faster as a result of those three indexes?

If your config.php file doesn't already contain $debug, add it to the bottom of the file as I've shown here. To prevent other users from accessing it add your IP address where I've indicated. You can get your IP address from Who's Online if you are logged on.

// Prefix that all vBulletin cookies will have
// For example
$cookieprefix = 'bb';

// ****** DEBUG MODE ON/OFF ******
// Turn debug on with '1' otherwise leave it blank to disable it.
$debug = '1';

if ($_SERVER['REMOTE_ADDR'] == 'your IP address')
{
$debug = 1;
} else {
$debug = 0;
}

/*================================================= =====================*\
|| ################################################## ##################
|| # Downloaded: 19:34, Mon Apr 5th 2004
|| # CVS: $RCSfile: config.php.new,v $ - $Revision: 1.19 $
|| ################################################## ##################
\*================================================ ======================*/
?>

https://vborg.vbsupport.ru/external/2011/01/19.gif Another feature that is activated with debug on is the Admin Help Manager which appears in the vBulletin Options menu within the Admin CP.

MickDoneDee
07-18-2004, 05:11 PM
To add an index in your phpmyadmin the attached images will help to explain it.

Load the page which displays all the tables. See part of this page in PhpMyAdmin 2001.jpg

Notice that each table has a Properties column. Choose your table and click Properties in that row. See PhpMyAdmin 9001s.jpg for the Post table.

Notice that each property has an Index column. You can also see a table at the bottom which shows existing indexes. You don't want to create one if it already exists. Choose your property and click Index in that row.

See PhpMyAdmin 11001.jpg that shows a message to say the index has been added.

See PhpMyAdmin 12001.jpg that shows that the property "dateline" has been added to the list of indexes.

Hope this helps make sense of it all.

lange
01-28-2005, 01:32 AM
I added indexes to post.dateline, thread.lastpost and thread.lastposter.

ALTER TABLE `post` ADD INDEX(`dateline`);

ALTER TABLE `thread` ADD INDEX(`lastpost`);

ALTER TABLE `thread` ADD INDEX(`lastposter`);


How to un-done it in phpMyAdmin ?

Marco van Herwaarden
01-28-2005, 03:37 AM
ALTER TABLE `post` DROP INDEX(`dateline`);

ALTER TABLE `thread` DROP INDEX(`lastpost`);

ALTER TABLE `thread` DROP INDEX(`lastposter`);

BaconDelight
01-28-2005, 04:20 AM
Forgive this question from a clueless newbie, but phpmyadmin?

AN-net
01-28-2005, 10:23 AM
please don't bump old threads;)

noppid
01-28-2005, 12:23 PM
Forgive this question from a clueless newbie, but phpmyadmin?

phpmyadmin is a web based interface to manage mysql databases. It is included with most hosting packages and can be downloaded from sourceforge for installation on your own server too.

If you want to run queries in vB3, you can use the control panel if you turn on $canrunqueries for your userid in config.php.