Skip to content
New issue

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

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

Already on GitHub? # to your account

[11.x] Improve Schema::hasTable() performance #53006

Merged
merged 4 commits into from
Oct 3, 2024

Conversation

hafezdivandari
Copy link
Contributor

@hafezdivandari hafezdivandari commented Oct 1, 2024

Fixes #53002

The Schema::hasTable() method is using the Schema::getTable() method internally, which could sometimes result in an expensive query. This PR improves the performance of Schema::hasTable() by using more lightweight queries.

PS: I previously added many integration tests for these methods and their edge cases.

Copy link

github-actions bot commented Oct 1, 2024

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@hafezdivandari hafezdivandari changed the title ['11.x'] Improve Schema::hasTable() performance [11.x] Improve Schema::hasTable() performance Oct 1, 2024
Copy link

@Vinksyunit Vinksyunit left a comment

Choose a reason for hiding this comment

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

Way more performance when I tried it for my case. Well done !

@taylorotwell taylorotwell merged commit d9ecee5 into laravel:11.x Oct 3, 2024
31 checks passed
@hafezdivandari hafezdivandari deleted the 11.x-improve-has-table branch October 3, 2024 17:50
@jpbalda
Copy link
Contributor

jpbalda commented Oct 7, 2024

Perfectly timed! I was working on a similar PR. Last week I upgraded a SaaS app and the migrations were taking around 3 minutes per tenant  😩

@hafezdivandari thanks for the PR, I really appreciate it!!! 👌

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PostgreSQL migration performance due to hasTable behavior
4 participants