in reply to MySQL "Counter"?

How about UPDATE impressions SET count = count+1 WHERE id=? .. I would guess this is as atomic as you can get with SQL. Forgive me if my SQL is invalid, it's a little late at night, but you get the point.

I can't say that I'm 100% sure if this statement is guaranteed to be atomic, and if I were really concerned about that, I would approach the problem differently:

blokhead

Replies are listed 'Best First'.
Re: Re: MySQL "Counter"?
by powerhouse (Friar) on Feb 05, 2003 at 08:33 UTC
    I love your suggestion. I even am implementing it. Thank you. I do have a few questions. I guess it would be more of a "design" question though, I think. What do you think?

    Here are the questions... More of can I please have your "opinions".

    I created a table with an auto incrementing `rid` field(record id) and a `id` field(affiliate id) plus two other fields, one is for the (banner|text ad) id and the last one is for the type of "update" (impression, hit or sale (enum 'i','h','s')).

    I'm kind of lost though. I will setup a cron job to run every half hour to take the data and remove it from the table to put it in another.

    What should I do with it? I mean, should I create a "table" for EACH affiliate? Then store the data in that table? That would amount to a lot of affiliates if I play our cards right(we are going to pay them lots of money (recurring too)). So say I ended up doing what one of my competitors is doing, they have 8000 affiliates. If I even get half that, and I had one table for each affiliate, that would be a HUGE database, right? So, should I scrap the database, and use Flat File databases? What would work better a bigger Database or a just more disk space taken?

    I love having the database, it's much easier to maintain.

    Plus, I would like to keep it where they can see how Each different "banner" or "text" ad did, so they can see the performance of each. If I just add it to a small database, it would only maintain the OVERALL picture, not show how each different one did.
    Does that matter?, should that matter?

    I'm confusing myself :o)

    If you will comment on that. If nothing else, please just answer these few questions. Do Databases that have thousands of "tables" run pretty slow?
    Are Flat File Databases FASTER then MySQL? (non mod_perl)

    Well, I've said too much. Sorry. My brain is having way to many brain 'farts' :o), I am confusing myself. I guess I need to take a few days off work, It's been at least 8 months since I've taken a full day off. I guess that is the bad thing about working at home, your always at work...

    Thank you for any tips||wisdom you can share.

    Richard.

    Geeze, I guess I do need a break. I thought I submitted this, I've been looking every where for any response for 5 hours:'(! It was hidden in one of my about 30 windows open....