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

Use pypika's SqlContext to improve performance #1837

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

henadzit
Copy link
Contributor

@henadzit henadzit commented Jan 3, 2025

Description

  • Update the code to use pypika's SqlContext

⚠️ This PR depends on the pypika PR, and should not be merged until it is merged.

Motivation and Context

This PR improves the performance of SQL generation by pypika (see the Codspeed comment for more details), hence improving over query performance:

  • 23% improvement in the test_get_many_fields benchmark
  • 9% improvement in the test_filter_many_filters benchmark
  • 4% improvement in test_filter_few_fields

How Has This Been Tested?

make ci

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link

codspeed-hq bot commented Jan 3, 2025

CodSpeed Performance Report

Merging #1837 will improve performances by 23.45%

Comparing henadzit:feat/pypika-sql-context (f81336d) with develop (7afc90e)

Summary

⚡ 1 improvements
✅ 7 untouched benchmarks

Benchmarks breakdown

Benchmark develop henadzit:feat/pypika-sql-context Change
test_get_many_fields 1.5 ms 1.2 ms +23.45%

@henadzit henadzit force-pushed the feat/pypika-sql-context branch from abcb490 to 95565ad Compare January 3, 2025 11:13
@coveralls
Copy link

coveralls commented Jan 3, 2025

Pull Request Test Coverage Report for Build 12597288641

Details

  • 26 of 29 (89.66%) changed or added relevant lines in 8 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage remained the same at 90.145%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tortoise/backends/mysql/executor.py 2 3 66.67%
tortoise/indexes.py 0 2 0.0%
Files with Coverage Reduction New Missed Lines %
tortoise/indexes.py 1 84.29%
Totals Coverage Status
Change from base Build 12596506172: 0.0%
Covered Lines: 6465
Relevant Lines: 7054

💛 - Coveralls

@henadzit henadzit marked this pull request as ready for review January 3, 2025 11:53
@henadzit henadzit requested a review from abondar January 5, 2025 20:49
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