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

Fix luigi.contrib.sqla performance bug; don't reflect all tables #2104

Merged
merged 1 commit into from
Apr 30, 2017

Conversation

kdbhiggins
Copy link
Contributor

Description

The sqla module can be extremely slow loading if your db has a lot of tables. This is due to unnecessary reflection of all the tables.

There was a similar bug in pandas: pandas-dev/pandas#8147

Motivation and Context

Reflection is very slow when you have lots of tables. In my case the sqla module would sit for > 30 seconds when running the line

metadata.reflect(bind=engine)

We don't need to reflect all the tables here. Instead we can only reflect and bind the table we are interested in

metadata.reflect(only=[self.table], bind=engine)

Have you tested this? If so, how?

Reflection is tested in sqla_test.py and with these changes my performance issue is fixed

@mention-bot
Copy link

@kdbhiggins, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Tarrasch, @aliavni and @soxofaan to be potential reviewers.

@kdbhiggins kdbhiggins changed the title luigi.contrib.sqla performance bug; don't reflect all tables Fix luigi.contrib.sqla performance bug; don't reflect all tables Apr 27, 2017
@Tarrasch Tarrasch merged commit ebd9a2b into spotify:master Apr 30, 2017
This was referenced Jun 29, 2022
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.

4 participants