Help - Search - Member List - Calendar
Full Version: speed: file vs. DB
WorkTheWeb Forums > Webmaster Resources > PHP Help
Support our Sponsors!
Olaf Noehring
Hi

Ich bin der administrator von TSEP - The Search Engine Project
(www.tsep.info).
Wir Developer haben eine Unstimmigkeit was schneller geht, daher wende ich
mich an Euch:
Ist es schneller
a) in eine Datei zu schreiben
oder
b) einen Datensatz in einer Datenbank zu aktualisieren?

Olaf

--
http://www.team-noehring.de

Stefan Rybacki
Olaf Noehring wrote:
QUOTE
Hi

Ich bin der administrator von TSEP - The Search Engine Project
(www.tsep.info).
Wir Developer haben eine Unstimmigkeit was schneller geht, daher wende ich
mich an Euch:
Ist es schneller
a) in eine Datei zu schreiben
oder
b) einen Datensatz in einer Datenbank zu aktualisieren?

Olaf

hm, du hast schon gemerkt, da diese Newsgroup englisch ist?


For those that aren't able to read the german text above:
QUOTE
Hey

I'm the admin of The Search Engine Project (www.tsep.info)
We are wondering what will be faster
a) write into a file
or
b) alter a tupel in a database
What is your opinion on this?

Olaf



So what about your problem. Why don't you guys test it? I guess the
database will be faster in the average case, but this also depends on
the database structure for example which indices have to be updated
after an update and of course of the structure you use in the files,
because a database also stores its data into a file ;)
So lets think about an avarage case:
10000 of datarows in the most naive file solution a CSV file. Imaging
you want to alter the 5000th row, you need to load the entire file (at
once or in parts), alter the row and store the whole file. A database
doesn't do so, so it would be of course faster. But if you have say a
B*-Tree structure behind your files you may get the same results a
database get. Well just test it.


Regards
Stefan

Olaf Noehring
Hi Stefan

QUOTE
hm, du hast schon gemerkt, da diese Newsgroup englisch ist?
nope, I did not notice - really!


QUOTE
I'm the admin of The Search Engine Project (www.tsep.info)
We are wondering what will be faster
a) write into a file
or
b) alter a tupel in a database
What is your opinion on this?

Thanks for your answer. We need to write only about 5 lines to the file -
or 1 record to the DB. It's only needed to tell the indexer (of TSEP)
which reads the contents of the files that another instance of the indexer
is already running. So, the first instance started will write to the file
/ db record when it has been started and that it is running at time X
(every 30 seconds)

We will probably favor the simple file.

Sorry, that I missed the english translation of my request and the
explanation what we need this for. Thanks for translating and your comment
Stefan.

Olaf

--
http://www.team-noehring.de

Tony
Olaf Noehring wrote:
QUOTE
I'm the admin of The Search Engine Project (www.tsep.info)
We are wondering what will be faster
a) write into a file
or
b) alter a tupel in a database
What is your opinion on this?

Thanks for your answer. We need to write only about 5 lines to the
file - or 1 record to the DB. It's only needed to tell the indexer
(of TSEP) which reads the contents of the files that another instance
of the indexer is already running. So, the first instance started
will write to the file / db record when it has been started and that
it is running at time X (every 30 seconds)

If there is no searching involved, just writing 5 lines (as you specified),
the simple file operation probably is faster. I would be concerned if you're
doing an append and the file size gets rather large, though - you may want
to do a little testing of that scenario.

--
Tony Garcia
Web Right! Development


PHP Help | Linux Help | Web Hosting | Reseller Hosting | SSL Hosting
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2006 Invision Power Services, Inc.