Hi all: I write a use define type (UUID)
typedef struct uuid { uint32 time_low; uint16 time_mid; uint16 time_hi_and_version; uint8 clock_seq_hi_and_reserved; uint8 clock_seq_low; uint8 node[6]; } uuid;
make all btree index function and operator, such as
CREATE OPERATOR CLASS uuid_btree_ops
DEFAULT FOR TYPE uuid USING btree AS
OPERATOR 1 < ,
OPERATOR 2 <= ,
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
FUNCTION 1 uuid_cmp(uuid, uuid),
create table test_uuid(id uuid primary key default uuid_time(), name char(40));
but this query: select * from test_uuid where id = 'df2b10aa-a31d-11d7-9867-0050babb6029'::uuid dosn't use index
QUERY PLAN --------------------------------------------------------------- Seq Scan on test_uuid (cost=0.00..22.50 rows=500 width=140) Filter: (id = 'df2b10aa-a31d-11d7-9867-0050babb6029'::uuid)
why ??
source code see attachement
MikeWang
---------------------------------------------------------------------
What is uuid?
uuid is a kind of data type, provide for PostgreSQL to implement unique id in cyberspace,
it's based one UUID URN name space IETF draft (see doc/draft-mealling-uuid-urn-00.txt),
now, pguuid support NIL(0), Time-Base(1), Name-Base(3) and Random-Base(4) type UUID.
It's propuse is
provide a solution
for data replication, merge, and distribute.
what is the use of uuid?
1, pguuid provide PostgreSQL a data type: uuid, it can provide unique id in
cyberspace.
2, provide type uuid related operator (e.g. =, <>, <, >, >=, <=)
3, provide functions to generate Time-base, Name-base, Random-base and Nil-UUID.
4, provide functions to parse uuid type.
license: BSD
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
uuid-v2.0.1.0.tar.gz
Description: GNU Zip compressed data
---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly