Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2009
    Posts
    51
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Would this be slow in the future? Heavy DB querying question

    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

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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?
    Last edited by oracleguy; 04-24-2011 at 06:31 PM.
    OracleGuy

  • #3
    New Coder
    Join Date
    Aug 2009
    Posts
    51
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by oracleguy View Post
    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.

  • #4
    Regular Coder
    Join Date
    Apr 2011
    Posts
    286
    Thanks
    2
    Thanked 39 Times in 39 Posts
    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.

  • Users who have thanked Wojjie for this post:

    Tanner8 (04-26-2011)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •