Indexes in PL/SQL
От | Tony Holmes |
---|---|
Тема | Indexes in PL/SQL |
Дата | |
Msg-id | 20030530103317.A30354@crosswinds.net обсуждение исходный текст |
Ответы |
Re: Indexes in PL/SQL
Re: Indexes in PL/SQL |
Список | pgsql-novice |
I'm using PgSQL 7.3.2 and a PL/SQL routine that is posing some performance problems for me. I have a table of users information as such (trimmed down): user_main ( uid int4, username character varying(32), password character varying(16) ); Primary Index is uid Unique Index on username There are approx 1.5million records in the table. Now, on the psql command line when i do SELECT uid FROM user_main WHERE username='bob'; it works and is very fast - the data is returned almost as fast as I can hit enter. Now I have a PL/SQL function (pgsql mail check): CREATE FUNCTION valid_user(text) RETURNS text AS ' DECLARE _user ALIAS FOR $1; _uid user_main.uid%TYPE; BEGIN SELECT uid INTO _uid FROM user_main WHERE username=_user; IF FOUND THEN RETURN ''OK''; END IF; RETURN ''554 Sender Address Rejected''; END;' LANGUAGE 'plpgsql'; It works, however, the select is taking a very long time, 5-10 seconds. Explain doesn't help much since it's a PL/SQL routine and I could not find any mention of this in the lists (maybe my search criteria sucked). Any ideas? -- Tony Holmes Founder and Senior Systems Architect Crosswinds Internet Communications Inc.
В списке pgsql-novice по дате отправления: