Forum Moderators: open
Is MySQL overkill for many uses, or does it offer any significant advantages over flat files other than the fact that you can't reliably use flat files when load-balancing between different servers? Flat files are usually faster, aren't they? What do MySQL/PostgreSQL/MS-SQL offer that makes them so popular for web development?
SQL (the query language) is the main reason i abandoned my plan to switch from database to flat-files. Although not perfect, it's extremely easy to quickly throw together all the queries you need for a site. The thought of writing a hacky php function every time you think of a new way to display/sort information doesn't appeal.
Other reasons that come to mind are:
- Transactions
- Scalability (Indexing in particular)
- Security
In general, i do agree that many sites could live without databases and in terms of performance would definitely benefit from switching to flat-files.
arran.
Flat files are usually faster
Flat files are NOT faster. they can only be read from top to bottom, and usually they have to be read all the way through.
A good database engine will take a query (Select field from table where field = '#*$!x') and first determine the best way to go into the database to solve the query, then leave the processing when the query is solved.
Another main reason to use databases is the ability to minimize the repetitions of data. Think about having multiple spreadsheets for a project. If you have an ID number assigned to a particular item, you only need to reference the ID number between different sets of data, rather than replicating all of the data for each sheet.
Database tables give you the ability to do this easily with "joins".
Still, if all you need to do is validate passwords, a flat file might be easier to use. But beyond that, you're much better off using a database.
I use flat files to cache database output for data that doesn't change very often.
I also use that type of hybrid design and have found it gives the best performance/data integrity balance.
Most CMS's are designed to do everything. That functionality always comes with a compromise.
Absolutely any CMS can be customised to work better for you than it does straight out of the box. Reducing unnecessary queries by removing them, or caching them, is one of the simplest things you can do that makes a significant performance difference.
I have several sites which run a simple CMS based on plain text files, and I can't see a reason to switch.
Great - a good sign of slick software and no unnecessary bloat.
I think it's a horses for courses thing. If you have a largely static site in terms of the data type you're displaying (i.e. what would be the DB structure in a DB based site doesn't ever need to change) then flatfile is great. And fast.
If you need to budget in the future for either complex load-balancing, or a structure of data that will need to grow and change, then a DB is probably the favourite choice - for reasons of management rather than speed.
Is MySQL overkill for many uses.....?
Yes. But given the low cost these days of an incredibly fast server, fast hard disk and plenty of RAM, does it really matter all that much?
Why is SQL so popular?
Convenience, simplicity of design, portability and easy management of content data.
TJ
It has nothing to do with speed or performance. Simple flat files will always out-do a database because manipulating them is closer to the machine language.
What a silly thing to say. Do you know how php handles flat files? Do you know how asp handles flat files? Do you know how C++ handles flat files ( which realy the notion of which doesn't even exist ) All do it diffferently and with different advantages and disadvantages.
Do you mean all flat files?
Are you using locks and semaphores?
Are you doing row processing?
Are you searching the flat file?
If your searching how many lines are in the flatfile?
Are there even lines?
And here's the doozy.. do you even know how to write assembly and what advantages it brings by being closer to the metal?
ALWAYS is a term you shouldn't use. Further more for anything data sets of signifigent size or doing anything signifigent with usually you are wrong. It takes quite a skilled programmer to use flat files to manage large amounts of data effeciently.
** anyways back to the point of the thread. **
The use of SQL allows for modular design of your application. If you think this is a one time app and you'll rarely if ever need to change it or its data, then a flat file may be the choice for you.
I always use SQL when there is the possibility of having the scale the application larger or the complexity of the data may increase. The reason being is that for me it is easier to change a sql based application than rewrite all my functions for parseing files.
If your worried about performance, getting a better server may be a solution for you. Processing power is cheap these days. For me it is cheaper than the amount of time it takes me to write code.
FIN