I have been banging my head to the walls for the past couple of days to make virtual mailboxes work and I finally found the problem. It seems when prefetch is used the user_query is not working at all. However, I have not found any reference to this one. http://wiki.dovecot.org/Plugins/Virtual I have tried to add the SQL statements to the password_query with prefetch but it did not work. It seems that it only works with prefetch off.