Believe me, I'm not trying to be an expert here, so if I'm wrong I could benefit
from some explaining why... but...
instead of:
SELECT user_idnr FROM dbmail_users WHERE lower(userid) =
lower('[EMAIL PROTECTED]')
Wouldn't it make more sense to create these entries with a INSERT INTO ..
lower() so that you can take advantage of a userid index?
dbmail_users_name_idx" UNIQUE, btree (userid)
dbmail=> explain SELECT user_idnr FROM dbmail_users WHERE lower(userid) =
lower('[EMAIL PROTECTED]');
QUERY PLAN
------------------------------------------------------------------
Seq Scan on dbmail_users (cost=0.00..195.09 rows=1 width=8)
Filter: (lower((userid)::text) = '[EMAIL PROTECTED]'::text)
(2 rows)
dbmail=> explain SELECT user_idnr FROM dbmail_users WHERE userid =
'[EMAIL PROTECTED]';
QUERY PLAN
-------------------------------------------------------------------------------------
Bitmap Heap Scan on dbmail_users (cost=57.00..61.01 rows=1 width=8)
Recheck Cond: ((userid)::text = '[EMAIL PROTECTED]'::text)
-> Bitmap Index Scan on dbmail_users_name_idx (cost=0.00..57.00 rows=1
width=0)
Index Cond: ((userid)::text = '[EMAIL PROTECTED]'::text)
(4 rows)