Reply to Re: Efficiency of file vs database

Your name:

Reply:


Posted by Erwin Moller on 12/18/06 11:17

ircmaxell wrote:

> Ok, I have a program that reads the contents of a file (1 line, 5 '|'
> seperated items). Every so often (between twice a day, and 200 times a
> day), it rewrites the contents of that file. I also do a few database
> update queries whenever the file is written. I only open up the
> database connector if I need to update the database. The script itself
> runs every 30 seconds. My question, is that is it faster and more
> efficient to read the file every time, or open the database connector
> and make a query? The file name never changes, and I read the whole
> file at one time (679 bites).

Hi,

Only one way to find out: timestamp both operations and see how long they
take to complete.
But the results may vary a lot based on machineload and needed diskIO (for
other processes).

In general: If your application is running fine with a small file, leave it
that way.
A database will typically be faster if your file is big, because opening a
big file and loading it into memory will take diskIO time, which is often a
bottleneck on modern machines (fast CPU, relatively slow disk IO).

More general: If you don't have a problem, don't fix it. :-)
You should of course be carefull when writing to a file and take precautions
no other process is doing the same (filelocking).

just my 2 cent.

Regards,
Erwin Moller

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация