Background
Slow queries are common in OpenSearch and can be caused by improper user operations, an excessive number of filter conditions, or a sudden spike in queries per second (QPS). The slow query analysis feature in OpenSearch lets you view details of slow queries with high logical computing unit (LCU) consumption over a specified time period. It also provides optimization suggestions to help you reduce costs.
Benefits
-
Free to use: This feature is available at no cost.
-
On-demand analysis: Analyze slow queries from the past month and receive optimization suggestions.
-
Comprehensive analysis: Analyze the causes of slow queries using metrics such as average LCU consumption, peak-hour LCU consumption, total LCU consumption, and the percentage of slow queries to total queries. You can also sort the results by any of these metrics.
Notes
-
Currently, you can only analyze data from the previous day. Analyzed historical data samples are kept for up to 30 days.
Procedure
1. Enable the slow query optimization feature: If this is your first time using the slow query optimization feature, enable it by navigating to OpenSearch High-performance Search Edition > Feature Extensions > Slow Search Optimization in the left-side navigation pane.
Select the application for which you want to enable slow query optimization, select the Enable Slow Query Analysis and Read Commitment for Use checkboxes, and then click Enable.
2. Analyze query data: After selecting an application, select a date from the date picker and click View. If the data for the selected date has not been analyzed, a message "Data for this date has not been analyzed." appears in the table area. Click Analyze. The table includes columns such as slow query category, peak-hour LCU consumption, average LCU consumption, total LCU consumption, percentage of slow queries to total queries, and optimization suggestions. The total LCU consumption column is the key metric to monitor.
3. View the results: When the analysis is complete, you can view the results. To view results for a specific day, select a date (for example, 2020-11-02) from the date picker in the analysis interface.
You can also sort the analysis results by different metrics.
Click a slow query category to view details for each search request, including the RequestId, query, total LCU consumption, search consumption (LCU), aggregation consumption (LCU), sorting consumption (LCU), summary consumption (LCU), other consumption (LCU), and optimization suggestions.