pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Eckermann <jeckermann@verio.net>
To: 'Frank Bax' <fbax@sympatico.ca>
To: pgsql-sql@postgresql.org
Subject: RE: Order by email address by domain ?
Date: Fri, 11 May 2001 09:35:39 -0500
Message-ID: <08CD1781F85AD4118E0800A0C9B8580B094A79@NEZU> (raw)

???
I don't think anyone suggested adding a new builtin function.
Yes, your suggestion is good for an occasional use.
Where this kind of functionality is likely to be needed on a continuing
basis, my experience is that wrapping the code up in a custom function is
easier and cleaner than writing it out every time.  Saves a lot of typing,
not to mention the risk of typos (which could give spurious results without
being obvious about it).  Also, a function allows for indexing on that
value, which can be a great aid to performance.
I have found that sometimes it is better to just add a column or two to the
table to contain the needed key, because with large amounts of data that can
be much quicker.  Doing this too much though can lead to a cluttered
database, and a loss of clarity about just what all of those extra fields
are for...  It's a judgement call.
Just my $0.01 (That's $0.02 Australian :-))

> -----Original Message-----
> From:	Frank Bax [SMTP:fbax@sympatico.ca]
> Sent:	Thursday, May 10, 2001 8:53 PM
> To:	pgsql-sql@postgresql.org
> Cc:	herve@elma.fr
> Subject:	Re: Order by email address by domain ?
> 
> Why is everyone else suggesting new functions?  This works (in 6.5.3):
> 
>    ORDER BY lower(substring(email from position('@' in email)+1 )),
> lower(email)
> 
> remove the lower() functions if you don't need them (I had mixed case
> addresses).
> 
> I am guessing/assuming that it's cheaper to just use entire email address
> in second key rather than extract before the '@' character.
> 
> Frank
> 
> At 08:37 PM 5/10/01 +0200, you wrote:
> >Hi,
> >
> >I just want to order by a listing of email address by domain like :
> >
> >toto@aol.com
> >tutu@aol.com
> >toto@be.com
> >tutu@be.com
> >toto@yahoo.com
> >
> >Is it possible and how ?
> >
> >Thanks !
> >-- 
> >Hervé Piedvache
> >
> >Elma Ingenierie Informatique
> >6, rue du Faubourg Saint-Honoré
> >F-75008 - Paris - France 
> >http://www.elma.fr
> >Tel: +33-1-44949901
> >Fax: +33-1-44949902 
> >Email: herve@elma.fr
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 6: Have you searched our list archives?
> >
> >http://www.postgresql.org/search.mpl
> >
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html



view thread (6+ messages)

Message-ID: <08CD1781F85AD4118E0800A0C9B8580B094A79@NEZU>
Permalink:  ../08CD1781F85AD4118E0800A0C9B8580B094A79@NEZU/
Also on:    postgresql.org/message-id/08CD1781F85AD4118E0800A0C9B8580B094A79@NEZU

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jeckermann@verio.net, fbax@sympatico.ca
  Subject: Re: Order by email address by domain ?
  In-Reply-To: <08CD1781F85AD4118E0800A0C9B8580B094A79@NEZU>
  References: <08CD1781F85AD4118E0800A0C9B8580B094A79@NEZU>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox