Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fA9Fs3m95979 for ; Fri, 9 Nov 2001 10:54:03 -0500 (EST) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.7) with HTTP id 502469; Fri, 09 Nov 2001 07:54:05 -0800 From: "Josh Berkus" Subject: Re: Optimizing To: "Jeff Sack" , X-Mailer: CommuniGate Pro Web Mailer v.3.4.7 Date: Fri, 09 Nov 2001 07:54:05 -0800 Message-ID: In-Reply-To: <003301c168a0$034d53e0$019ca8c0@jeff> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200111/145 X-Sequence-Number: 5529 Jeff, > Hello all. I have an academic project that I'm working on and, as > I'm > relatively new to optimization techniques and database design, I'm > wondering if some of you can give me some pointers. See the PostgreSQL book review page: http:\\techdocs.postgresql.org\bookreviews.php There, you will find reviews of several good books on database design. > There are several interesting queries that I've been constructing > just > to get a feel for this schema, and given that some of these tables > contain 100,000-200,000 tuples, some queries are taking a good 5-10 > seconds to execute. I'm just wondering if this is simply the fault > of > my schema or are these queries poorly constructed? That entirely depends. If you're doing this on a 3-year-old laptop, 5-10 seconds is a *good* time. But not on a Proliant 9000. Here's the rules of indexing: 1. All JOIN columns should be indexed. 2. All criteria (WHERE) columns should be indexed, except those that have a very limited range of values (e.g. BOOLEAN). 3. All ORDER BY columns should be indexed, with the same exception. 4. Multi-column indexes are seldom useful for queries. 5. VACUUM should be performed regularly. 6. If SELECT is very fast and INSERT is very slow, try removing a few indexes. Also, you can muck around with runtime settings to you heart's content, and moving the log files (pgsql/data/xlog) to a seperate drive improves performance. There are no quick answers once you've taken the basic steps. -Josh ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco