cancel
Showing results for 
Search instead for 
Did you mean: 

Performance issue in fetching noderefs from resultset.

faizaan
Champ in-the-making
Champ in-the-making
Hi,

I am facing performance issue in fetching noderefs from lucene resultset for 5 concurrent users, w.r.t below code snippet line that executes lucene query " resultSet = AlfrescoServiceRegistry.getSearchService().query(searchParameters)" is taking only  1-2 sec to execute but line that fetches noderefs from resultset "listNodeRefs = resultSet.getNodeRefs()" is taking around 25-30 sec, I am fetching only 25 records into resultset for pagination out total 1000-1500 records.

Please suggest how can we bring down execution time for this method.

Environment :  Alfresco 3.4.3 EE, MYSQL, Tomcat.



    public static List<NodeRef> executeSPQuery(final String query, final String siteName, final String pageSize, final String skipCount, final String sortField,
            final String sortOrder)
    {
        ResultSet resultSet = null;
        List<NodeRef> listNodeRefs = null;
        try
        {
            // For sorting and limit the result , uses searchparameters
            final SearchParameters searchParameters = new SearchParameters();
            searchParameters.addStore(Repository.getStoreRef());
            searchParameters.setLanguage(SearchService.LANGUAGE_LUCENE);
            searchParameters.setQuery(query);
            searchParameters.setMaxItems(Integer.parseInt(pageSize));
            searchParameters.setSkipCount(Integer.parseInt(skipCount));

            searchParameters.addSort(SearchParameters.SORT_IN_DOCUMENT_ORDER_DESCENDING);
             
            LOGGER.debug("==========Started Executing Query=======");
           
            resultSet = AlfrescoServiceRegistry.getSearchService().query(searchParameters);
           
            LOGGER.debug("==========Completed Executing Query=======");

            if (resultSet != null && resultSet.length() > 0)
            {
               LOGGER.debug("====Started Getting noderefs=======");
               
               resultSet.setBulkFetch(true);
               resultSet.setBulkFetchSize(10000);
               
               LOGGER.debug(">>>>>>>Result set size : "+resultSet.length());
               
                listNodeRefs = resultSet.getNodeRefs();
               
                LOGGER.debug("====Completed Getting noderefs=======");
            }

        }
         catch (final LuceneQueryParserException e)
        {
            LOGGER.info("Problem in Parsing the Lucene query :: " + query, e);
            return listNodeRefs;
        }
        catch (final Exception e)
        {
            LOGGER.info("Problem in Parsing the Lucene query :: " + query, e);
            return listNodeRefs;
        }
        finally
        {
            if (resultSet != null)
            {
                resultSet.close();
                resultSet = null;
            }
        }

        return listNodeRefs;
    }

Thanks,
Faizaan
1 REPLY 1

faizaan
Champ in-the-making
Champ in-the-making
Fixed this by setting bulkfetch size equal to page size, this brought execution time of method from around 25-30 sec to 4-5 sec for 5 concurrent users.



                resultSet.setBulkFetch(true);
               resultSet.setBulkFetchSize(Integer.parseInt(pageSize));
               
                listNodeRefs = resultSet.getNodeRefs();
               

Thanks !
Faizaan