5 Replies Latest reply on Jun 2, 2010 10:26 AM by Anil Saldanha

    Too much time to search an user by attributes: 2 min when 1000 users exists

    Valentin Roman Newbie

      Hy,

       

      Here is my situation: I want to create  a user with to properties: login id ( email ) and name ( person name ) and I want my login id to be modifiable.
      So, I must use as id some  random id for the user I want to create and set the attributes login id and name  on it like this:
                               identitySession.getPersistenceManager().createUser(RANDOM_ID);
                              Attribute[]  userInfo = new Attribute[] { new SimpleAttribute(LOGIN_ID, email)  , new SimpleAttribute(NAME, name) };
                               identitySession.getAttributesManager().updateAttributes(dbUser,  userInfo);
      Now if I want to create a new user I want to verify, in my repository, I do not have a user with the same email and name, so for this I do the following:
                          IdentitySearchCriteria criteria =  new IdentitySearchCriteriaImpl();
                          criteria.attributeValuesFilter(  new SimpleAttribute(LOGIN_ID, email) , new SimpleAttribute(NAME, name)  );
                          dbUser =  identitySession.getPersistenceManager().findUser(criteria);
                          if (dbUser != null)
                          {
                               throw new Exception(User already exists);
                          }
      Here is my problem: beacause I have 1000 users in my repository the method findUser() takes around 2 minutes to execute and that is too much.
      Do you have any idea how I can make my search faster?
      Thanks,
      Valentin