views:

117

answers:

6

Subjective question, I know, but I am counting outgoing clicks for a very specific part of a website, and I'm simply needing to keep a tally of outgoing clicks per link and per day. I know that I could use MySQL for this, but I am wondering if there is something smaller/more-efficient for this application.

I manage my own server on slicehost running Ubuntu 9.10 with Apache/2.2.12 and could install something, however, is there something that is small and easily dropped in for small applications like this?

Perhaps something that writes to it's own file within the site.

Clarification: this question is about the efficiency of code required to simply setup small things like this. I do not have nor anticipate performance issues. I'm curious what other people use for things like this. Maybe it is MySQL - I'm here to learn.

+2  A: 

You could use SQLite but honestly, this entire question reeks of pre-optimization.

Peter Bailey
it's not pre-optimization, it's application design.
galambalazs
I'd tend to agree, this reeks of pre-optimization.
Kalium
what do you mean by pre-optimization?
JonKratz
By looking for something "smaller" and "more efficient" than MySQL as if you already have a size and efficiency problem.
Peter Bailey
JonKratz
Well, what you're really looking for here is something with fast INSERT performance. A topic which I don't have any particular insight on. I think it's probably more about the storage engine and nature of the queries than the DBMS chose, though.
Peter Bailey
@JonKratz: Just use Oracle! ;-)
Mike
alright so you would use BIGINTS all over your database because you haven't got performance problems yet? Just because you can? No, you chose your algorithm and storage depending on your application's attributes.
galambalazs
+1  A: 

You can do smaller. You can do more efficient. You're not really going to get both in the same package.

  • SQLite is smaller and contained in a single file. It's also substantially slower than MySQL.
  • Firebird is similarly contained to a single file. I believe it also underperforms MySQL.
  • Oracle is expensive and not even remotely "small". It can be very efficient.
  • PostgreSQL is an option, but again not small. It also handles differently than MySQL and is known to be more complex to administer.

Really, I'm with Peter Bailey on this. This whole question reeks of pre-optimization. Do you actually have a performance problem that justifies using an additional database?

Kalium
You are correct: I do not have a site performance problem and as Peter Bailely suggested, I am not needing to be concerned about size and efficiency at this time. I clarified in my question above that what I am wondering is if, for small applications like this, there is a better (as in quicker to set-up/code) database. Or it could just be my own inefficiencies as a coder in MySQL that cause me to ask this question.Thank you for your suggestions.
JonKratz
Thank you for listing out options with explanations, this was helpful and should at least assist me trying out a new database.
JonKratz
A: 

Since you've parameterized your architecture by using code efficiency as a metric instead of performance under load (or whatever), just go with whatever database technology you're most familiar with. This will drastically reduce code writing and debugging time.

Of course, you might also want to take this opportunity to learn a new database technology. If that's the case, then find out what would make you more valuable to your current or future employer(s) (ie., they might be looking at a different technology for a new product, which you can become the in house guru of), what new databases are "up and coming", etc.

Sam Bisbee
+1  A: 

You could use Memcached as an in-memory cache for your hit counter.

<?php
$m = new Memcached();
$m->addServer('localhost', 11211);

$m->add('counter', 0); // no-op if key already exists
$m->increment('counter');

Then you would run another script offline every minute or so to read the hit counter, add it to a persistent database, and reset the counter to zero.

<?php
$m = new Memcached();
$m->addServer('localhost', 11211);

$count = (int) $m->get('counter');
$m->set('counter', 0);

$pdo->exec("UPDATE mytable SET counter = counter + {$count}");
Bill Karwin
This is great! Thank you...
JonKratz
A: 

Use a text file with fopen()?

Jon
A: 

Just use a text file. fopen / fwrite / fclose

Gate