PDA

View Full Version : [Improvement] vBStats -> Member Referrer list PHP-code improvement (much less queries


KuraFire
13 Jan 2003, 20:30
HACK: [Improvement] vBStats -> Member Referrer list PHP-code improvement (much less queries)
BY: KuraFire [www.kurafire.com]
DESCRIPTION: Instead of using 1 query for every member that has referred someone to your forum, this new code will use only 2 queries for it all, allowing you to set your Referrermax variable in the vB stats as high as you want, you'll not get 150 queries if you have 150 referring members or anything, anymore :)
DIFFICULTY: Easiest :D
INSTALL-TIME: 1 minute I'd say :)


extended description:
What the default vBStats Member referrer list bit does, is loop through all users who have referred a member to your board, and for each user it runs an additional query to select all the usernames of that user's referrerlist.

My code improvement eliminates that and simply uses 1 query for all the users in the left column (referrers), 1 query for all the users in the right column (referrals) and some PHP intelligence to get the same result. No more query-per-user. 2 queries are all that remains, and a bit of PHP looping (not much).

Now you can display your entire list without having to fear for the page needing God knows how many queries in total :)
(it had 52 queries on first guest view in the old default way when I'd not limit the amount of users it'd display, it has 12 now... :))


Instructions are in the attachment :)


Enjoy, vBStats users :)


Disclaimer: I spoke with Bane about this a long time ago and he was happy I was improving his code cos he didn't have the time for it. I doubt he'd mind me releasing it now that I've gotten around to doing it, but if he does, I'll take it down... :)

Floris
13 Jan 2003, 20:41
Nice work, implemented it on my site and page loads faster, less less less queries and works with 2.2.9 :)

KuraFire
13 Jan 2003, 20:43
This works on any board where vBStats works :)

as long as you haven't brutally raped your vbstats.php code anyway ;)

KuraFire
14 Jan 2003, 09:12
funny, so many people have vBStats yet hardly anyone has noticed this..

*goes post a notice in the vbstats thread* ^_^

Dean C
14 Jan 2003, 16:42
Nice mod :)

Did you ask bane for permission ;)

- miSt

Natch
15 Jan 2003, 00:38
Great work - no-one should really be fretting if their work is improved upon IMO ...

:D

KuraFire
15 Jan 2003, 01:22
Mist: pah! ;p

Natch: I agree ^_^

Dean C
15 Jan 2003, 16:39
Yes well i can't see why he would mind it's just always nice to ask these things to the respective creator :)

- miSt

Bane
17 Jan 2003, 03:51
Well done Kura :) Should I get a chance to upgrade vbstats I will with your permission use this code. =) Very well done.

KuraFire
17 Jan 2003, 09:28
Yay, Bane's approval ^_^
;)


Feel free to use this code in your new vBStats if you end up making that. I'm working on an alternative for vBStats, a stats system that doesn't do as much queries before a page even starts (like vBStats) and has a bunch of other features and is more flexible... (and, no offense, some cleaner code...)
oh, and my point was, I'll be using my own code in that new Stats hack for the referrerlist (though we will be using a different template-style for the display)

:)

Dean C
17 Jan 2003, 16:21
Wow Bane's here! :)

Welcome back buddy

- miSt

Boofo
17 Jan 2003, 17:02
Originally posted by KuraFire

Feel free to use this code in your new vBStats if you end up making that. I'm working on an alternative for vBStats, a stats system that doesn't do as much queries before a page even starts (like vBStats) and has a bunch of other features and is more flexible... (and, no offense, some cleaner code...)
oh, and my point was, I'll be using my own code in that new Stats hack for the referrerlist (though we will be using a different template-style for the display)

:)

If you need any testers, let me know. ;)

Bane
17 Jan 2003, 22:52
flexible?

KuraFire
18 Jan 2003, 00:06
will do ^_^

though it'll probably just go in the Beta hack forum :)

KuraFire
18 Jan 2003, 00:09
Originally posted by Bane
flexible?


yeah, more control on what all is seen and more power on who can see what, and easier to adjust the look of, mostly :)

and also flexible like more modular, i.e. ability to add parts/new features at a later point :)

Martin64
18 Jan 2003, 01:56
Nice job, I'll install this. :)

thebigboss
21 Jan 2003, 22:18
Kura,

at phpportals, we have a Top10 module, which pulls things like top links, top files, top threads, top posters, etc. It also pulls top referrers.

with your permission, I'd like to change the code of the top refererrers to use yours, so as to dramatically reduce the queries.

regards
scotsmist (dev @ phpportals)

KuraFire
23 Jan 2003, 09:54
thebigboss: sure, go right ahead. I'd really appreciate it if you'd give me credit for it somewhere visible, though :)
(*hinthint* ;))

But feel free to use it :)

thebigboss
23 Jan 2003, 11:26
kura, thanks.

I've put your name at the top of the script, but to put it in the html output may, not appeal to most, as its in a nice table.

see here - http://www.phpportals.com/modules.php?s=&name=Top

o course, the Top 10 Refererrers only shows if Refererrers are active in vbulletin admin.

I'll also add to the credits page http://dev.phpportals.com/modules.php?s=&name=Credits , so it will be in the next release of vbportal. I'll do that as soon as I get a spare 5 :)

regards
scotsmist

KuraFire
23 Jan 2003, 13:52
Great, thx :)

's fine like this, thank you & you're welcome ^_~

Chris M
24 Jan 2003, 20:00
Nice...I will be installing this improvement on my next site update:)

Satan

KuraFire
06 Feb 2003, 14:43
btw, Bane, maybe it's a good idea to link to this from the vBStats thread's initial post?

:up: hellsatan ^_^

(ps nice avatar ;))

KuraFire
13 Feb 2003, 10:04
I sent out an update, because I released another Improvement-to-vBStats hack:

http://www.vbulletin.org/forum/showthread.php?s=&threadid=48869

Enjoy ^_^

Bane
15 Feb 2003, 09:31
This has been fixed in the newest version of vbStats.