Re: type design guidance needed

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Brook Milligan <brook(at)biology(dot)nmsu(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: type design guidance needed
Date: 2000-09-23 05:41:22
Message-ID: 994.969687682@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Brook Milligan <brook(at)biology(dot)nmsu(dot)edu> writes:
> Along with each data item, I must keep additional information about
> the scale of measurement. Further, the relevant scales of measurement
> fall into a few major families of related scales, so at least a
> different type will be required for each of these major families.
> Additionally, I wish to be able to convert data measured according to
> one scale into other scales (both within the same family and between
> different families), and these interconversions require relatively
> large sets of parameters.

It'd be useful to know more about your measurement scales. Evgeni
remarks that for his applications, units can be broken down into
simple linear combinations of fundamental units --- but if you're
doing something like converting between different device-dependent
color spaces, I can well believe that that model wouldn't work...

> - How much of an overhead is introduced by requiring the backend to
> query system tables during tuple processing? Is this unacceptable
> from the outset or is it reasonable to consider this option further?

Assuming that the scale tables are not too large and not frequently
changed, the ideal access mechanism seems to be the "system cache"
mechanism (cf src/backend/utils/cache/syscache.c,
src/backend/utils/cache/lsyscache.c). The cache support allows each
backend to keep copies in memory of recently-used rows of a cached
table. Updating a cached table requires rather expensive cross-
backend signaling, but as long as that doesn't happen often compared
to accesses, you win. The only real restriction is that you have to
look up cached rows by a unique key that corresponds to an index, but
that seems not to be a problem for your application.

Adding a new system cache is a tad more invasive than the usual sort of
user-defined-type addition, but it's certainly not out of the question.
Bruce Momjian has done it several times and documented the process,
IIRC.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marko Kreen 2000-09-23 13:59:06 Re: [patch,rfc] binary operators on integers
Previous Message Evgeni E. Selkov 2000-09-23 04:41:41 Re: type design guidance needed