Entry Counts and Database Errors
Wed Nov 21 2001

I think I may have a solution to both problems in one go. In any case, you will notice the Entry Count column gradually (as people add new entries) being updated to reflect the amount of entries a user has when you click the 'Show' button... A brief history into our rather appalling way of doing it previously will be needed to understand whats happening...

When the 'Show' Button is pressed, the system performs a query to obtain a list of diary ID's that have entries within the timescale you asked for. Presently its finding around 220 or so, just for a day (out of around 21,000). It also gets the diary title and user name and such like.

Once it had that information, it then went and queried the database (for those SQL bods amongst you, using a large IN statement, ie where bert IN ( x, y, z)) to get the number of entries. This method worked fairly well when we were only getting 100 updates in a day, and there were less than 50,000 entries etc etc. You get the idea. Basically it worked OK when the database was small. But lately that method has been taking around 20 to 30 seconds to complete, EVERY TIME someone clicked the 'Show' button. Somewhat unnacceptable really... Of course, while the database is fetching this information, no-one can update the entries table (if they try, it locks the table), resulting in queries queueing up behind each other until eventually it hits the maximum number of outstanding requests and you get the dreaded 'Sorry we are too busy' message.

I have now changed the system so that when you add an entry to your diary, it recalculates how many entries you have and updates a seperate 'lookup' table. The 'Show' screen simply fetches the stored entry count and displays it. The result is that the query which took 30 seconds on a good day, now takes about 0.03 seconds. Mucho faster. There doesn't appear to be a noticeable slowdown in the adding of entries either, so its a win all round. The only downer is that until that table is properly populated, some diaries will show 0 entries, incorrectly. Also, the count is updated ONLY when you ADD entries, so if you delete any then the count will be incorrect until you next add an entry.

But hopefully, that should cure a couple of problems in one swoop :-)

Steve.

8 Comments
  • From:
    Fallinstar (Legacy)
    On:
    Wed Nov 21 2001
    We're all very thankful for you Steve!
    (and Matt too)

    *sending one virtual turkey and stuffing to you for Thanksgiving*

    (((hugs)))
    Christina
  • From:
    02012000 (Legacy)
    On:
    Wed Nov 21 2001
    Boy I'm glad your the techie person!! IN (x,y,z) stuff is over my head, lol.
  • From:
    Starcrossed (Legacy)
    On:
    Wed Nov 21 2001
    I admire your smarts! I have absolutely no idea what you're talking about most of the time but I know it took brains to put this site together. I really enjoy DD and am completely hooked on it. Thanks!

    Star
  • From:
    Jade (Legacy)
    On:
    Wed Nov 21 2001
    We'll forgive you Steve. You've been way overworked lately! :) I'll be looking for my test email in the morning. (Oh, when I said 9:30am in the email earlier I meant Central Time - which would be 3:30PM your time, I believe). Thanks again for working so hard.
    -Jade
  • From:
    Alifelessordinary (Legacy)
    On:
    Thu Nov 22 2001
    We all know oyu guys put in a lot of UNPAID hours to give us this wondrous place to write. A big thankyou in case you don't hear it often enough from us dills who have no idea what your entries are on about, but know they are all working to make DD a better place for us [takes breath]

    THANKYOUTHANKYOUTHANKYOUTHANKYOUTHANKYOUTHANKYOU

    ~LIFE~
  • From:
    Salamander (Legacy)
    On:
    Thu Nov 22 2001
    Nite nite, Steve. Sleep well.
  • From:
    Mtwib (Legacy)
    On:
    Thu Nov 22 2001
    Thank you:)
    the sites running wya smoothly..
    better than ever,
    may u be blessed with a dozens day of hapiness,,
    did that make sense?
  • From:
    Xedri (Legacy)
    On:
    Thu Nov 22 2001
    Hehe Steve, and I thought we Americans had bad grammar! ;)

    Get plenty of rest, and have a good weekend :)

    Xedri