X-Original-To: pgsql-novice@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 510B3474E61 for ; Thu, 13 Feb 2003 10:45:47 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B0F78474E4F for ; Thu, 13 Feb 2003 10:45:46 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h1DFjc5u013514; Thu, 13 Feb 2003 10:45:38 -0500 (EST) To: HK Cc: pgsql-novice@postgresql.org Subject: Re: accessing primary key slower than accessing non primary key??? In-reply-to: References: Comments: In-reply-to HK message dated "Thu, 13 Feb 2003 19:29:25 +0530" Date: Thu, 13 Feb 2003 10:45:37 -0500 Message-ID: <13513.1045151137@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/161 X-Sequence-Number: 6177 HK writes: > time in ms per query retrieval > py key non py key > ------ ----------- > 2000 15.8 15.7 > 10000 71.2 70.7 > 25000 174 173.5 > 100000 4319 3417 > As u see the non primary key retrieval is faster. AFAIK accessing primary > key should be faster. Can anybody throw light on why is this anamoly. There's nothing magic about primary keys in Postgres; I'd expect the results to come out the same. The first three of these look like they're indeed the same, to within measurement error. Not sure about the last one; perhaps you had some effect of physical order in the table agreeing with the ordering of the non-primary key? regards, tom lane