Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Bug Reports (Open)
 BUG (31sr4): search.asp performs unnecesary query
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 25 April 2001 :  14:20:37  Show Profile  Visit HuwR's Homepage
While doing some index studies on searching, I discovered this unnecesary behaviour.
After the search query is performed, the code iterates through the result set checking the cat and forum status for each result, now say for instance you search for test, and it returns 50 results, 40 of which are in the same forum, you guessed it, the query gets executed 40 times returning the same result each time.

Solution.

look for this section of code

rs.MoveFirst
currForum = 0
currTopic = 0
do until rs.EOF
if ChkForumAccess(rs("FORUM_ID")) then

'## Forum_SQL - Find out if the Category is Locked or Un-Locked and if it Exists
strSql = "SELECT " & strTablePrefix & "CATEGORY.CAT_STATUS "
strSql = strSql & ", " & strTablePrefix & "FORUM.F_STATUS "
strSql = strSql & " FROM " & strTablePrefix & "CATEGORY "
strSql = strSql & " , " & strTablePrefix & "FORUM "
strSql = strSql & " WHERE " & strTablePrefix & "CATEGORY.CAT_ID = " & strTablePrefix & "FORUM.CAT_ID "
strSql = strSql & " AND " & strTablePrefix & "FORUM.FORUM_ID = " & rs("FORUM_ID")

set rsCFStatus = my_Conn.Execute (StrSql)


and make the changes in red below


rs.MoveFirst
currForum = 0
currTopic = 0
dim cStatus
dim fStatus
dim lastForumID

lastForumID = 1


do until rs.EOF
if ChkForumAccess(rs("FORUM_ID")) then

'## Forum_SQL - Find out if the Category is Locked or Un-Locked and if it Exists
if lastForumID <> rs("FORUM_ID") then
strSql = "SELECT " & strTablePrefix & "CATEGORY.CAT_STATUS "
strSql = strSql & ", " & strTablePrefix & "FORUM.F_STATUS "
strSql = strSql & " FROM " & strTablePrefix & "CATEGORY "
strSql = strSql & " , " & strTablePrefix & "FORUM "
strSql = strSql & " WHERE " & strTablePrefix & "CATEGORY.CAT_ID = " & strTablePrefix & "FORUM.CAT_ID "
strSql = strSql & " AND " & strTablePrefix & "FORUM.FORUM_ID = " & rs("FORUM_ID")


set rsCFStatus = my_Conn.Execute (StrSql)
cStatus = rsCFStatus("CAT_STATUS")
fStatus = rsCFStatus("F_STATUS")
lastForumID = rs("FORUM_ID")
rsCFStatus.close
end if



OK, now you need to replace every occurence of
rsCFStatus("CAT_STATUS") except the ones above to cStatus
and all the rsCFStatus("F_STATUS") to fStatus





work mule
Senior Member

USA
1358 Posts

Posted - 25 April 2001 :  23:27:40  Show Profile
Good catch HuwR!

I'm wondering if active.asp and possibly bookmark.asp (if using that mod) may also be guilty of this? Briefly thinking about default.asp, I think it is probably okay. Hard to tell looking through all the modified code tho'.



Edited by - work mule on 25 April 2001 23:29:13
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 26 April 2001 :  01:28:30  Show Profile  Visit HuwR's Homepage
bookmark is ok, only uses one query

Go to Top of Page

work mule
Senior Member

USA
1358 Posts

Posted - 26 April 2001 :  05:22:29  Show Profile
Doh!! You're right. In practice, the only way a user can bookmark something is if they already have access to it anyways.

Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 24 December 2001 :  03:20:19  Show Profile
HuwR, this doesn't seem like it was implemented.
This sounds like it would gain some performance on the search.asp page, in light of our recent performance discussions.

- David
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 24 December 2001 :  04:21:31  Show Profile  Visit HuwR's Homepage
Good idea, maybe Spooky could test it for performance gain.

Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 24 December 2001 :  04:48:48  Show Profile
It's a little different now with the addition of Category/Forum Subscriptions.

Here is what it looks like after incorporating the changes:

			rs.MoveFirst
currForum = 0
currTopic = 0
dim Cat_Status
dim Cat_Subscription
dim Forum_Status
dim Forum_Subscription
dim lastForumID
lastForumID = 0

do until rs.EOF
if ChkForumAccess(rs("FORUM_ID"),getNewMemberNumber()) then
if lastForumID <> rs("FORUM_ID") then
'## Forum_SQL - Find out if the Category is Locked or Un-Locked and if it Exists
strSql = "SELECT C.CAT_STATUS, C.CAT_SUBSCRIPTION , F.F_SUBSCRIPTION, F.F_STATUS" & _
" FROM " & strTablePrefix & "CATEGORY C, " & strTablePrefix & "FORUM F" & _
" WHERE C.CAT_ID = F.CAT_ID" & _
" AND F.FORUM_ID = " & rs("FORUM_ID")

set rsCFStatus = my_Conn.Execute (StrSql)
Cat_Status = rsCFStatus("CAT_STATUS")
Cat_Subscription = rsCFStatus("CAT_SUBSCRIPTION")
Forum_Status = rsCFStatus("F_STATUS")
Forum_Subscription = rsCFStatus("F_SUBSCRIPTION")
lastForumID = rs("FORUM_ID")
rsCFStatus.close
set rsCFStatus = nothing
end if


Then in addition to changing all instances of
rsCFStatus("CAT_STATUS") to Cat_Status
&
rsCFStatus("F_STATUS") to Forum_Status

change all instances of
rsCFStatus("CAT_SUBSCRIPTION") to Cat_Subscription
&
rsCFStatus("F_SUBSCRIPTION") to Forum_Subscription
Go to Top of Page

James
Average Member

USA
539 Posts

Posted - 24 December 2001 :  16:54:07  Show Profile  Visit James's Homepage
quote:

Then in addition to changing all instances of
rsCFStatus("CAT_STATUS") to Cat_Status
&
rsCFStatus("F_STATUS") to Forum_Status

change all instances of
rsCFStatus("CAT_SUBSCRIPTION") to Cat_Subscription
&
rsCFStatus("F_SUBSCRIPTION") to Forum_Subscription



No other files need changing other than search.asp, correct?

-
*Interested in Radio Control*
*The RC Web Board - http://www.rcwebboard.com/*
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 29 December 2001 :  01:56:18  Show Profile
yes, just search.asp

fixed in v3.4
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000 Version 3.4.07