Re: slow inet within cidr query - Mailing list pgsql-general

From Steve Atkins
Subject Re: slow inet within cidr query
Date
Msg-id 9CA9E0B1-469C-41B9-8A66-F13A1F9D21C6@blighty.com
Whole thread Raw
In response to slow inet within cidr query  ("Edwin Grubbs" <edwin.grubbs@gmail.com>)
List pgsql-general
On Nov 28, 2006, at 12:07 PM, Edwin Grubbs wrote:

> Under postgres 8.1, the "<<=" comparison yields very slow queries
> with large tables. I can rewrite the query without the "<<="
> operator by generating all 33 possible netmasks (0 through 32) for
> a given IP. This ugly rewrite runs about 12 times faster (6 seconds
> versus 0.5 seconds). Be aware that EXPLAIN ANALYZE seems to be run
> a different query plan since the first query runs even slower with
> EXPLAIN ANALYZE. Setting enable_seqscan did not improve the query
> speed.

GiST opclasses for inet to make <<= indexable would be nice,
but I don't think anyones done them yet.

Depending on exactly what you're doing you might want to look at
http://pgfoundry.org/projects/ip4r and see if that'll do what you need.
It's not a drop-in replacement, though, so would be a pain to use
with existing code.

Cheers,
   Steve



pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: backend crash following load command
Next
From: Scott Ribe
Date:
Subject: Re: NULLs ;-)