Legacy Knowledge Base
Published Jun. 30, 2025

Database throughput problems due to queries to the AssetEntry table executed by the assetEntryLocalServiceUtil.getEntries method

Written By

Jorge Diaz

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

Issue

We have a custom development that calls the assetEntryLocalServiceUtil.getEntries method:

AssetEntryQuery assetEntryQuery = new AssetEntryQuery();
assetEntryQuery.setAnyCategoryIds(new long[] { categoriaMesVistos });
assetEntryQuery.setOrderByCol1("priority");
List<AssetEntry> assetEntryList = AssetEntryLocalServiceUtil.getEntries(assetEntryQuery)

This method executes queries to the AssetEntry table, leading to database throughput problems.

How can I avoid them?

Environment

  • DXP 7.3

Resolution

You have to replace the call to AssetEntryLocalServiceUtil.getEntries with the equivalent _assetHelper.searchAssetEntries method that uses the Elasticsearch index.

In the Asset Publishers, this code: com.liferay.asset.publisher.web.internal.util.AssetPublisherHelperImpl class, getAssetEntries method uses both AssetEntryLocalServiceUtil.getEntries and _assetHelper.searchAssetEntries depending on _isSearchWithIndex result.

Since AssetEntryLocalServiceUtil.getEntries can cause performance issues at the database level, it is generally preferable to use the _assetHelper.searchAssetEntries method, which queries against Elasticsearch and typically performs better for these specific use cases.

As you can see in the linked example, both methods receive an assetEntryQuery object, so adapting your code to use _assetHelper.searchAssetEntries is straightforward:

  1. Call assetHelper.searchAssetEntries, which returns an object of type BaseModelSearchResult<AssetEntry>. There are several examples of how to invoke this method:

  2. With the BaseModelSearchResult<AssetEntry> object, call the baseModelSearchResult.getBaseModels() method, which will return the list of AssetEntries.

With these changes, you will avoid executing this query against your database and instead perform it against Elasticsearch.

 

 

 

 

Did this article resolve your issue ?

Legacy Knowledge Base