2010/9/22 Miguel Panuera <[email protected]>:
> Buenas, al realizar estas funciones,
> tambien se deberia crear un indice con la funcion para optimizar la
> busqueda????????
>

En este caso no, porque esta usando ILIKE y ese operador nunca usa
indices ademas la funcion sp_ascii esta siendo declarada volatile,
pero si haces esto:

CREATE OR REPLACE FUNCTION sp_ascii(character varying)
RETURNS text AS
$BODY$
SELECT TRANSLATE
($1,
'áàâãäéèêëíìïóòôõöúùûüÁÀÂÃÄÉÈÊËÍÌÏÓÒÔÕÖÚÙÛÜçÇ',
'aaaaaeeeeiiiooooouuuuAAAAAEEEEIIIOOOOOUUUUcC');
$BODY$
LANGUAGE 'sql' IMMUTABLE;

(no veo problema en declarar la funcion IMMUTABLE, o la hay?)

CREATE INDEX idx_ascii_apellido ON nombres (lower(sp_ascii(apellido1)));

SELECT * FROM nombres WHERE lower(sp_ascii(apellido1)) LIKE
lower(sp_ascii('martin'));


deberia funcionar

-- 
Jaime Casanova         www.2ndQuadrant.com
Soporte y capacitación de PostgreSQL
-
Enviado a la lista de correo pgsql-es-ayuda ([email protected])
Para cambiar tu suscripci�n:
http://www.postgresql.org/mailpref/pgsql-es-ayuda

Responder a