Re: Very puzzling sort behavior

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com>
Cc: Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PG-General Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Very puzzling sort behavior
Date: 2015-09-10 21:02:37
Message-ID: 20150910210237.GR2912@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ken Tanzer wrote:

> Are there any other potential solutions, pitfalls or considerations that
> come to mind? Any thoughts welcome. And as I said, if there's not a good
> way to do this I'll probably leave it alone.

In part, it boils down to what you use the in ORDER BY clause. If you
concatenate the last name and first name, they will be considered as a
single string and run afoul of funny behavior of dictionary sorting,
which ignores non-alphanumeric chars in the first pass. But if you keep
them separate by using "ORDER BY last_name, first_name" then sorting
will consider the last name separately from first name, and you'd get
the results you want (I think).

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ken Tanzer 2015-09-10 21:54:31 Re: Very puzzling sort behavior
Previous Message Ken Tanzer 2015-09-10 20:49:18 Re: Very puzzling sort behavior