Re: Some indexing advice for a Postgres newbie, please?

From: brian <brian(at)meadows(dot)pair(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Some indexing advice for a Postgres newbie, please?
Date: 2015-02-19 17:19:20
Message-ID: 8i6cea5vnpi2b3124tkod45rgfsh7c7f7h@4ax.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 19 Feb 2015 09:30:57 -0700, you wrote:

>On 02/19/2015 09:10 AM, brian wrote:
>> Hi folks,
>>
>> I have a single-user application which is growing beyond the
>> fixed-format data files in which it currently holds its data, I need a
>> proper database as the backend. The front end is written using Lazarus
>> and FreePascal under Linux, should anyone feel that makes a
>> difference. The database will need to grow to around 250,000 records.
>>
>> My problem is with the data field which is the (unique) key. It's
>> really a single 192-bit integer (it holds various bits of bitmapped
>> data) which I currently hold as six 32-bit integers, but can convert
>> if needed when transferring the data.
>>
>> How would you advise that I hold this field in a Postgres database,
>> given the requirement for the whole thing to be a unique key? The
>> first 64 bits change relatively infrequently, the last 128 bits will
>> change with virtually every record. The last 128 bits will ALMOST be
>> unique in themselves, but not quite. :(
>>
>> Thanks,
>>
>> Brian.
>>
>>
>If your application understands/parses/makes use of the data in those
>192 bites, I would reload with an additional unique id field. For the
>intended number of rows of data a sequence would be fine, though I'm
>partial to UUIDs. Alternatively map the 192 bytes to two fields and make
>a unique key of both of them. Third alternative would be to use a binary
>BitString a suggested by Brian.

Thanks. The purpose of the field is purely as a check against the user
feeding the same data in twice. Once I've constructed it, I never pull
the field apart again. It had to be done this way, as otherwise the
boolean statement to check for uniqueness was horrendous.

Brian.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2015-02-19 18:15:57 Re: Some indexing advice for a Postgres newbie, please?
Previous Message Adrian Klaver 2015-02-19 16:44:35 Re: Issue dumping schema using readonly user