From owner-freebsd-questions@FreeBSD.ORG Fri May 30 01:30:50 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 481B537B404 for ; Fri, 30 May 2003 01:30:48 -0700 (PDT) Received: from cfcl.com (cpe-24-221-172-174.ca.sprintbbd.net [24.221.172.174]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2797543F75 for ; Fri, 30 May 2003 01:30:48 -0700 (PDT) (envelope-from rdm@cfcl.com) Received: from [192.168.254.205] ([192.168.254.205]) by cfcl.com (8.12.6/8.11.1) with ESMTP id h4U8WX2o004145 for ; Fri, 30 May 2003 01:32:34 -0700 (PDT) (envelope-from rdm@cfcl.com) Mime-Version: 1.0 Message-Id: In-Reply-To: References: X-Mailer: Eudora for Macintosh! Date: Fri, 30 May 2003 01:30:26 -0700 To: freebsd-questions@freebsd.org From: Rich Morin Content-Type: text/plain; charset="us-ascii" ; format="flowed" Subject: Re: About reading and writing to files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 May 2003 08:30:50 -0000 At 3:04 AM -0500 5/30/03, Bingrui Foo wrote: >I'm wondering in freeBSD, if I have a directory with 10,000 files, or >maybe even 100,000 files, each about 5 kb long. Wondering will reading and >writing to any one of these files in C be affected by the sheer number of >these files? Will the access time be affected significantly? > >Just wondering because not sure whether I should put these data in a >database or just use files with unique names. > >Also will separating the files into many directories help? Looking up .../x/12/34/56 can be done in logarithmic time (i.e., look up .../x/12, then .../x/12/34, then .../x/12/34/56); looking up .../y/123456 (unless some optimization has been added) will require a linear scan through the directory. In short, don't go there... -r -- email: rdm@cfcl.com; phone: +1 650-873-7841 http://www.cfcl.com/rdm - my home page, resume, etc. http://www.cfcl.com/Meta - The FreeBSD Browser, Meta Project, etc. http://www.ptf.com/dossier - Prime Time Freeware's DOSSIER series http://www.ptf.com/tdc - Prime Time Freeware's Darwin Collection