...

View Full Version : Would this be slow in the future? Heavy DB querying question



Tanner8
04-24-2011, 04:40 AM
Hey guys, I am on a project that requires a messaging system between users. I can't think of any solid way to divide up the messages into different tables to speed it up, so it seems like it will all have to be stuffed into one. My question is if the messaging table reached 10k-100k+ records, and is queried every page load for every user, is it going to be ridiculously slow?

Obviously the server would be something capable of handling such traffic, but I am just not sure if that many queries that often is even possible on any reasonable machine. Thank you

oracleguy
04-24-2011, 05:29 PM
If the table is properly indexed, I don't think it will be a problem. I would make sure to have the MySQL query cache enabled as well.

I am assuming you aren't going to be pulling the contents of all the messages for a user on every page load, just checking the number and/or if there are unread ones?

Tanner8
04-25-2011, 09:08 PM
If the table is properly indexed, I don't think it will be a problem. I would make sure to have the MySQL query cache enabled as well.

I am assuming you aren't going to be pulling the contents of all the messages for a user on every page load, just checking the number and/or if there are unread ones?

Alright thank you. I thought of a better way to do this anyway. I will place a variable on the users account that has the ID of the last message it searched up to in the last visit. So next page or visit, it will just check if the number of records changed, if it has, then scan from that variable through the rest of the new messages and reset the variable to the number of records in the table. That way I will never need to scan through the whole table more than once per user.

Wojjie
04-25-2011, 10:33 PM
Even better way to do it is to have a counter on the user of unread messages, and increment it when a message is send to that user. Then the query is simple, you just get the user, and check the counter, so you won't have to read the 'large' table on each page load.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum