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

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: General / Classic ASP versions(v3.4.XX)
 Update Forum Counts?
 New Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sikandar
Junior Member

Pakistan
135 Posts

Posted - 26 January 2013 :  08:55:47  Show Profile  Reply with Quote
Hi,
I am trying to run Update Forum Counts but it is getting timeout due to long list of topics. Inside the asp file I had also increased the timeout from 600 to large number but still not able to get it completed. tks

AnonJr
Moderator

United States
5768 Posts

Posted - 28 January 2013 :  10:08:09  Show Profile  Visit AnonJr's Homepage
Sounds like it may be time to archive some of your older material. If there's enough that it's timing out on the counts, then I would recommend archiving in small chunks to prevent timeouts and other odd errors resulting from a timeout in the middle of the process.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 28 January 2013 :  13:15:36  Show Profile  Send ruirib a Yahoo! Message
There are scripts that were posted before to do this from the database side of things, if you are running on MySQL or SQL Server. If you are running on Access, well, maybe you should consider upgrading.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

sikandar
Junior Member

Pakistan
135 Posts

Posted - 01 February 2013 :  03:55:39  Show Profile
Hi,
Thanks AnonJr for the suggestion and sure will consider the archiving option.

Ruirib I am using MYSQL so from where I can get those scripts?

tks
Go to Top of Page

sikandar
Junior Member

Pakistan
135 Posts

Posted - 01 February 2013 :  04:37:33  Show Profile
Hi Ruirib,
I found the following for mysql?

http://forum.snitz.com/forum/topic.asp?TOPIC_ID=61685
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 01 February 2013 :  05:45:57  Show Profile  Send ruirib a Yahoo! Message
Yep, that is the one. You need to execute it on a MySQL client or maybe even phpMyAdmin. You can also create a stored proc based on this (I can provide additional code) and just execute the stored procedure.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

sikandar
Junior Member

Pakistan
135 Posts

Posted - 01 February 2013 :  07:44:41  Show Profile
"(I can provide additional code) and just execute the stored procedure."

Please provide the additional code as will be appreciated. tks
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 01 February 2013 :  09:51:15  Show Profile  Send ruirib a Yahoo! Message
This will create you a stored procedure to do it:

DELIMITER $$

DROP PROCEDURE IF EXISTS `uspUpdateCounts`$$

