Search Postgresql Archives

Re: UUID column as pimrary key?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've been enjoying this discussion, but it seems to me there are two 
possibilities that guarantee unique results, use less storage, and neither 
would use a UUID for the primary key.

The first would assume that only one machine is doing the work on the database. 
As has been pointed out earlier, in this case the simplest solution would be 
to simply use a series. As that is guaranteed unique on a single machine and 
is incredibly simple to implement.

Once multiple machines are linked to maintain the database, this has a flaw in 
it as a series is not guaranteed to be unique between machines (actually I 
think they're pretty well guaranteed *NOT* to be, but that's another issue. In 
that case, another field is needed as follows:

 	Create table test
	(  id serial,
	  machine_id integer,
	.....
	primary_key(machine_id, id);
	)

Each machine would have a unique machine_id. This would guarantee uniqueness 
and be very easy to maintain. In addition - *IF* it were ever necessary - it 
would be easy to determine which machine generated records.

OK, I'm probably going to regret jumping in here, but I couldn't resist.

Sorry

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux