Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add index for update metric calculation spec reporting metrics in create metrics #1538

Merged

Conversation

tristanvuong2021
Copy link
Contributor

No description provided.

@wfa-reviewable
Copy link

This change is Reviewable

@tristanvuong2021 tristanvuong2021 marked this pull request as ready for review March 27, 2024 18:32
@tristanvuong2021 tristanvuong2021 force-pushed the tristanvuong-minor-improvements-reporting-v2-queries branch from c2bdcf2 to fbf447f Compare April 3, 2024 16:52
@tristanvuong2021 tristanvuong2021 changed the title Minor improvements to Metric and Report queries Add index for update metric calculation spec reporting metrics in create metrics Apr 3, 2024
Copy link
Member

@SanjayVas SanjayVas left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @tristanvuong2021)

a discussion (no related file):
I'm not quite understanding what this index is for.

Part of this is because I don't quite understand the MetricCalculationSpecReportingMetrics table. It appears to be mapping MetricCalculationSpecs to Metrics within the context of a Report. What's odd to me is that CreateMetricRequestId is part of the primary key rather than MetricId. MetricId is also nullable. Is the idea that this row is created separately from Metric creation, and the Metric is created later? Therefore the (MeasurementConsumerId, CreateMetricRequestId) tuple uniquely identifies a future or existing Metric? Why does it have ReportingSetId as part of its primary key then, as each Metric is tied to exactly one ReportingSet?



src/main/resources/reporting/postgres/add-index-on-metric-calculation-spec-reporting-metrics-table-for-update.sql line 40 at r1 (raw file):

-- changeset tristanvuong2021:add-metric-calculation-spec-reporting-metrics-create-metric-request-id-index dbms:postgresl
CREATE INDEX metric_calculation_spec_reporting_metrics_create_metric_request_id

Index names tend to be UpperCamelCase.

Suggestion:

MetricCalculationSpecReportingMetricsByCreateMetricRequestId

src/main/resources/reporting/postgres/changelog-v2.yaml line 48 at r1 (raw file):

- include:
    file: add-index-on-metric-calculation-spec-reporting-metrics-table-for-update.sql
    relativeToChangeLogFile: true    

nit: trailing whitespace

Code quote:

····

@tristanvuong2021 tristanvuong2021 force-pushed the tristanvuong-minor-improvements-reporting-v2-queries branch from 6e5e997 to 23ed845 Compare April 9, 2024 19:29
Copy link
Contributor Author

@tristanvuong2021 tristanvuong2021 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 of 3 files reviewed, 2 unresolved discussions (waiting on @SanjayVas)

a discussion (no related file):

Previously, SanjayVas (Sanjay Vasandani) wrote…

I'm not quite understanding what this index is for.

Part of this is because I don't quite understand the MetricCalculationSpecReportingMetrics table. It appears to be mapping MetricCalculationSpecs to Metrics within the context of a Report. What's odd to me is that CreateMetricRequestId is part of the primary key rather than MetricId. MetricId is also nullable. Is the idea that this row is created separately from Metric creation, and the Metric is created later? Therefore the (MeasurementConsumerId, CreateMetricRequestId) tuple uniquely identifies a future or existing Metric? Why does it have ReportingSetId as part of its primary key then, as each Metric is tied to exactly one ReportingSet?

Metrics are created separately from the Report and the rows in this table are first created when creating a Report before being updated later once the metrics are created.

ReportingSetId isn't needed as part of the primary key. Removed it.



src/main/resources/reporting/postgres/add-index-on-metric-calculation-spec-reporting-metrics-table-for-update.sql line 40 at r1 (raw file):

Previously, SanjayVas (Sanjay Vasandani) wrote…

Index names tend to be UpperCamelCase.

In postgres, index names tend to use this convention because of lack of case sensitivity

Copy link
Member

@SanjayVas SanjayVas left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @tristanvuong2021)


src/main/resources/reporting/postgres/drop-reporting-set-id-from-metric-calculation-spec-reporting-metrics-table-primary-key.sql line 39 at r2 (raw file):

--           └── MetricCalculationSpecReportingMetrics

-- changeset tristanvuong2021:drop-reporting-set-id-column-metric-calculation-spec-reporting-metrics-table-primary-key dbms:postgresql

nit: you don't need to be this verbose in the file/changeset name. You can add a -- comment: line to the changeset to explain what's happening.

Copy link
Collaborator

@stevenwarejones stevenwarejones left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @tristanvuong2021)

@tristanvuong2021 tristanvuong2021 merged commit e004ca8 into main Apr 12, 2024
4 checks passed
@tristanvuong2021 tristanvuong2021 deleted the tristanvuong-minor-improvements-reporting-v2-queries branch April 12, 2024 19:55
ple13 pushed a commit that referenced this pull request Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants