From: Chris Gehlker Date: 2002-06-20T13:29:10+09:00 Subject: Re: Are Unix tools just slow? On 6/19/02 1:26 PM, "Christopher Browne" wrote: > In an attempt to throw the authorities off his trail, Chris Gehlker > transmitted: >> On 6/17/02 11:36 AM, "Christopher Browne" wrote: >>> If an SQL database is being used, then perhaps the _filesystem_ >>> doesn't have to get traversed, but that certainly doesn't eliminate >>> the need to traverse the _database_. >> >> But the difference is the difference between accessing *one* file and >> accessing *every* file. That's tremendous. > > But that's _not_ the difference. > > A "find" command does _not_ read every file. It reads a database > containing metadata about the files. It does not read the contents of > those files. This may be true for your system. That was the original question and it still remains unanswered for whatever system you are using. It is not true for NetBSD, and MacOS X. If you doubt this assertion, check the source. Find is literally reading directories. On both these systems, the disk will be continually accessed the first time find executes. Find also executes, the first time, slowly, on the order of a minute. The find function in Windows seems to operate the same way in terms of being slow and continually accessing the disk. > Change that to a SQL query, and it changes _insubstantially_ to > walking through the set of database blocks that contain 17,000 > directory entries containing the metadata for those 17,000 files. > > The only crucial difference between those approaches is that the data > may be somewhat more compact in an SQL database. Otherwise, there is > no reason to expect _any_ difference in overall behaviour. RDBMSes > are commonly implemented as B-Trees. Filesystem directory structures > are also commonly implemented as B-Trees. Not a difference. This depends entirely on the file system. There are systems where a directory is just a node in a tree. There are other systems in which the directories are just special files that are actually stored in disk sectors like any other file. In these latter systems, walking the file system will involve opening, reading and closing each directory which in turn involves moving heads and waiting for the disk to revolve. -- Tact is the ability to describe others as they see themselves. -Abraham Lincoln, 16th president of the U.S (1809-1865)