从文件或数据库服务器访问数据更快吗? [英] Is it faster to access data from files or a database server?

查看:123
本文介绍了从文件或数据库服务器访问数据更快吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个由文件夹和文件组成的静态数据库,考虑到将在CGI脚本中使用它,访问和操作是否比SQL Server类型的数据库要快?

If I have a static database consisting of folders and files, would access and manipulation be faster than SQL server type databases, considering this would be used in a CGI script?

使用文件和文件夹时,提高性能的诀窍是什么?

When working with files and folders, what are the tricks to better performance?

推荐答案

我将添加到它

这种问题没有通用答案,但在很大程度上取决于当前的情况。我什至最近甚至将一些数据从SQL数据库移到了平面文件系统,因为数据库的开销以及一些数据库连接可靠性问题使使用平面文件成为更好的选择。

This is the kind of question that has no generic answer but is heavily dependent on the situation at hand. I even recently moved some data from a SQL database to a flat file system because the overhead of the DB, combined with some DB connection reliability issues, made using flat files a better choice.

做出选择时,我会问自己一些问题:

Some questions I would ask myself when making the choice include:


  1. 我如何使用数据?例如,我只是按输入的顺序从头到尾读取行吗?还是我要搜索符合多个条件的行?

  1. How am I consuming the data? For example will I just be reading from the beginning to the end rows in the order entered? Or will I be searching for rows that match multiple criteria?

在一个程序执行过程中,我将多久访问一次数据?我会否以塞林格为作者来获得所有书籍,还是会为获得数位不同的作者而去几次?对于几种不同的条件,我会不止一次吗?

How often will I be accessing the data during one program execution? Will I go once to get all books with Salinger as the author or will I go several times to get several different authors? Will I go more than once for several different criteria?

我将如何添加数据?我可以在行末尾附加一行,这对我的检索来说是完美的,还是需要重新执行?

How will I be adding data? Can I just append a row to the end and that's perfect for my retrieval or will it need to be resorted?

代码的外观如何合理六个月之内?我之所以强调这一点,是因为我认为这在设计事物时常常被人遗忘(不仅仅是代码,这匹业余爱好实际上是我作为海军机械师诅咒机械工程师的日子)。在六个月内,我必须维护您的代码(或在完成另一个项目后再执行)时,哪种方式存储和检索数据更有意义。如果从平面文件到数据库的效率提高了1%,但又增加了一周的时间来解决问题,那么当您必须更新代码时,您的情况就得到了真正的改善。

How logical will the code look in six months? I emphasize this because I think this is too often forgotten in designing things (not just code, this hobby horse is actually from my days as a Navy mechanic cursing mechanical engineers). In six months when I have to maintain your code (or you do after working another project) which way of storing and retrieving data will make more sense. If going from flat files to a DB results in a 1% efficiency improvement but adds a week of figuring things out when you have to update the code have you really improved things.

这篇关于从文件或数据库服务器访问数据更快吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