Ask HN: The right way to store settings in a webapp
The MySQL database isn't supposed to do this, tables are to store a variable number of rows with a fixed number of columns. Storing settings you would either set the variablename in the columnname and the value in a row, or create 2 columns (variable and value) and store variables in rows. Either way, the number of rows is constant. Not immediately a bad thing, but not ideal either.
There is also the lack of hierarchy this way, currently we have a filesystem-like path in use. The variable in the database will be something like "/modules/twitter/username". This is a custom system though, and it works but doesn't really feel right either. Unlike a table, files can be placed in the directory along with the right module (part of the application, they can be added or removed as needed).
Lastly a problem with a database is that you can use one table for all settings, or a new settings table for different modules. Using a single table, you would have to clean it up every time you add or delete a module. Using multiple tables, you get a long list of tables in the database, often to store only a few variables per application.
Settings files (ini, json, or another format) feel a lot more like how it should be done, but to open and parse a settings file every pageload seems not too great for performance either. Or even if it performed well enough, settings are something that can be loaded into the RAM and only written to the disk when changed. MySQL can keep file handles opened, doesn't use an interpreted language to read or write the data, and even caches stuff so there is often no disk interaction at all on reading.
So... what else could or should we use? NoSQL perhaps (I'm rather unfamiliar with that)? Or is there simply no optimal solution and should we continue to (ab)use the database for this?