Re: match an IP address

From: "Phoenix Kiula" <phoenix(dot)kiula(at)gmail(dot)com>
To: "PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: match an IP address
Date: 2008-09-23 00:26:15
Message-ID: e373d31e0809221726u55ae750dw69ecafb2b450b3e2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> > I think this is common DB design on many websites that have registered
> > user IDs.
> >
>
> Is it? Name one! Sounds like crappy design to me.
>

It might sound crappy design to you, but for websites that allow users
to do something while they are registered OR unregistered, will choose
to have this for query speed. (Registered user goes in as "testuser"
while an unregistered one goes as his IP address--some websites also
use cookies but they're less reliable.)

We can make this very relationally sound and whatnot, but having one
field to go to, whether you are registered or not, makes it much
simpler.

Most websites have to allow for dots in their user ID these days as
people prefer to have their email address as user ID. Which means that
the dot checking of an IP address may not work to distinguish IP
addresses (unregistered user) from registered user IDs.

In this scenario, for query speed, again, if there is a column that
tells us whether this user is registered or not it helps a great deal.
The INET match condition is not good enough for speed for most modern
websites with any sizeable traffic. I even wrote a function that
converts IP to INET integer and vice versa, but no great boost in
query speed that could compare to an indexed query on user_id and
user_reg.

Welcome your thoughts on how you would do it.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dale Harris 2008-09-23 01:26:13 Re: Triggers not working
Previous Message Tino Wildenhain 2008-09-23 00:19:23 Re: match an IP address