Re: Best method to compare subdomains

From: Steve Atkins <steve(at)blighty(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Best method to compare subdomains
Date: 2013-01-16 22:45:17
Message-ID: FF38F9DD-BA8D-4309-BD35-1333DCD2D846@blighty.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jan 16, 2013, at 12:23 PM, Robert James <srobertjames(at)gmail(dot)com> wrote:

> Is there a recommended, high performance method to check for subdomains?
>
> Something like:
> - www.google.com is subdomain of google.com
> - ilikegoogle.com is not subdomain of google.com
>
> There are many ways to do this (lowercase and reverse the string,
> append a '.' if not there, append a '%', and do a LIKE). But I'm
> looking for one that will perform well when the master domain list is
> an indexed field in a table, and when the possible subdomain is either
> an individual value, or a field in a table for a join (potentially
> indexed).

If you've already dealt with any punycode encoding then the lowercased,
reversed string works pretty well, either as a (probably trigger-managed)
field or as a functional index.

If you need to get fancier, you might want to take a look at the approach
https://github.com/dimitri/prefix takes.

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Charles Porter 2013-01-16 23:06:41 pg_upgrade problem from 8.4 to 9.2 problems on OSX
Previous Message T. E. Lawrence 2013-01-16 22:42:23 Re: reducing number of ANDs speeds up query RESOLVED