Soy nuevo en los índices de floración. Me refiero al enlace https://habr.com/en/company/postgrespro/blog/452968/ para conocer los nuevos índices.
Cuando intentaba crear un índice de floración en la propia tabla de prueba, recibí el siguiente error:
SQL Error [42704]: ERROR: data type bigint has no default operator class for access method "bloom" Hint: You must specify an operator class for the index or define a default operator class for the data type.Sin duda, porque en mi tabla tengo una columna en la que uso el tipo de datos bigint y la misma columna que incluyo en la creación de mi índice.
Para evitar ese error, traté de crear mi propia clase para el tipo de datos bigint. Como abajo:
CREATE OPERATOR CLASS bigint_ops DEFAULT FOR TYPE int USING bloom AS OPERATOR 1 =(bigint,bigint), FUNCTION 1 hashbigint;y obtuve el siguiente error:
SQL Error [42883]: ERROR: could not find a function named "hashbigint"Cualquier ayuda para evitar este error será muy apreciada.
La función hash para bigint es hashint8 , no hashbigint . Encontré esto ejecutando la consulta en la publicación que vinculó y filtrando hasta donde el tipo es 'bigint'.
testdb=# with t0 as (select distinct opc.opcintype::regtype::text, amop.amopopr::regoperator, ampr.amproc from pg_am am, pg_opclass opc, pg_amop amop, pg_amproc ampr where am.amname = 'hash' and opc.opcmethod = am.oid and amop.amopfamily = opc.opcfamily and amop.amoplefttype = opc.opcintype and amop.amoprighttype = opc.opcintype and ampr.amprocfamily = opc.opcfamily and ampr.amproclefttype = opc.opcintype order by opc.opcintype::regtype::text) select * from t0 where opcintype='bigint'; opcintype | amopopr | amproc -----------+------------------+---------- bigint | =(bigint,bigint) | hashint8 (1 row) También hay un error en su instrucción CREATE OPERATOR; debe ser DEFAULT FOR TYPE bigint , no int .
testdb=# create extension bloom; CREATE EXTENSION testdb=# CREATE OPERATOR CLASS bigint_ops DEFAULT FOR TYPE int USING bloom AS OPERATOR 1 =(bigint,bigint), FUNCTION 1 hashint8; ERROR: could not make operator class "bigint_ops" be default for type pg_catalog.int4 DETAIL: Operator class "int4_ops" already is the default. testdb=# CREATE OPERATOR CLASS bigint_ops DEFAULT FOR TYPE bigint USING bloom AS OPERATOR 1 =(bigint,bigint), FUNCTION 1 hashint8; CREATE OPERATOR CLASS testdb=#