Announcement Announcement Module
Collapse
No announcement yet.
Search with Spring LDAP very slow Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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.

      Comment

      Working...
      X