X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 58240D1B45B for ; Fri, 6 Feb 2004 06:30:20 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 54900-08 for ; Fri, 6 Feb 2004 02:30:17 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 108B7D1D283 for ; Fri, 6 Feb 2004 02:30:16 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i166UFmL024650; Fri, 6 Feb 2004 01:30:15 -0500 (EST) To: Steve Lane Cc: pgsql-admin@postgresql.org Subject: Re: Index (re)-creation speed In-reply-to: References: Comments: In-reply-to Steve Lane message dated "Thu, 05 Feb 2004 22:36:52 -0600" Date: Fri, 06 Feb 2004 01:30:15 -0500 Message-ID: <24649.1076049015@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/70 X-Sequence-Number: 12244 Steve Lane writes: > When I drop and rebuild the indexes, they take oddly varying amounts of time > to rebuild. I rebuilt them in the following order, with the following rough > times. I took a guess that the speed of the rebuild might be related to the > number of distinct values in the column -- this seems true in some cases but > not in others. Here are the times: > id_response 38 secs (86000 distinct) > id_topic 33 secs (6 distinct) > id_survey 13 secs (1 distinct) > id_code 39 secs (1444 distinct) > id_item 40 secs (65 distinct) > id_administration 13 secs (1 distinct) How many rows altogether in this table? What sort_mem are you using (and have you tried altering it)? When I read your previous message I was wondering about different datatypes having different comparison costs, but since these are all integer columns that's clearly not the issue here. I think you may be seeing something related to the number of initial runs created in the sorting algorithm --- with only one distinct value, there'd always be just one run and no need for any merge passes. (Why are you bothering to index columns with only one or a few values in them, anyway? Such an index will be useless for searches ...) regards, tom lane