a problem with index and user define type - Mailing list pgsql-hackers

From Wang Mike
Subject a problem with index and user define type
Date
Msg-id BAY4-F33Kh4TtnrAIaA00009b05@hotmail.com
Whole thread Raw
Responses Re: a problem with index and user define type  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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

Attachment

pgsql-hackers by date:

Previous
From: "Andrew Dunstan"
Date:
Subject: Re: Two weeks to feature freeze
Next
From: Bruce Momjian
Date:
Subject: Re: Two weeks to feature freeze