检查唯一字符串时何时在文件系统“数据库”上使用MySQL

在我的许多应用程序中,一个非常常见的操作只是简单地检查一个持久字符串的存在,该字符串可以是唯一的用户名,文件名/ URL,UUID或UNIQUE()id或“通用主键”。过去,我没有考虑太多,只是在MySQL中创建了一个标准表来跟踪此情况。

I recently was told that this equivalent operation of simply checking for a unique string should probably just be done on the filesystem, check file_exist() on a path.

我的问题是,什么时候应该使用MySQL而不是仅仅(?)文件系统?

我的天真理解是MySQL设计为索引更好-但这仅适用于更复杂的操作吗?

我有一些担心:

  1. Does PHP file_exists() degrade when there are a large number of files in a folder? At which point should you "shard" a folder on an CentOS or Ubuntu Apache server (actually, I am not sure how dependent on PHP version, OS, web server version this is)?
  2. If one needs to do things like list files, does that also come at a high performance cost over just your typical MySQL SELECT Like '%bla%' for example?

引理:两个系统是否应该并行创建?用于快速检查的文件系统和用于列表/搜索/其他操作的MySQL系统?

评论