开发者

Performance: Templates in a Database or a File?

开发者 https://www.devze.com 2022-12-09 13:12 出处:网络
What is the fastest way to store templates? In a database (SQL Server) or a file? Those template can be from 1KB to ~15KB (usually 1-3KB).

What is the fastest way to store templates? In a database (SQL Server) or a file? Those template can be from 1KB to ~15KB (usually 1-3KB).

After开发者_开发知识库 reading the template, I'm parsing it with Regex to HTML. I've <div>[Block Parameter="Value" Parameters2="SomeValue" ...]</div> for example, so please consider that.

Thanks.


Reading a file will be faster than database access. But with DB you get bonus: transactions, concurrent access, ...


A common approach is to store the path to the file in your database, rather than the file itself. Doing so will allow you to keep your database small and lightweight. File systems are faster than databases in "serving up" the data, because it's part of the operating system and does not need to go through a large application stack such as relational database server.

edit: Whatever you're doing with the file after you've loaded it ("regex to html") is not related to how fast you can access where you stored the data in the file itself. I doubt your database is performing the "regex to html" step.

0

精彩评论

暂无评论...
验证码 换一张
取 消