Results 1 to 3 of 3

Thread: Search with Spring LDAP very slow

  1. #1
    Join Date
    Apr 2011
    Posts
    2

    Unhappy Search with Spring LDAP very slow

    Hi,
    I use spring ldap at work, I have this query that returns 15,000 objects.
    With Spring LDAP, my search delay 00:06:37s
    Code:
    getLdap().search("user=ou,global=o",
    		"cn=*", ONELEVEL_SCOPE,
    		new ContextMapper() {
    		       public Object mapFromContext(Object ctx) {
    			     count++;
                                 // only count the result
    	               }
                     });
    The same search, but using pure JNDI, my search delay only 00:00:39s (10 times faster than with spring ldap):
    Code:
    SearchControls ctls = new SearchControls();
    NamingEnumeration answer;
    // all attributes
    ctls.setReturningAttributes(userAttributes);
    ctls.setSearchScope(SearchControls.ONELEVEL_SCOPE);            
    InitialLdapContext ctx = getConnection();
    answer = ctx.search("user=ou,global=o", "cn=*", ctls);
    int total = 0;
    while ( answer.hasMore() )  {
    	answer.nextElement();
    	total++;
            // only count the result also
     }
    The tests were performed on the same server.
    Not yet discovered the cause of the problem with the spring ldap, anyone have any idea of the cause???

    thanks.

  2. #2
    Join Date
    Jul 2010
    Posts
    139

    Default

    You didn't show what getLdap() is; I'll assume this is a singleton instance of a Spring-managed ldapTemplate bean.

    Are you leveraging the Spring Ldap connection pooling? Hopefully yes, as opening/closing connections on any protocol is quite expensive.

    Also, have someone look at the LDAP logs to see what searches are actually performed by your spring ldap queries. Just to make sure the requested attributes, search base, and search filter are the same as your JNDI searches.

  3. #3
    Join Date
    Apr 2011
    Posts
    2

    Default

    Quote Originally Posted by jzcfk9 View Post
    You didn't show what getLdap() is; I'll assume this is a singleton instance of a Spring-managed ldapTemplate bean.

    Are you leveraging the Spring Ldap connection pooling? Hopefully yes, as opening/closing connections on any protocol is quite expensive.

    Also, have someone look at the LDAP logs to see what searches are actually performed by your spring ldap queries. Just to make sure the requested attributes, search base, and search filter are the same as your JNDI searches.
    1- Yes, itīs singleton spring managed ldapTemplate bean...

    2- I'm reusing the connections certainly open and close is too costly...

    3-I'm using the same base dn, same attributes and same filter. Precisely this is what caused me to wonder ...

    I will to continue my research, I come back if I solve with the solution ...

    Thanks.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •