Re: group by points

From: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
To: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: group by points
Date: 2006-05-22 08:23:28
Message-ID: 52EF20B2E3209443BC37736D00C3C13808857936@EXADV1.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Jaime Casanova wrote:
> suppose we have something like this:
>
> upd_views=# create table tabla1 (col1 point);

[...]

> then, this select will give an error:
>
> upd_views=# select col1, count(*) from tabla1 group by col1;
> ERROR: could not identify an ordering operator for type point
> HINT: Use an explicit ordering operator or modify the query.
> upd_views=#
>
> i guess this is related to:
> http://archives.postgresql.org/pgsql-hackers/2003-08/msg00809.php
>
> so, what happened with this idea? there is another way to automagicaly
> identify an "equality operator" for datatypes like 'point'?

I don't think that there is a connection to the message you quote.

In order to (efficiently) process a GROUP BY clause, you need a
total ordering on the data type that you group by, i.e. an ordering
such that for any two data x and y you have either x < y or x > x
or x = y.

There is no reasonable total ordering on the real plain, so you will
have to roll your own. How about:

select point(col1[0], col1[1]), count(*) from tabla1 group by col1[0],
col1[1];

Yours,
Laurenz Albe

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2006-05-22 10:17:33 Duplicate definition of LOCALEDIR
Previous Message Martijn van Oosterhout 2006-05-22 07:05:26 Re: SSL certificate info on SQL level and HSM support for libpq