CREATE PROCEDURE `uspUpdateCounts`()
BEGIN
/* Update Forum Topic Counts */
CREATE TEMPORARY TABLE F_T_COUNT (
FORUM_ID INT(11),
T_COUNT INT (11)
);
UPDATE FORUM_FORUM SET F_TOPICS = 0;
INSERT INTO F_T_COUNT
SELECT FORUM_ID, COUNT(FORUM_ID) FROM FORUM_TOPICS WHERE T_STATUS<=1 GROUP BY FORUM_ID ;
UPDATE FORUM_FORUM F INNER JOIN F_T_COUNT T ON T.FORUM_ID=F.FORUM_ID
SET F_TOPICS = T_COUNT;
/* Update Forum Archived Topics Count */
DELETE FROM F_T_COUNT;
UPDATE FORUM_FORUM SET F_A_TOPICS = 0;
INSERT INTO F_T_COUNT
SELECT FORUM_ID, COUNT(FORUM_ID) FROM FORUM_A_TOPICS WHERE T_STATUS<=1 GROUP BY FORUM_ID ;
UPDATE FORUM_FORUM F INNER JOIN F_T_COUNT T ON T.FORUM_ID=F.FORUM_ID
SET F_A_TOPICS = T_COUNT;
DROP TABLE F_T_COUNT;
/* Update Topic Replies Counts now */
CREATE TEMPORARY TABLE T_R_COUNT (
TOPIC_ID INT(11),
R_COUNT INT(11)
);
INSERT INTO T_R_COUNT
SELECT TOPIC_ID, COUNT(REPLY_ID) FROM FORUM_REPLY WHERE R_STATUS<=1 GROUP BY TOPIC_ID ;
UPDATE FORUM_TOPICS SET T_REPLIES = 0 WHERE T_STATUS<=1;
UPDATE FORUM_TOPICS T INNER JOIN T_R_COUNT TR ON T.TOPIC_ID = TR.TOPIC_ID
SET T_REPLIES = R_COUNT WHERE T.T_STATUS<=1;
/* Update Archived Topics Replies Count Now */
DELETE FROM T_R_COUNT;
INSERT INTO T_R_COUNT
SELECT TOPIC_ID, COUNT(REPLY_ID) FROM FORUM_A_REPLY GROUP BY TOPIC_ID;
UPDATE FORUM_A_TOPICS SET T_REPLIES = 0;
UPDATE FORUM_A_TOPICS T INNER JOIN T_R_COUNT TR ON T.TOPIC_ID = TR.TOPIC_ID
SET T_REPLIES = R_COUNT;
DROP TABLE T_R_COUNT;
/* Update Last post Date */
CREATE TEMPORARY TABLE T_POST_DATA (
TOPIC_ID INT(11),
LAST_POST VARCHAR(50)
);
INSERT INTO T_POST_DATA
SELECT TOPIC_ID, MAX(R_DATE) FROM FORUM_REPLY WHERE R_STATUS<=1 GROUP BY TOPIC_ID;
UPDATE FORUM_TOPICS T INNER JOIN T_POST_DATA TP ON T.TOPIC_ID = TP.TOPIC_ID
SET T.T_LAST_POST = LAST_POST;
DELETE FROM T_POST_DATA;
UPDATE FORUM_TOPICS SET T_LAST_POST=T_DATE, T_LAST_POST_AUTHOR=T_AUTHOR, T_LAST_POST_REPLY_ID=0 WHERE T_REPLIES=0;
/* Update Last post Date */
INSERT INTO T_POST_DATA
SELECT TOPIC_ID, MAX(R_DATE) FROM FORUM_A_REPLY GROUP BY TOPIC_ID;
UPDATE FORUM_A_TOPICS T INNER JOIN T_POST_DATA TP ON T.TOPIC_ID = TP.TOPIC_ID
SET T.T_LAST_POST = TP.LAST_POST;
UPDATE FORUM_A_TOPICS SET T_LAST_POST=T_DATE, T_LAST_POST_AUTHOR=T_AUTHOR,T_LAST_POST_REPLY_ID=0 WHERE T_REPLIES=0;
DROP TABLE T_POST_DATA;
/* Now find the reply ID for the posts that have more than 0 replies */
CREATE TEMPORARY TABLE T_L_REPLY_ID (
TOPIC_ID INT(11),
REPLY_ID INT(11)
);
INSERT INTO T_L_REPLY_ID
SELECT T.TOPIC_ID, MAX(REPLY_ID) FROM FORUM_REPLY R INNER JOIN FORUM_TOPICS T ON R.TOPIC_ID=T.TOPIC_ID
WHERE T.T_LAST_POST=R_DATE AND T_STATUS<=1 GROUP BY T.TOPIC_ID;
UPDATE FORUM_TOPICS T INNER JOIN T_L_REPLY_ID TL ON TL.TOPIC_ID = T.TOPIC_ID
SET T.T_LAST_POST_REPLY_ID = TL.REPLY_ID;
DELETE FROM T_L_REPLY_ID;
/* Now find the reply ID for the posts that have more than 0 replies in archived topics */
INSERT INTO T_L_REPLY_ID
SELECT T.TOPIC_ID, MAX(REPLY_ID) FROM FORUM_A_REPLY R INNER JOIN FORUM_A_TOPICS T ON R.TOPIC_ID=T.TOPIC_ID
WHERE T.T_LAST_POST=R_DATE GROUP BY T.TOPIC_ID;
UPDATE FORUM_A_TOPICS T INNER JOIN T_L_REPLY_ID TL ON TL.TOPIC_ID = T.TOPIC_ID
SET T.T_LAST_POST_REPLY_ID = TL.REPLY_ID;
DROP TABLE T_L_REPLY_ID;
/* Now found the author ID for the last reply */
CREATE TEMPORARY TABLE T_L_REPLY_AUTHOR(
TOPIC_ID INT(11),
AUTHOR INT(11)
);
INSERT INTO T_L_REPLY_AUTHOR
SELECT T.TOPIC_ID, R.R_AUTHOR FROM FORUM_TOPICS T INNER JOIN FORUM_REPLY R ON T.TOPIC_ID=R.TOPIC_ID
WHERE T.T_LAST_POST_REPLY_ID = R.REPLY_ID AND T_STATUS<=1;
UPDATE FORUM_TOPICS T INNER JOIN T_L_REPLY_AUTHOR TL ON TL.TOPIC_ID = T.TOPIC_ID
SET T.T_LAST_POST_AUTHOR = TL.AUTHOR;
DELETE FROM T_L_REPLY_AUTHOR;
INSERT INTO T_L_REPLY_AUTHOR
SELECT T.TOPIC_ID, R.R_AUTHOR FROM FORUM_A_TOPICS T INNER JOIN FORUM_A_REPLY R ON T.TOPIC_ID=R.TOPIC_ID
WHERE T.T_LAST_POST_REPLY_ID = R.REPLY_ID;
UPDATE FORUM_A_TOPICS T INNER JOIN T_L_REPLY_AUTHOR TL ON TL.TOPIC_ID = T.TOPIC_ID
SET T.T_LAST_POSTER = TL.AUTHOR;
DROP TABLE T_L_REPLY_AUTHOR;
/* Now to current step 3, unmoderated replies per topic */
/* Update Topic Replies Counts now */
CREATE TEMPORARY TABLE T_R_COUNT (
TOPIC_ID INT(11),
R_COUNT INT(11)
);
INSERT INTO T_R_COUNT
SELECT TOPIC_ID, COUNT(REPLY_ID) FROM FORUM_REPLY WHERE R_STATUS=2 OR R_STATUS=3 GROUP BY TOPIC_ID ;
UPDATE FORUM_TOPICS SET T_UREPLIES = 0 WHERE T_STATUS<=1;
UPDATE FORUM_TOPICS T INNER JOIN T_R_COUNT TR ON T.TOPIC_ID = TR.TOPIC_ID
SET T_UREPLIES = R_COUNT WHERE T.T_STATUS<=1;
DROP TABLE T_R_COUNT;
/* Now to step 4 */
/* Count replies per forum */
CREATE TEMPORARY TABLE F_R_COUNT (
FORUM_ID INT(11),
R_COUNT INT (11)
);
INSERT INTO F_R_COUNT
SELECT R.FORUM_ID, COUNT(REPLY_ID) FROM FORUM_TOPICS T INNER JOIN FORUM_REPLY R ON T.TOPIC_ID=R.TOPIC_ID
WHERE T.T_STATUS<=1 AND R_STATUS<=1 GROUP BY R.FORUM_ID;
UPDATE FORUM_FORUM SET F_COUNT=F_TOPICS WHERE F_TYPE<>1;
UPDATE FORUM_FORUM F INNER JOIN F_R_COUNT FR ON F.FORUM_ID = FR.FORUM_ID
SET F.F_COUNT = F.F_COUNT + FR.R_COUNT;
DELETE FROM F_R_COUNT;
INSERT INTO F_R_COUNT
SELECT R.FORUM_ID, COUNT(REPLY_ID) FROM FORUM_A_TOPICS T INNER JOIN FORUM_A_REPLY R ON T.TOPIC_ID=R.TOPIC_ID GROUP BY R.FORUM_ID;
UPDATE FORUM_FORUM SET F_A_COUNT=F_A_TOPICS WHERE F_TYPE<>1;
UPDATE FORUM_FORUM F INNER JOIN F_R_COUNT FR ON F.FORUM_ID = FR.FORUM_ID
SET F.F_A_COUNT = F.F_A_COUNT + FR.R_COUNT;
DROP TABLE F_R_COUNT;
/* Update Last Post Per Forum */
CREATE TEMPORARY TABLE F_POST_DATA (
FORUM_ID INT(11),
LAST_POST VARCHAR(50)
);
INSERT INTO F_POST_DATA
SELECT FORUM_ID, MAX(T_LAST_POST) FROM FORUM_TOPICS WHERE T_STATUS<=1 GROUP BY FORUM_ID;
UPDATE FORUM_FORUM F INNER JOIN F_POST_DATA FP ON F.FORUM_ID = FP.FORUM_ID
SET F.F_LAST_POST = LAST_POST;
DROP TABLE F_POST_DATA;
/* Update Last Post TOPIC_ID */
CREATE TEMPORARY TABLE F_TOPIC_ID (
FORUM_ID INT(11),
TOPIC_ID INT(11)
);
INSERT INTO F_TOPIC_ID
SELECT F.FORUM_ID, MAX(T.TOPIC_ID) FROM FORUM_FORUM F INNER JOIN FORUM_TOPICS T ON F.FORUM_ID=T.FORUM_ID
WHERE F.F_LAST_POST = T.T_LAST_POST AND T.T_STATUS<=1 GROUP BY F.FORUM_ID;
UPDATE FORUM_FORUM F INNER JOIN F_TOPIC_ID FT ON F.FORUM_ID = FT.FORUM_ID
SET F.F_LAST_POST_TOPIC_ID = FT.TOPIC_ID;
DROP TABLE F_TOPIC_ID;
/* Now Update for Author ID */
UPDATE FORUM_FORUM F INNER JOIN FORUM_TOPICS T ON F.F_LAST_POST_TOPIC_ID=T.TOPIC_ID
SET F.F_LAST_POST_AUTHOR=T.T_LAST_POST_AUTHOR, F.F_LAST_POST_REPLY_ID=T.T_LAST_POST_REPLY_ID;
CREATE TEMPORARY TABLE T_TOPICS (
COUNT_ID INT(11),
TOPICS INT(11),
A_TOPICS INT(11)
);
INSERT INTO T_TOPICS
SELECT 1, SUM(F_TOPICS), SUM(F_A_TOPICS) FROM FORUM_FORUM;
UPDATE FORUM_TOTALS FT INNER JOIN T_TOPICS TT ON FT.COUNT_ID=TT.COUNT_ID
SET FT.T_COUNT = TT.TOPICS, FT.T_A_COUNT = A_TOPICS;
DROP TABLE T_TOPICS;
CREATE TEMPORARY TABLE T_TOPICS (
COUNT_ID INT(11),
TOPICS INT(11),
A_TOPICS INT(11),
POSTS INT(11),
A_POSTS INT(11)
);
INSERT INTO T_TOPICS
SELECT 1, SUM(F_TOPICS), SUM(F_A_TOPICS),SUM(F_COUNT),SUM(F_A_COUNT) FROM FORUM_FORUM WHERE F_TYPE<>1;
UPDATE FORUM_TOTALS FT INNER JOIN T_TOPICS TT ON FT.COUNT_ID=TT.COUNT_ID
SET FT.T_COUNT = TT.TOPICS, FT.T_A_COUNT = A_TOPICS, FT.P_COUNT=TT.POSTS, FT.P_A_COUNT=TT.A_POSTS;
DROP TABLE T_TOPICS;
CREATE TEMPORARY TABLE T_MEMBERS (
COUNT_ID INT(11),
MEMBERS INT(11)
);

INSERT INTO T_MEMBERS
SELECT 1, COUNT(MEMBER_ID) FROM FORUM_MEMBERS;
UPDATE FORUM_TOTALS FT INNER JOIN T_MEMBERS TM ON FT.COUNT_ID=TM.COUNT_ID
SET FT.U_COUNT = TM.MEMBERS;
DROP TABLE T_MEMBERS;
END$$

DELIMITER ;


This will execute the stored procedure, once created:


CALL uspUpdateCounts();


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

sikandar
Junior Member

Pakistan
135 Posts

Posted - 04 March 2013 :  21:57:24  Show Profile
Hi Ruirib,
I have created and executed the procedure but seems not much lucky as current counts are as it is and if I am reading one topic once and refreshing the page it is showing jump of 10 addition in the read counter. Any tip please. tks
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 05 March 2013 :  01:55:22  Show Profile  Visit HuwR's Homepage
the read counter is not changed by updating forum counts. A jump in the read counter like that could mean that someone has the topic tagged somewhere, it happened here with a few topics some weeks ago

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

sikandar
Junior Member

Pakistan
135 Posts

Posted - 05 March 2013 :  02:06:02  Show Profile
I am surprised as topics READS are going to thousands which was not happening before. From where and how I can check tagging and also kindly let me know then what is this forum count suppose to do? tks
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 05 March 2013 :  02:48:39  Show Profile  Visit HuwR's Homepage
the update ccounts, updates all the topic and reply counts so they match what is actually in the database as occasionaly they get out of sync.

