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

Table.exists() very slow in Postgres Environments with a lot of objects #1701

RobertRad opened this issue Jul 10, 2017 · 2 comments


Copy link

What version of Flyway are you using?


Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)

Java API

What database are you using (type & version)?

Postgres 9.5

What did you do?

Run migrations on a database with many objects.
Objects are all tables/indexes/sequences in all schemas.

What did you expect to see?

I expected a negligible overhead for the calls to Table.exists()

What did you see instead?

A single call to Table.exists() - or more precisely PostgreSQLTable.doExists() - has a significant overhead.

On a database with over 500.000 Objects a single call can take more than 250ms.

When calling Flyway.migrate() the method is called about 8 times and then 3 times per Script.
This might sum up to a huge overhead. Especially with a lot of schemas (which lead to the many objects).

Of course this is a problem with Postgres in the first place, but unfortunately leads to difficulties when doing migrations with Flyway .

Copy link
Contributor Author

The code for PostgreSQLTable.doExists() is taken from this post:

@axelfontaine axelfontaine added this to the Flyway 5.0.0 milestone Jul 10, 2017
axelfontaine pushed a commit to flyway/ that referenced this issue Sep 5, 2017
Copy link

Fixed by #1702

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants