一个文件夹中有1到2百万个文件? [英] 1 - 2 millions files in one folder?

查看:142
本文介绍了一个文件夹中有1到2百万个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我真的需要你的建议。

我必须在一个文件夹中存储超过一百万个文件,每个10到15 kb。

这些文件是由我的php脚本创建的,有时旧的文件被删除了,而且新的文件被写了。

所以,基本上每个连接我的脚本读取/删除/写入文件

从/到该文件夹​​。

现在我在该文件夹中只有大约300,000个文件,感觉

喜欢它让脚本工作变慢。它确实在

时刻工作,但我不确定当那里有超过一百万个b $ b b文件会发生什么...

是否存在可以存储在文件夹中的文件的限制?

我使用mysql会更好吗?我不确定mysql会怎样

应对数百万的写/读

你会推荐什么?

非常感谢你!

ps我正在运行linux,fedora core 3

Hi all,
I really need your advice.
I have to store over a million files, 10 - 15 kb each, in one folder.
The files are created by my php script, sometimes the old files are
deleted and new ones are written.
So, basically on every connection my script reads/deletes/ writes files
from/to that folder.
Right now i have only around 300 000 files in that folder, and it feels
like its getting slower for that script to work. It does work at the
moment, but i am not sure what will happen when there is over a million
files there...
Are there any limits of files that can be stored in a folder?
Would it be better for me to use mysql? I am not sure how mysql will
cope with millions of writes/reads
What would you recommend?
Thank you very much!
p.s.I am running linux, fedora core 3

推荐答案

On Thu,2006年7月27日02:49:10 -0700,b007uk写道:
On Thu, 27 Jul 2006 02:49:10 -0700, b007uk wrote:

大家好,

我真的需要你的建议。

我必须在一个文件夹中存储超过一百万个文件,每个10-15kb。

这些文件是由我的php脚本创建的,有时旧的文件被删除了b
和新文件写的。

所以,基本上在每个连接上我的脚本读取/删除/写入文件

从/到该文件夹​​。

现在我该文件夹中只有大约300,000个文件,并且感觉好像这个脚本工作速度慢了。它确实在

时刻工作,但我不确定当那里有超过一百万个b $ b b文件会发生什么...

是否存在可以存储在文件夹中的文件的限制?

我使用mysql会更好吗?我不确定mysql会怎样

应对数百万的写/读

你会推荐什么?

非常感谢你!

psI正在运行linux,fedora core 3
Hi all,
I really need your advice.
I have to store over a million files, 10 - 15 kb each, in one folder.
The files are created by my php script, sometimes the old files are
deleted and new ones are written.
So, basically on every connection my script reads/deletes/ writes files
from/to that folder.
Right now i have only around 300 000 files in that folder, and it feels
like its getting slower for that script to work. It does work at the
moment, but i am not sure what will happen when there is over a million
files there...
Are there any limits of files that can be stored in a folder?
Would it be better for me to use mysql? I am not sure how mysql will
cope with millions of writes/reads
What would you recommend?
Thank you very much!
p.s.I am running linux, fedora core 3



总之...... *你疯了* !!!查看使用不同文件系统在

linux下存储文件的方式。有了ext2 / 3,上帝知道你会经历多少

级别的间接,甚至可以用来索引

目录。

你需要做大量的阅读,大量的定制工作,并加载

基准测试才能实现这一目标。而且,tbh,我会找到另一种解决方案。

必须有一种方法可以将这些数据细分为可接受数量的

文件(数千或更少! !)每个目录。


史蒂夫

In a word... *you''re crazy*!!! Look at the way that files are stored under
linux, with the different file systems. with ext2/3, god knows how many
levels of indirection you''ll be going through to even amange to index the
directory.

You need to do a lot of reading, a lot of customization, and a load of
benchmarking to get this to work. And, tbh, I''d find another solution.
There must be a way to subdivide this data to get an acceptable number of
files ( thousands or less!!! ) in each directory.

Steve


b0 **** @ gmail.com 写道:
b0****@gmail.com wrote:

大家好,

我真的需要你的建议。

我必须在一个文件夹中存储超过一百万个文件,每个10-15kb。

这些文件是由我的php脚本创建的,有时是旧文件被删除了
并写入了新文件。

因此,基本上每个连接我的脚本都读取/删除/写入文件

来自/到那个文件夹。

现在我在该文件夹中只有大约300,000个文件,感觉好像这个脚本工作速度慢了。它确实在

时刻工作,但我不确定当那里有超过一百万个b $ b b文件会发生什么...

是否存在可以存储在文件夹中的文件的限制?

我使用mysql会更好吗?我不确定mysql会怎样

应对数百万的写/读

你会推荐什么?

非常感谢你!

psI正在运行linux,fedora core 3
Hi all,
I really need your advice.
I have to store over a million files, 10 - 15 kb each, in one folder.
The files are created by my php script, sometimes the old files are
deleted and new ones are written.
So, basically on every connection my script reads/deletes/ writes files
from/to that folder.
Right now i have only around 300 000 files in that folder, and it feels
like its getting slower for that script to work. It does work at the
moment, but i am not sure what will happen when there is over a million
files there...
Are there any limits of files that can be stored in a folder?
Would it be better for me to use mysql? I am not sure how mysql will
cope with millions of writes/reads
What would you recommend?
Thank you very much!
p.s.I am running linux, fedora core 3






不要。 :P

如果您知道该文件夹将包含数百万个文件,则底层操作系统

将需要越来越多的时间来获取正确的文件。

有些操作系统比其他操作系统更聪明,我不知道详细信息。


但是更好的是安全而不是抱歉,所以如果可能的话,使用数据库。这些东西

设置为通过(智能)

索引轻松处理大量的表查找。


一个简单的方法:

(Postgresnotation,而不是我避免使用的mySQL)


创建一个包含你内容的表格

创建表格文件{

fileid序列主键,

文件名文本,

内容文本

}


现在你可以非常快速地获取每个文件的内容,因为

fileid是主键,因此被索引。

如果你想使用文件名,索引那个。


所以(非常快)

从文件中选择内容WHERE(fileid = 238756);

因为fileid被编入索引。


如果您也编入索引文件名,这也会非常快:

SELECT内容FROM文件WHERE(filename ='' myfile_3_4_2006.txt'');


或者:也许你可以将整个方法转换为数据库并且

在需要时产生结果而不是产生数百万个文件。

这很难说因为我不知道潜在的问题,但在

一般来说,你可以用一个设计良好的数据库解决这个问题。


希望有所帮助,


问候,

欧文Moller

Hi,

Don''t. :P
If you know that folder will contain millions of files, the underlying OS
will need more and more time to get the right file.
Some OS''s are smarter than others, I do not know the details.

But better be safe than sorry, so if possible, use a database. These things
are set up to easily handle massive tablelookups by means of (smart)
indexing.

A simple approach:
(Postgresnotation, not mySQL which I avoid)

create a table that holds your content
create table files{
fileid serial primary key,
filename text,
content text
}

Now you can get the content of each file based on its id very fast because
fileid is primary key, and thus indexed.
If you want to use the filename, index that one too.

So (very fast)
SELECT content from files WHERE (fileid=238756);
because fileid is indexed.

And if you indexed filename too, this will also be very fast:
SELECT content FROM files WHERE (filename=''myfile_3_4_2006.txt'');

Alternatively: Maybe you can translate your whole approach to a database and
produce the results when needed instead of making millions of files.
This is hard to say since I do not know the underlying problem, but in
general you can solve this with a good designed database.

Hope that helps,

Regards,
Erwin Moller


消息ID:< 44 ********************** @ news.xs4all。 nlfrom Erwin Moller

包含以下内容:
Message-ID: <44**********************@news.xs4all.nlfrom Erwin Moller
contained the following:

>一个简单的方法:
(Postgresnotation,而不是我避免的mySQL)
>A simple approach:
(Postgresnotation, not mySQL which I avoid)



上次我检查了它mysql用于tinyurl.com

http://tinyurl.com/

-

Geoff Berrow(放thecat发送电子邮件)

它只是Usenet,没有人死。

我的意见,不是委员会的,我的。

简单RFD http://www.ckdog.co.uk/rfdmaker/


这篇关于一个文件夹中有1到2百万个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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