Author |
Topic |
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 23 March 2002 : 23:17:28
|
Gremlin - your idea is good ... I was going to use the same idea for my UserGroup mod I'm working on ... delimited list of allowed forums based on the user ... but I just haven't gotten around to working on it. I thought I saw somewhere else in the code where this is done with a comma delimited list. Can't think right now where that is though.
If you are using GetRows, couldn't you just use VBScript's Join function to build the list?
Nikkol
Edited by - Nikkol on 23 March 2002 23:20:51 |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 23 March 2002 : 23:21:00
|
Why dont you use a two dimentional array to store moderator/forum relationships.
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 23 March 2002 : 23:26:03
|
quote:
Your above function looks good, but try to use the Snitz variable naming prefixes
str for string int for interger bol for boolian arr for array
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's
Each to their own I guess Nathan :) I just know I'm not personally going to subscribe to a topic based on its subject line alone, I want to read it first.
As for variable names, well umm, take a look there really isn't that much standarisation going on with most of them now (the prefixes you mention are actually long time Microsoft reccomendations for variable naming conventions), I've just for now used the variable names that matched the surrounding code I was editing.
I've actually personally removed all Admin type links from my pages without any complaints so far from people. To view them I just add an Admin=1 to the querystring of each page, I found i very rarely need them showing except when I was setting up the boards and occasionally again when I was doing a little bit of admin. I'd rather trim 0.01 of a second off the execution time than have them clutter my page up again each to their own !
quote: I thought I saw somewhere else in the code where this is done with a comma delimited list. Can't think right now where that is though
You might have been thinking of the bad words function Nikkol, also the Poll Mod uses something like this and then uses split(string) to get the fields out again, think it uses it for keeping track of polls members have voted on.
www.daoc-halo.com
Edited by - Gremlin on 24 March 2002 09:14:57 |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 23 March 2002 : 23:29:08
|
Let me clean up that query a bit.
SELECT FORUM_FORUM.F_SUBJECT, FORUM_FORUM.F_SUBSCRIPTION, FORUM_FORUM.F_STATUS, FORUM_FORUM.F_ORDER, FORUM_CATEGORY.CAT_STATUS, FORUM_CATEGORY.CAT_SUBSCRIPTION, FORUM_CATEGORY.CAT_ORDER, FORUM_TOPICS.T_SUBJECT, FORUM_TOPICS.T_VIEW_COUNT, FORUM_TOPICS.FORUM_ID, FORUM_TOPICS.T_STATUS, FORUM_TOPICS.TOPIC_ID, FORUM_TOPICS.T_ISPOLL, FORUM_TOPICS.CAT_ID, FORUM_TOPICS.T_REPLIES, FORUM_TOPICS.T_AUTHOR, FORUM_MEMBERS.M_NAME, FORUM_TOPICS.T_LAST_POST, FORUM_TOPICS.T_LAST_POST_AUTHOR, FORUM_SUBSCRIPTIONS.MEMBER_ID FROM ( FORUM_CATEGORY INNER JOIN ( FORUM_FORUM INNER JOIN ( FORUM_MEMBERS INNER JOIN FORUM_TOPICS ON FORUM_MEMBERS.MEMBER_ID = FORUM_TOPICS.T_AUTHOR ) ON ( FORUM_FORUM.FORUM_ID = FORUM_TOPICS.FORUM_ID ) AND ( FORUM_FORUM.CAT_ID = FORUM_TOPICS.CAT_ID ) ) ON ( FORUM_TOPICS.CAT_ID = FORUM_CATEGORY.CAT_ID ) AND ( FORUM_CATEGORY.CAT_ID = FORUM_FORUM.CAT_ID ) ) LEFT JOIN FORUM_SUBSCRIPTIONS ON FORUM_MEMBERS.MEMBER_ID = FORUM_SUBSCRIPTIONS.MEMBER_ID ORDER BY FORUM_CATEGORY.CAT_ORDER, FORUM_FORUM.F_ORDER, FORUM_TOPICS.T_LAST_POST DESC
WOW! Any way to simplify that into this = this or that = that
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 24 March 2002 : 00:57:15
|
chkForumModerator could also be changed to setup a list of valid Moderation Forums for the user once per page as I've done with IsAllowedMember above, on some pages this again is saving a large number of DB calls.
EDIT: Add chkForumAccess to that list also. (still working on that one) Once I have active.asp will be down to only about 8 Database calls to show the last months worth of Active Topics ... changes have also had a nice side effect on search.asp too, its doesn't time out on full searchs any longer (well so far - limited testing only)
www.daoc-halo.com
Edited by - Gremlin on 24 March 2002 01:53:50 |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 24 March 2002 : 01:57:32
|
Gremlin, wouldn't an easy way to executet this just to put the if structure in the old function that is called so many times?
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 24 March 2002 : 01:59:04
|
quote:
added the following into inc_top.asp to builded a pipe delimited sting of all forums the user has access too e.g |23|34|35|45|
Don't put in inc_top, put it in the top of the files that need it.
If its put in inc_top.asp then it's going to add overhead to files that don't need it.
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 24 March 2002 : 02:02:27
|
quote:
Why dont you use a two dimentional array to store moderator/forum relationships.
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's
You probably could actually build a large multi-dimensional Array of all the info your going to need just once in inc_top.asp (possibly even persist it using Session/Cookies)
So far The really heavy functions that are causing the multitude of DB calls that I've located are
chkForumAccess chkForumModerator isAllowedMember
In most cases, for every Topic thats displayed on the screen in either active.asp or search.asp or forum.asp these Functions are being called at least once, in some instances 3 or 4 times. A couple of those functions have 2 separate DB calls in them also.
This is resulting in somewhere around 10-20 unrequired calls out to our database every time a topic is displayed.
www.daoc-halo.com |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 24 March 2002 : 02:07:57
|
Add these two to the list
CheckForUnModeratedPosts <edit> oopsi, forgot this one needs taken care of another way, see my first reply </> CheckSubscription
It wont be needed in all files, so theres no point in doing it in all files. Add the function to inc_functions and only call it at the top of files that need it.
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's
Edited by - Nathan on 24 March 2002 02:11:53 |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 24 March 2002 : 02:14:24
|
quote:
Don't put in inc_top, put it in the top of the files that need it.
Theres not that many pages that I can find that don't call one of the above listed functions already.
quote:
Gremlin, wouldn't an easy way to executet this just to put the if structure in the old function that is called so many times?
hmmm might have been, remember I'm just playing right now to see what can be done, I'm not neccesarily going about it the 'cleanest' or 'purest' way I'm in "Proof of Concept" mode right now.
However, the way I've done it is to remove all of the unrequired calls to those functions by doing it once only in inc_top.asp (which isn't a huge overhead when you consider the 1100 odd calls its just saved from the database in Grazman's example that started this off)
I've then changed the line where the function was previously being called i.e chkForumModerator(Forum_ID, Session(strCookieURL & "username"))= "1" to just a simple If CanModerate = 1 where CanModerate is setup at the top of that page using the CanModerate = instr(AllowForumList,("|" & fForum_ID & "|",) structure.
I've refined things a little from my first post as I've gone though so its getting more streamlined. My post was really just a starter for Devs to start looking at a better way of doing these things (if they haven't already fixed them in 3.4 anyway).
www.daoc-halo.com |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 24 March 2002 : 02:15:38
|
quote:
Add these two to the list
CheckForUnModeratedPosts <edit> oopsi, forgot this one needs taken care of another way, see my first reply </> CheckSubscription
It wont be needed in all files, so theres no point in doing it in all files. Add the function to inc_functions and only call it at the top of files that need it.
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's
Edited by - Nathan on 24 March 2002 02:11:53
Someone else might want to look at them, the 3.3 Version I work with has had all subscriptions and moderation code removed already.
www.daoc-halo.com |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 24 March 2002 : 04:16:46
|
I think this may be able to be cleaned up (saves 1 call per topic to DB for Admins when browsing the boards anyway .. I think heh)
function chkForumAccess(fForum, UserNum) chkForumAccess = false strSql = "SELECT " & strMemberTablePrefix & "MEMBERS.M_LEVEL " strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS " strSql = strSql & " WHERE " & strMemberTablePrefix & "MEMBERS.MEMBER_ID=" & UserNum
Set rsCheck = Server.CreateObject("ADODB.Recordset") rsCheck.open strSql, my_Conn
if rsCheck.BOF or rsCheck.EOF then chkForumAccess = false elseif rsCheck("M_LEVEL") = 3 then chkForumAccess = true rsCheck.close set rsCheck = nothing exit function end if rsCheck.close
This first bit of the Function I think could be changed too
if (mlev = 4) then chkForumAccess = true exit function end if
mLev should always be set already in inc_top.asp to either 0,1,2,3 or 4 so I dont think the function needs to retrieve the level again. The only time this would not be true is in a page that uses inc_top_short.asp. The only pages I can locate that use inc_short are most of the pop_xxxx.asp pages and none of them call this particular function anyway.
www.daoc-halo.com
Edited by - Gremlin on 24 March 2002 04:21:02 |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 24 March 2002 : 04:51:52
|
Ummm. . . . thats not true.
mLev is not set in inc_top_short.asp
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 24 March 2002 : 05:15:56
|
Umm thats exactly what I said Nathan
quote: The only time this would not be true is in a page that uses inc_top_short.asp. The only pages I can locate that use inc_short are most of the pop_xxxx.asp pages and none of them call this particular function anyway.
www.daoc-halo.com |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 24 March 2002 : 08:26:44
|
If your not using Topic Moderation then make sure you switch it off in the Admin Options. This alone reduces the number of queries by around 30%.
Perhaps Allow Topic Moderation could be set to defauly to "off" on a clean install.
After all of the above changes I've noted have been made, I've gone from 1234 DB Calls to get the Last Months Active topics, taking 20 seconds to execute to 10 Calls taking 0.5 seconds Now thats what I call a nice little performance increase
A secondary, but rather nice side effect of these changes has also been the improvement in search.asp.
A standard single keyword search over my forums took 30 seconds and 5725 DB calls before the changes, the same search is now taking 10 seconds and 2103 DB calls.
www.daoc-halo.com
Edited by - Gremlin on 24 March 2002 08:34:30 |
|
|
Topic |
|