开发者

Postgres hashing user defined types

Note: m4 is being u开发者_如何学编程sed so "_" prefixed strings are expanded (m4 is a macro pre-processor similar to the c preprocessor).

My Type:

CREATE TYPE UrlPair AS (                                                      
    HostName        varchar( _LIMIT_HOSTNAME ),                               
    ScriptName      varchar( _LIMIT_SCRIPTNAME )                              
);

Used in

CREATE TABLE SymbolTable_UrlPair (
    Symbol          _BIG_SYMBOL_SERIAL_TYPE     PRIMARY KEY,
    UrlPair         UrlPair                     
);

With index

CREATE INDEX SymbolTable_UrlPair_UrlPair 
    ON SymbolTable_UrlPair USING hash (UrlPair);

Gives:

psql:script:32: ERROR:  data type urlpair has no default operator class 
for access method "hash"

HINT:  You must specify an operator class for the index or define a default 
operator class for the data type.

Question

Ideally I would like the engine to concatinate the strings and use that for a hash. However, I am not fussy. Could someone show me the syntax for declaring this "Operator Class" for the access method hash.

I would have expected some default hashing behaviour for user defined types. I would really preffer to keep the type -- i.e., I don't want to expand it, as I will probably define a few more elaborate UDT's.


Hashing and a hash index are two different things. Hash indexes don't support a multi column index, that might be the problem, your type UrlPair is multi value.

What's wrong with a Btree-index? What problem do have to solve?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