Re: slow inet within cidr query

From: Steve Atkins <steve(at)blighty(dot)com>
To: PgSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: slow inet within cidr query
Date: 2006-11-28 21:45:08
Message-ID: 9CA9E0B1-469C-41B9-8A66-F13A1F9D21C6@blighty.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-11-28 21:46:12 Re: backend crash following load command
Previous Message Ragnar 2006-11-28 21:38:59 Re: NULLs ;-)