network address query

From: Litao Wu <litaowu(at)yahoo(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: network address query
Date: 2004-07-01 16:12:47
Message-ID: 20040701161247.98527.qmail@web13122.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi,

I have query:
explain
SELECT *
FROM ip_tracking T, ip_map C
WHERE
T.source_ip::inet >>= C.net;
QUERY PLAN
-------------------------------------------------------------------------------------------
Nested Loop (cost=0.00..3894833367750.16
rows=51709297065144 width=111)
Join Filter: ("outer".source_ip >>=
("inner".net)::inet)
-> Seq Scan on ip_tracking t
(cost=0.00..825050.68 rows=31093368 width=34)
-> Seq Scan on ip_map c (cost=0.00..83686.66
rows=3326066 width=77)
(4 rows)

ip_tracking (
pk_col int,
source_ip inet,
.. the rest...
)
There is one index
ip_tracking_ip_idx btree (source_ip)

ip_map (
net cidr,
... the rest...)
Indexes: map_net_idx hash (net)

If I change ">>=" to "=", the query plan is:

QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------
Nested Loop (cost=0.00..10798882243.63 rows=31093368
width=111)
-> Seq Scan on ip_map c (cost=0.00..83686.66
rows=3326066 width=77)
-> Index Scan using ip_tracking_ip_idx on
ip_tracking t (cost=0.00..3236.72 rows=800 width=34)
Index Cond: (t.source_ip =
("outer".net)::inet)
(4 rows)

This is my first time to deal network address type.

Is it possible to make a query use index with
operator of ">>=" like the above?

Thanks,


__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Dennis Bjorklund 2004-07-01 20:44:22 Re: Query gets slow when where clause increases
Previous Message Joseph Shraibman 2004-07-01 03:14:58 planner and worst case scenario