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

Optimise the logic for verifying if a table is empty #4734

Closed
1 of 2 tasks
tati-qalified opened this issue Aug 24, 2023 · 1 comment · Fixed by #4834
Closed
1 of 2 tasks

Optimise the logic for verifying if a table is empty #4734

tati-qalified opened this issue Aug 24, 2023 · 1 comment · Fixed by #4834

Comments

@tati-qalified
Copy link
Contributor

Search first

  • I searched and no similar issues were found

Description

Originally metioned here.

Currently, to check if a table is empty, Liquibase is using JdbcExecutor.queryForInt(..), which isn't efficient for tables with a large number of rows. Furthermore, if a table contains more rows than the maximum Integer number, the run will fail with an exception.

Steps To Reproduce

Create a changeSet that includes the TableIsEmpty precondition, which will call the check function in the RowCountPrecondition class.

If the table that the changeSet is being applied to has over Integer.MAX_VALUE rows, the run will fail with an exception.

Expected/Desired Behavior

The method for checking if a table is empty should be something similar to checking if there is a first row or not, instead of counting all of them and seeing if the number of rows is 0.

Liquibase Version

All

Database Vendor & Version

All

Liquibase Integration

All

Liquibase Extensions

No response

OS and/or Infrastructure Type/Provider

No response

Additional Context

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR (Thank you!)
@tati-qalified tati-qalified added DBAll featurePrecondition enhancement New non breaking enhancements in LB labels Aug 24, 2023
@kevin-atx
Copy link
Contributor

As this ticket generally affects performance, I'm including it in the next sprint review to see if it's something we want to address.

@kevin-atx kevin-atx added TypeEnhancement performance and removed enhancement New non breaking enhancements in LB labels Aug 24, 2023
@filipelautert filipelautert self-assigned this Sep 4, 2023
@filipelautert filipelautert added this to the 1NEXT milestone Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants