Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id B03E45EC6B8 for ; Mon, 16 Jan 2012 05:32:42 -0400 (AST) Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rmive-0007SV-Cl for pgsql-bugs@postgresql.org; Mon, 16 Jan 2012 09:32:42 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RmivR-00018k-8F for pgsql-bugs@postgresql.org; Mon, 16 Jan 2012 09:32:26 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1RmivQ-0001Mv-VJ for pgsql-bugs@postgresql.org; Mon, 16 Jan 2012 09:32:24 +0000 Date: Mon, 16 Jan 2012 09:32:24 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6399: knngist sometimes returns tuples in incorrect order To: pgsql-bugs@postgresql.org From: yamt@mwd.biglobe.ne.jp X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201201/119 X-Sequence-Number: 32186 The following bug has been logged on the website: Bug reference: 6399 Logged by: YAMAMOTO Takashi Email address: yamt@mwd.biglobe.ne.jp PostgreSQL version: Unsupported/Unknown Operating system: NetBSD Description: = 9.2devel (01d83ffdcae92f75dbfd41de0b4213d241edd394) knngist seems to assume that any distances can be represented with float8. at least distances between int8 values can not. the following example uses btree_gist extension. results should be the same regardless of the existance of the index. create temp table t (a int8); insert into t values (9223372036854775806),(9223372036854775807); select *,0<->a as dist from t order by dist; create index on t using gist (a); set enable_seqscan=3Doff; select *,0<->a as dist from t order by dist; CREATE TABLE INSERT 0 2 a | dist = ---------------------+--------------------- 9223372036854775806 | 9223372036854775806 9223372036854775807 | 9223372036854775807 (2 rows) CREATE INDEX SET a | dist = ---------------------+--------------------- 9223372036854775807 | 9223372036854775807 9223372036854775806 | 9223372036854775806 (2 rows)