php and textfile as a database

rgb192 used Ask the Experts™
php, windows server 2008, iis7, fastcgi

use a textfile as a database  
is this what caching is

would this be a php odbc connection

my sql server 2005 database is getting very large (which is slowing load time for my important data), so I would like to use a textfile for my data that is not important

why is it not recommended to use a textfile as a database does it use alot of cpu or ram

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Aaron TomoskyDirector of Solutions Consulting

What is so large in your database? Do you stour pictures or large datablobs? What do you consider large? How many rows?
using flat files (text file) as a database is not recommended because you cannot just jump to a row. you need to loop through each line in the file until you find the record you are looking for.

if you are just placing static text that you load the whole text file this will work just fine.


static text

biographies about different people

but should each person have their own text file
Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.


a one html page biography about one person may be 5000 characters
Most Valuable Expert 2011
Top Expert 2016
A text file is not a data base.  But a data base can certainly have pointers to a text file.  And if you are storing text you have to choose whether you want good performance (text stored in the file system) or full-text index capabilities and poor performance (text stored in the data base)  When data bases get slow, it is usually because someone coded a query like this:


That query has to do a table scan, transferring all the data in the table.  If the table contains a column with a 5,000 character HTML string for every row, you add n * 5,000 bytes to the workload.  But if the table contained a 50 character URL or file pointer you would save n * 4,950 bytes.

So my general advice would probably be to store the large elements in the file system and store pointers to these in the data base.  By "large elements" I would mean things like long text strings, pictures, audio or video files, etc.



Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial