Skip to content

Improve overlapping indices action#7630

Open
labkey-adam wants to merge 14 commits intodevelopfrom
fb_overlapping_indices
Open

Improve overlapping indices action#7630
labkey-adam wants to merge 14 commits intodevelopfrom
fb_overlapping_indices

Conversation

@labkey-adam
Copy link
Copy Markdown
Contributor

Rationale

Redundant indices waste disk space and degrade insert/update/delete performance. We can improve the existing action with per-schema processing, better documentation in the SQL scripts it generates, unique index vs. unique constraint detection, etc.

Also, add support for simple action parameter binding to Java records.

// Very simple binding for Java records: no support for binding errors, arrays, lists, disallowed fields, etc.
private <R> BindException defaultBindParametersToRecord(Class<R> recordClass, PropertyValues m)
{
ObjectFactory<R> factory = ObjectFactory.Registry.getFactory(recordClass);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Standard form binding goes through getPropertyValuesForFormBinding(). Seems wise to do that here too, even if records are less likely to have problems

void writeScript(Writer writer, IndexChange change, String schemaName, String tableName, IndexDefinition changeIndex) throws IOException
{
Drop.writeScript(writer, change);
String indexName = changeIndex.name().replace("uq", "ix").replace("unique", "index");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

replace() replaces all instances. Do we want to just replace the first ones?

}

@Test
public void testUniqueNotDroppedByLongerPk()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude pointed this out as a problem. I pulled down the FB to confirm and ended up adding these test cases, plus fixing the issue with this (perhaps unlikely) scenario. See what you think.

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.

2 participants