The only way to check why your read counts are going up so high is to look in your IIS log files, you will then see the same ip address connecting to the same topic over and over again. There is very little you can do about it

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 05 March 2013 :  02:54:28  Show Profile  Visit HuwR's Homepage
here is an example of a topic it happened to here

http://forum.snitz.com/forum/topic.asp?TOPIC_ID=70382 it has a read count of 114250

MVC .net dev/test site | MVC .net running on Raspberry Pi
Go to Top of Page

Carefree
Advanced Member

Philippines
4217 Posts

Posted - 05 March 2013 :  05:17:44  Show Profile
Better examples, HuwR:
"Forgot Password" Link Not Displaying on login.asp - 511,844 Reads! and Create version without requiring login - 554,842 Reads!

Edited by - Carefree on 05 March 2013 05:19:57
Go to Top of Page

Carefree
Advanced Member

Philippines
4217 Posts

Posted - 05 March 2013 :  05:21:39  Show Profile
quote:
Originally posted by HuwR

the update ccounts, updates all the topic and reply counts so they match what is actually in the database as occasionaly they get out of sync.

The only way to check why your read counts are going up so high is to look in your IIS log files, you will then see the same ip address connecting to the same topic over and over again. There is very little you can do about it



Well, you could ban the IP and/or IP range that's constantly connecting.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.35 seconds. Powered By: Snitz Forums 2000 Version 3.4.07