We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
MySQL vs text (Read 491 times)
MySQL vs text
Jun 20th, 2008, 6:15am
 
I'm working on a project that will involve a large amount of simple data to be collected, viewed and deleted over the course of a day (maybe about 2,000 to 10,000).

It works like this:

- Various website hits trigger a PHP script that adds a record to a MySQL database

- Processing accesses that PHP script every few seconds, retrieving the entries and deleting them

Would it be quicker to do this PHP script by writing, reading, and deleting a text file instead of performing MySQL queries?
Re: MySQL vs text
Reply #1 - Jun 20th, 2008, 7:09am
 
If the amount of data is large and involve lot of dynamic operations, I believe that database is better suited to your needs: it is optimized for such usage.
Now, optimization of the SQL queries is important, too.
And well, the number of data is less important than their overall size. If everything easily fit in memory, reading the whole text file at once, altering it in memory and spitting it at once back in the file can be efficient too, as long as you don't have to deal with concurrent accesses...
Re: MySQL vs text
Reply #2 - Jun 20th, 2008, 1:50pm
 
Thanks for the quick reply, it'll just be the one script accessing it.

So even though my "database" will only ever contain 10 records of 6-8 columns at a time (because it's cleaned up every few seconds), MySQL is the way to go?
Re: MySQL vs text
Reply #3 - Jun 20th, 2008, 3:26pm
 
ppritcha wrote on Jun 20th, 2008, 1:50pm:
it'll just be the one script accessing it.

Yes, but in general Web servers are designed to serve many requests simultaneously: if several users use the applet at the same time, you will have concurrent scripts running simultaneously.
You can solve that at the level of text file by checking if it is locked and waiting for the lock to be removed.
Or just let the database handle that, they are good for this!
Page Index Toggle Pages: 1