PDA

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


KuraFire
01-12-2003, 10:00 PM
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
01-13-2003, 07:41 PM
Nice work, implemented it on my site and page loads faster, less less less queries and works with 2.2.9 :)

KuraFire
01-13-2003, 07:43 PM
This works on any board where vBStats works :)

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

KuraFire
01-14-2003, 08:12 AM
funny, so many people have vBStats yet hardly anyone has noticed this..

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

Dean C
01-14-2003, 03:42 PM
Nice mod :)

Did you ask bane for permission ;)

- miSt

Natch
01-14-2003, 11:38 PM
Great work - no-one should really be fretting if their work is improved upon IMO ...

:D

KuraFire
01-15-2003, 12:22 AM
Mist: pah! ;p

Natch: I agree ^_^

Dean C
01-15-2003, 03:39 PM
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
01-17-2003, 02:51 AM
Well done Kura :) Should I get a chance to upgrade vbstats I will with your permission use this code. =) Very well done.

KuraFire
01-17-2003, 08:28 AM
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
01-17-2003, 03:21 PM
Wow Bane's here! :)

Welcome back buddy

- miSt

Boofo
01-17-2003, 04:02 PM
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
01-17-2003, 09:52 PM
flexible?

KuraFire
01-17-2003, 11:06 PM
will do ^_^

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

KuraFire
01-17-2003, 11:09 PM
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
01-18-2003, 12:56 AM
Nice job, I'll install this. :)

thebigboss
01-21-2003, 09:18 PM
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
01-23-2003, 08:54 AM
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
01-23-2003, 10:26 AM
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
01-23-2003, 12:52 PM
Great, thx :)

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

Chris M
01-24-2003, 07:00 PM
Nice...I will be installing this improvement on my next site update:)

Satan

KuraFire
02-06-2003, 01:43 PM
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
02-13-2003, 09:04 AM
I sent out an update, because I released another Improvement-to-vBStats hack:

https://vborg.vbsupport.ru/showthread.php?s=&threadid=48869

Enjoy ^_^

Bane
02-15-2003, 08:31 AM
This has been fixed in the newest version of vbStats.