Re: What are the characteristics of a good user-defined data type?

From: David Fetter <david(at)fetter(dot)org>
To: Tim Hart <tjhart(at)mac(dot)com>
Cc: 'Tom Lane' <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org
Subject: Re: What are the characteristics of a good user-defined data type?
Date: 2006-06-07 22:05:58
Message-ID: 20060607220558.GB31183@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jun 07, 2006 at 12:57:15PM -0500, Tim Hart wrote:
> Could custom types benefit significantly from custom operators as
> well?

Yes.

> Do custom C functions stand a good chance of introducing speed
> benefits over their raw SQL or pl/sql counterparts? Or is the field
> too broad to speculate on the general case?

Generally, it's too broad to say. Note also that programmer time is a
valuable resource and CPU time is cheap.

> The scenario that inspired this question was about data that had to
> be stored accurately, but the data itself wasn't usually precise.
> You could think of an individual datum being a set of ranges. You
> could definitely define equality on this data type, but the ordering
> operators would probably be meaningless.

Right. Just don't define a < or > operator, but do define an =
operator on the type :)

> On the other hand, some (but not all) of the geometric operators could
> probably be interpreted to apply to this data set, as long as you ignore the
> 'above' and 'below' semantics, and replace the concepts of left and right
> with less than and greater than. So for example, while
>
> << (is strictly left of)
>
> Wouldn't make sense, using the same operator to mean 'strictly less than'
> might.
>
> Would R-tree indexes be useful for a data type like this? Would it
> be possible to define the base type such that an R-tree index would
> always be created?

Kinda depends on what you're doing.

> Once again - this is entirely idle curiosity. This isn't anything I
> have a real need for.

You might some day. One of PostgreSQL's Killer Features(TM) is its
radical extensibility.

Cheers,
D
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
phone: +1 415 235 3778 AIM: dfetter666
Skype: davidfetter

Remember to vote!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message tom.darci 2006-06-07 23:24:02 Re: SessionID, pretty please
Previous Message Tom Lane 2006-06-07 21:42:26 Re: COLLATE