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

schema: Add new index for customvar_flat #617

Merged
merged 2 commits into from
Aug 1, 2023

Conversation

nilmerg
Copy link
Member

@nilmerg nilmerg commented Jul 11, 2023

resolves #523

postgres changes still tbd

@nilmerg nilmerg self-assigned this Jul 11, 2023
@cla-bot cla-bot bot added the cla/signed label Jul 11, 2023
@nilmerg
Copy link
Member Author

nilmerg commented Jul 11, 2023

This is required, because Icinga/ipl-orm#110 will change how Icinga DB Web filters custom variables. Without an index, the then not dependent subqueries will perform a full table scan.

I also played around with just an index on flatname, but that turned out to be ignored as the flatname, flatvalue index was still being preferred.

@julianbrost julianbrost added this to the 1.2.0 milestone Jul 26, 2023
@julianbrost
Copy link
Contributor

Pretty much the same as for #616:

Change looks fine to me in general. Will you do it for PostgreSQL as well and also resolve the merge conflict while doing so?

But probably do one PR first as both append something to the upgrade file, you'd probably end up with a new merge conflict otherwise.

@julianbrost julianbrost force-pushed the fix/customvarflat-name-index-523 branch from e3150ce to d4b3dec Compare August 1, 2023 13:58
@julianbrost julianbrost removed their assignment Aug 1, 2023
@julianbrost julianbrost marked this pull request as ready for review August 1, 2023 14:04
Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

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

New files names don't match PR milestone.

@julianbrost
Copy link
Contributor

There are no new files. It's mixed up already and will be cleaned up with #602, including the schema version.

@@ -987,7 +987,8 @@ CREATE TABLE customvar_flat (

PRIMARY KEY (id),

INDEX idx_customvar_flat_customvar_id (customvar_id)
INDEX idx_customvar_flat_customvar_id (customvar_id),
INDEX idx_customvar_flat_flatname_flatvalue (flatname, flatvalue(255)) COMMENT 'Lists filtered by custom variable'
Copy link
Member

Choose a reason for hiding this comment

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

The 255 just respects MySQL limits...

(source: @nilmerg)

@@ -1564,13 +1564,16 @@ ALTER TABLE customvar_flat ALTER COLUMN customvar_id SET STORAGE PLAIN;
ALTER TABLE customvar_flat ALTER COLUMN flatname_checksum SET STORAGE PLAIN;

CREATE INDEX idx_customvar_flat_customvar_id ON customvar_flat(customvar_id);
CREATE INDEX idx_customvar_flat_flatname_flatvalue ON customvar_flat(flatname, flatvalue);
Copy link
Member

Choose a reason for hiding this comment

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

... so we don't need to emulate it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed. I tested with a 32k character long flatvalue, PostgreSQL was happy.

@julianbrost julianbrost merged commit 73472f1 into master Aug 1, 2023
31 checks passed
@julianbrost julianbrost deleted the fix/customvarflat-name-index-523 branch August 1, 2023 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add index on customvar_flat.flatname
3 participants