Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id B405F6326CD for ; Sat, 11 Sep 2010 12:23:56 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 66657-06 for ; Sat, 11 Sep 2010 15:23:49 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id 7900263269C for ; Sat, 11 Sep 2010 12:23:49 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id o8BFNmf3039253 for ; Sat, 11 Sep 2010 12:23:48 -0300 (ADT) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id o8BF7wqG031307 for pgsql-sql@postgresql.org; Sat, 11 Sep 2010 12:07:58 -0300 (ADT) (envelope-from news) From: Lew X-Newsgroups: pgsql.sql Subject: Re: Question regarding indices Date: Sat, 11 Sep 2010 11:08:00 -0400 Organization: albasani.net Lines: 26 Message-ID: References: <20100911122923.75010@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit In-Reply-To: <20100911122923.75010@gmx.net> Cancel-Lock: sha1:gdTDgpE4dTSpXHXuxFXaJu3dskI= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100826 Thunderbird/3.0.7 Injection-Info: news.albasani.net; logging-data="JFQfwuubQzr2/2MpzX2dWmy7PquOnyP0BgQp8oploYB50IRuEFAJ3UR8xPae2r0UjIxb3bBAyLjj38ocmifjE+Miz9plo8LHUafzgSZ/parsGsPXEwH4S13id3YzVph7"; mail-complaints-to="abuse@albasani.net" To: pgsql-sql@postgresql.org 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/32 X-Sequence-Number: 34563 On 09/11/2010 08:29 AM, Steve wrote: > I have a small question about the order of values in a query. > Assume I have a table with the following fields: > uid INT, > data BIGINT, > hits INT > And an unique index on (uid, data). I use libpq C API to query > data from the table. The query is something like this: > SELECT uid,data,hits FROM mytable WHERE uid=2 > AND data IN (2033,2499,590,19,201,659) > > Would the speed of the query be influenced if I would sort the data? What do you mean by "sort the data"? Which data? > I can imagine that just querying a bunch of bigint would not make a > big difference but what about several thousand of values? Would sorting > them and sending the SQL query with ordered data influence the speed of the query? Send the query from where to where? Are you referring to a sort of the items in the IN subselect? My guess is that sorting that won't matter but it's only a WAG. -- Lew