Using EDB Query Advisor
Suggest editsEDB Query Advisor defines functions and views.
Functions
query_advisor_index_recommendations(min_filter, min_selectivity)
Performs a global index suggestion.
By default, only predicates filtering at least 1000 rows and 30% of the rows in average are considered. You can use the min_filter
and min_selectivity
parameters to override the default.
The function generates the one- and two-column index candidates based on the predicates it collects. It replans all related workload queries in the presence of the hypothetical index with respect to each candidate. It recommends the list of indexes that bring the most value to the workload. It also shows the estimated index size and percentage cost reduction in the workload queries. You can decide, based on the size and benefit ratio, which indexes are the most useful for you.
For example:
query_advisor_statistics_recommendations(min_err_estimate_num, min_err_estimate_ratio)
Recommends potentially useful extended statistics by analyzing the statistics collected from the quals of user queries.
By default, min_err_estimate_num
and min_err_estimate_ratio
are set to 0
. You can use the min_err_estimate_num
and min_err_estimate_ratio
parameters to override the default.
The function generates potential candidates from the multi-column filters of your queries. Then, these candidates are processed by exploring different possible combinations. Currently the focus is on statistics for two columns at a time.
It also shows the weights to each candidate. Weights are based on how many queries would benefit from those extended statistics and what the execution cost of the queries would be.
For example:
query_advisor_qualstat
Returns the counts for every qualifier identified by the expression hash. This hash identifies each expression.
Qualifier | Description | |
---|---|---|
userid | ID of the user who executed the query. | |
dbid | ID of the database in which the query was executed. | |
lrelid, lattnum | ID of the relation and attribute number of the VAR on the left side, if any. | |
opno | ID of the operator used in the expression. | |
rrelid, rattnum | ID of the relation and attribute number of the VAR on the right side, if any. | |
qualid | Normalized identifier of the parent AND expression, if any. This identifier is computed excluding the constants. This qualifier is useful for identifying predicates that are used together. | |
uniquequalid | Unique identifier of the parent AND expression, if any. This identifier is computed including the constants. | |
qualnodeid | Normalized identifier of this simple predicate. This identifier is computed excluding the constants. | |
uniquequalnodeid | Unique identifier of this simple predicate. This identifier is computed including the constants. | |
occurrences | Number of times this predicate was invoked, that is, number of related query execution. | |
execution_count | Number of times this predicate was executed, that is, the number of rows it processed. | |
nbfiltered | Number of tuples this predicate discarded. | |
queryid | Query identifier. | |
eval_typ | The evaluation type: f for a predicate evaluated after a scan or i for an index predicate. |
For example:
query_advisor_workload_queries
Returns all the stored query texts.
query_advisor_qualstats_memory_usage
Returns the percentage usage of the workload and qualifier hash table.
query_advisor_qualstats_reset
Resets the internal counters and forgets about every encountered qualifier and workload entry.
Views
The extension defines the following views on top of the pg_qualstats
function.
query_advisor_qualstats
Filters calls to query_advisor_qualstats()
by the current database.
query_advisor_qualstats_pretty
Performs the appropriate joins to display a readable, aggregated form for every attribute from the query_advisor_qualstats view.
For example:
query_advisor_statistics_recommendations
Skips the weight column from query_advisor_statistics_recommendations
.
For example:
Could this page be better? Report a problem or suggest an addition!