Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Optimize prom_info.metric view #547

Merged
merged 1 commit into from
Oct 31, 2022
Merged

Optimize prom_info.metric view #547

merged 1 commit into from
Oct 31, 2022

Conversation

jgpruitt
Copy link
Collaborator

@jgpruitt jgpruitt commented Oct 24, 2022

Description

prom_info.metric can be quite slow. Part of this is due to the columns that deal with disk size. Split the view into two views - one that does not have the size columns and is optimized for speed, and the original.

prom_info.metric is now a SQL view (not backed by a function) and it omits the columns dealing with disk size. On a test database containing 2,500 metrics and 1.5 million chunks, it returned in ~4 seconds whereas the original was killed after running for > 20 minutes.

prom_info.metric_detail is a view that is backed by a function (_prom_catalog.metric_detail) which has the same signature as the original view. i.e. it contains the columns dealing with disk size. If this is a multinode installation (which we don't currently even support), it executes the original query. If this is a singlenode installation (which should be everyone), we use a new optimized query.

The new prom_info.metric_detail returns in 2.5 minutes on a test system with 2,500 metrics and 1.5 million chunks.

Merge requirements

Please take into account the following non-code changes that you may need to make with your PR:

  • CHANGELOG entry for user-facing changes
  • Updated the relevant documentation

@jgpruitt jgpruitt self-assigned this Oct 24, 2022
@jgpruitt jgpruitt linked an issue Oct 24, 2022 that may be closed by this pull request
@jgpruitt jgpruitt changed the title Create a new, "fast" version of prom_info.metric view Optimize prom_info.metric view Oct 27, 2022
@jgpruitt jgpruitt marked this pull request as ready for review October 27, 2022 20:55
@jgpruitt jgpruitt requested a review from a team as a code owner October 27, 2022 20:55
@jgpruitt jgpruitt force-pushed the john/metric-view2 branch 3 times, most recently from ea8def6 to 4041541 Compare October 27, 2022 21:38
Copy link
Contributor

@sumerman sumerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Although, I left a couple of questions/suggestions.

migration/idempotent/001-base.sql Outdated Show resolved Hide resolved
migration/idempotent/001-base.sql Outdated Show resolved Hide resolved
prom_info.metric can be quite slow. Part of this is due to the columns
that deal with disk size. Split the view into two views
    - one that does not have the size columns and is optimized for
      speed
    - and the original (also optimized for better performance)

prom_info.metric is now a SQL view (not backed by a function) and it
omits the columns dealing with disk size.

prom_info.metric_detail is a view that is backed by a function
(_prom_catalog.metric_detail) which has the same signature as the
original view. i.e. it contains the columns dealing with disk size. If
this is a multinode installation (which we don't currently even
support), it executes the original query. If this is a singlenode
installation (which should be everyone), we use a new optimized query.
@jgpruitt jgpruitt merged commit 5eb81ef into master Oct 31, 2022
@jgpruitt jgpruitt deleted the john/metric-view2 branch October 31, 2022 17:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a new, "fast" version of prom_info.metric_view
2 participants