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 4E746D1B187 for ; Sat, 26 Jun 2004 20:13:53 -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 12847-05 for ; Sat, 26 Jun 2004 23:13:51 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id BBF9FD1B7D8 for ; Sat, 26 Jun 2004 20:13:47 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i5QNDlQC029509 for ; Sat, 26 Jun 2004 23:13:47 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i5QN6CKm027260 for pgsql-sql@postgresql.org; Sat, 26 Jun 2004 23:06:12 GMT From: siganos@gmail.com (George Siganos) X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Question about a CIDR based query Date: 26 Jun 2004 16:06:15 -0700 Organization: http://groups.google.com Lines: 35 Message-ID: References: <200406250900.08312.josh@agliodbs.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: groups-abuse@google.com To: pgsql-sql@postgresql.org 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/268 X-Sequence-Number: 18213 I did a vacuum analyze before I run the following explain June_03=# explain select * from tmp where route >>='62.1.1.0/24'; QUERY PLAN ---------------------------------------------------------------- Seq Scan on tmp (cost=0.00..606.60 rows=14544 width=33) Filter: (route >>= '62.1.1.0/24'::cidr) (2 rows) The select returns just one route, Thanks josh@agliodbs.com (Josh Berkus) wrote in message news:<200406250900.08312.josh@agliodbs.com>... > Georgos, > > > select * from tmp where route >>= some_cidr > > Can you post an EXPLAIN ANALYZE for this? And when's the last time you ran > ANALYZE on the table? > > > The index on route is not used and I get a sequential scan. The index is > > used only for the <<= operator. > > Most likely Postgres thinks that the >>= query is returning 60% of your table, > which makes indexes useless. > > -- > Josh Berkus > Aglio Database Solutions > San Francisco > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html