Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 19042632AFA for ; Sat, 11 Sep 2010 14:08:48 -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 96861-09 for ; Sat, 11 Sep 2010 17:08:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.gmx.net (mailout-de.gmx.net [213.165.64.22]) by mail.postgresql.org (Postfix) with SMTP id 806A56329C3 for ; Sat, 11 Sep 2010 14:08:40 -0300 (ADT) Received: (qmail 31191 invoked by uid 0); 11 Sep 2010 17:08:39 -0000 Received: from 62.12.131.152 by www052.gmx.net with HTTP; Sat, 11 Sep 2010 19:08:37 +0200 (CEST) Content-Type: text/plain; charset="utf-8" Date: Sat, 11 Sep 2010 19:08:37 +0200 From: "Steve" In-Reply-To: Message-ID: <20100911170837.240190@gmx.net> MIME-Version: 1.0 References: Subject: Re: Question regarding indices To: pgsql-sql@postgresql.org X-Authenticated: #26630975 X-Flags: 0001 X-Mailer: WWW-Mail 6100 (Global Message Exchange) X-Priority: 3 X-Provags-ID: V01U2FsdGVkX19fkK86OGBfhL3CinhQTjgo1RbuH/+2cm6Tnd3kNZ tVRAQDO41uLnk3Bep9nu4pdazlELgzipjPaQ== Content-Transfer-Encoding: 8bit X-GMX-UID: oo++eJgXRkkNfEsh5WVquCludWkvKNNu X-FuHaFi: 0.5 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-5 required=5 tests=BAYES_00=-1.9, HK_RANDOM_ENVFROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201009/27 X-Sequence-Number: 34558 -------- Original-Nachricht -------- > Datum: Sat, 11 Sep 2010 10:05:18 -0400 > Von: Michael Gould > An: Steve > Betreff: Re: [SQL] Question regarding indices > Steve, > Hello Michael, > If I remember correctly the sort only works on the final result set and so > doing a sort before the select isn't going to help > I think you got me wrong. It's not that I want the RESULT to be sorted. I only asked if sorting the values in the query would have an effect on the speed of the query. Or to ask it the other way around: Is an index in PostgreSQL sorted or not? If it is sorted and the PostgreSQL parser is looking for entries in the index then having the values pre-sorted would probably be beneficial. Right? // Steve > Sent from Samsung mobile > > Steve wrote: > > >Hello List, > > > >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? 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? > > > > > >// Steve > >-- > >GRATIS: Spider-Man 1-3 sowie 300 weitere Videos! > >Jetzt freischalten! http://portal.gmx.net/de/go/maxdome > > > >-- > >Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > >To make changes to your subscription: > >http://www.postgresql.org/mailpref/pgsql-sql -- GRATIS: Spider-Man 1-3 sowie 300 weitere Videos! Jetzt freischalten! http://portal.gmx.net/de/go/maxdome