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