X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A8492D1BA62 for ; Thu, 24 Jun 2004 17:43:19 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 98664-04 for ; Thu, 24 Jun 2004 20:43:13 +0000 (GMT) Received: from mproxy.gmail.com (mproxy.gmail.com [216.239.56.252]) by svr1.postgresql.org (Postfix) with SMTP id D1CBAD1B7CF for ; Thu, 24 Jun 2004 17:43:09 -0300 (ADT) Received: by mproxy.gmail.com with SMTP id u22so175623cwc for ; Thu, 24 Jun 2004 13:43:08 -0700 (PDT) Received: by 10.38.76.40 with SMTP id y40mr21559rna; Thu, 24 Jun 2004 13:43:08 -0700 (PDT) Message-ID: Date: Thu, 24 Jun 2004 13:43:08 -0700 From: Georgos Siganos To: pgsql-sql@postgresql.org Subject: Question about a CIDR based query Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/242 X-Sequence-Number: 18187 Hello, Consider that I have the following table: Create Table tmp( =A0 =A0 =A0 =A0 =A0 =A0 route_id =A0 =A0 int =A0 =A0NOT NULL, =A0 =A0 =A0 =A0 =A0 =A0 route =A0 =A0 =A0 =A0 cidr =A0 NOT NULL, =A0 =A0 =A0 =A0 =A0 =A0 Data =A0 =A0 =A0 =A0 varchar(100) NOT NULL) The table contains ~40,000 routes and I have an index on route. The query I am interested in is: select * from tmp where route >>=3D some_cidr The index on route is not used and I get a sequential scan. The index is=20 used only for the <<=3D operator. Any idea how I can make the query run faster? Thanks, George