Re: On using doubles as primary keys

Поиск
Список
Период
Сортировка
От Melvin Davidson
Тема Re: On using doubles as primary keys
Дата
Msg-id CANu8Fix173cyMOoAt5XrHBV2Kd78R9RkY_jkRHoQcty6E89PUA@mail.gmail.com
обсуждение исходный текст
Ответ на On using doubles as primary keys  (Kynn Jones <kynnjo@gmail.com>)
Ответы Re: On using doubles as primary keys  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
First, please ALWAYS include the version and O/S, even with basic questions.

I'm not sure what you mean by doubles. Do you mean bigint data type, or do you mean use two columns for a primary key? Either way it's pretty simple.
If you mean a bigint, then probably best to use serial data type, which will default to the next value.
If you mean use two columns for a Primary Key, the you just specify the columns.
EG: CONSTRAINT PRIMARY KEY table_name_pk PRIMARY KEY (col1, col2)


On Fri, Apr 17, 2015 at 11:34 AM, Kynn Jones <kynnjo@gmail.com> wrote:
I have some data in the form of a matrix of doubles (~2 million
rows, ~400 columns) that I would like to store in a Pg table,
along with the associated table of metadata (same number of rows,
~30 columns, almost all text).  This is large enough to make
working with it from flat files unwieldy.

(The only reason for wanting to transfer this data to a Pg table
is the hope that it will be easier to work with it by using SQL
queries to extract subsets of it, than by, e.g., writing programs
that must scan the entire matrix every time they're run.)

My plan is to add one extra column to the Pg tables to serve as
the primary key joining the data and the metadata tables
together.

One consideration that is complication the choice of primary key
is wanting to have the ability to store chunks of the data
table (not the metadata table), including the PK column, as
matrices of doubles.  In its simplest form, this would mean using
doubles as primary keys, but this seems to me a bit weird.

I'm willing to go ahead with this, but I wanted to ask for your
feedback on the whole thing.  In particular I'd like to know if
there are there standard ways for using doubles as primary keys,
and, conversely, if there are known pitfalls I should be looking
out for, but I welcome any other words of wisdom you may have on
this topic.

Thanks in advance!

kj


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



--
Melvin Davidson
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.

В списке pgsql-general по дате отправления:

Предыдущее
От: Kynn Jones
Дата:
Сообщение: On using doubles as primary keys
Следующее
От: Jeff Janes
Дата:
Сообщение: Re: Waiting on ExclusiveLock on extension