Legacy Knowledge Base
公開されました Jun. 30, 2025

assetEntryLocalServiceUtil.getEntriesメソッドで実行されるAssetEntryテーブルへのクエリによるデータベースのスループット問題

Written By

Jorge Diaz

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

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

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

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

問題

assetEntryLocalServiceUtil.getEntriesメソッドを呼び出すカスタム開発があります:

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

このメソッドはAssetEntryテーブルへのクエリを実行するため、データベースのスループットに問題が生じる。

どうすれば避けることができますか?

環境

  • DXP 7.3

解像度

AssetEntryLocalServiceUtil.getEntriesの呼び出しを、Elasticsearchインデックスを使用する同等の_assetHelper.searchAssetEntriesメソッドに置き換える必要があります。

アセットパブリッシャーでは、このコード:com.liferay.asset.publisher.web.internal.util.AssetPublisherHelperImplクラスのgetAssetEntriesメソッドは、_isSearchWithIndexの結果に応じてAssetEntryLocalServiceUtil.getEntriesと _assetHelper.searchAssetEntriesの両方を使用します。

AssetEntryLocalServiceUtil.getEntriesはデータベースレベルでパフォーマンスの問題を引き起こす可能性があるため、一般的にはElasticsearchに対してクエリを実行する_assetHelper.searchAssetEntriesメソッドを使用することが望ましいです。

リンク先の例でわかるように、どちらのメソッドもassetEntryQueryオブジェクトを受け取るので、_assetHelper.searchAssetEntriesを使用するようにコードを適応させるのは簡単です:

  1. assetHelper.searchAssetEntriesを呼び出し、BaseModelSearchResult<AssetEntry> 型のオブジェクトを返します。 このメソッドの呼び出し方にはいくつかの例がある:

  2. BaseModelSearchResult<AssetEntry>オブジェクトを使用して、baseModelSearchResult.getBaseModels() メソッドを呼び出し、AssetEntries のリストを返します。

これらの変更により、このクエリをデータベースに対して実行することを避け、代わりにElasticsearchに対して実行することになります。

Did this article resolve your issue ?

Legacy Knowledge Base