If it writes cleanly a small amount of data without further searching, direct file I / O is almost guaranteed to be more efficient. You lose all the advantages of a DBMS: indexing, transaction integrity (indeed, ACID in general), simultaneous access, etc.
You seem to be talking about what constitutes simple logging. If this is the case, and you donβt need to make frequent complex queries on the resulting data, you are probably better off working with direct file I / O if performance is a serious problem. However, be careful of problems with simultaneous recording.
If RDBMS features are desired, you might consider using SQLite, which for better performance will have better performance than most RDBMSs with less overhead due to some advantages (high level of simultaneous access and network access to other machines is a couple of βbigβ ones ) However, it will not be as fast as direct file I / O in the general case.
Your later mention that this is to track pageviews raises my question: are you increasing the counter, but not registering the pageview data? If so, I highly recommend switching to something like SQLite (something like UPDATE tbl SET counter = counter + 1). You really do not want to understand the time issues associated with this manually - if you do not do it right, you will start to lose accounts with simultaneous access (A reads β100β, B reads β100β, A writes β101β, B writes "101", B should have written 102, but does not know this).
Nicholas knight
source share