Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 1C72C633246 for ; Sat, 11 Sep 2010 15:22:19 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 34867-06 for ; Sat, 11 Sep 2010 18:22:11 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 4BD6A63296A for ; Sat, 11 Sep 2010 15:22:11 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o8BIM8Mk020433; Sat, 11 Sep 2010 14:22:08 -0400 (EDT) To: "Steve" cc: pgsql-sql@postgresql.org Subject: Re: Question regarding indices In-reply-to: <20100911172332.240150@gmx.net> References: <20100911122923.75010@gmx.net> <17448.1284217456@sss.pgh.pa.us> <20100911172332.240150@gmx.net> Comments: In-reply-to "Steve" message dated "Sat, 11 Sep 2010 19:23:32 +0200" Date: Sat, 11 Sep 2010 14:22:08 -0400 Message-ID: <20432.1284229328@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201009/29 X-Sequence-Number: 34560 "Steve" writes: >> Von: Tom Lane >> It's unlikely to make enough difference to be worth the trouble. >> > Making a quick sort is ultra easy in C. Anyway... is there a > difference in the speed of the query with pre-sorted values or not? > If there is one then I will go and sort the values. I didn't opine on whether it was "easy" or not. I said it was unlikely to be worth the trouble. You could very well spend more time sorting the values than you buy in whatever you might save on the server side. Each value in the IN list is going to require a separate index probe. The sorting might buy something in locality of reference for successive probes, but most likely not enough to notice. regards, tom lane