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

Do not call CommandInterface::getRawSql() if no logger or profiler #781

Merged
merged 12 commits into from
Nov 27, 2023

Conversation

Tigrov
Copy link
Member

@Tigrov Tigrov commented Nov 22, 2023

Optimization

Q A
Is bugfix?
New feature?
Breaks BC?
Fixed issues -

Copy link

codecov bot commented Nov 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c4c4a9d) 99.64% compared to head (dbdc094) 99.64%.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #781   +/-   ##
=========================================
  Coverage     99.64%   99.64%           
- Complexity     1264     1265    +1     
=========================================
  Files            63       63           
  Lines          3062     3063    +1     
=========================================
+ Hits           3051     3052    +1     
  Misses           11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

what-the-diff bot commented Nov 22, 2023

PR Summary

  • Introduction of new entry in CHANGELOG
    A new record has been added to the history of modifications made in our codebase (CHANGELOG.md). This record indicates a change we made that improves efficiency by avoiding unnecessary operations when there's no need to log or profile the running process.

  • Optimization in AbstractPdoCommand
    We revamped the part of our code (AbstractPdoCommand.php) that deals with database operations. Now, it will log the executed database query only when a logger is available. Similarly, it will profile (measure the performance of) the process if and only if a tool for doing that is set up. This speeds up our code when these kinds of diagnostic settings are not in place.

@Tigrov Tigrov added the status:code review The pull request needs review. label Nov 22, 2023
@Tigrov Tigrov requested a review from a team November 22, 2023 07:47
Copy link
Member

@vjik vjik left a comment

Choose a reason for hiding this comment

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

If add result caching to getRawSql() method, then we can reafactor code so:

$this->profiler?->begin($this->getRawSql(), $queryContext);

If profile is null then $this->getRawSql() don't call.

@vjik vjik merged commit ad6577d into master Nov 27, 2023
85 of 86 checks passed
@vjik vjik deleted the do-not-call-getRawSql branch November 27, 2023 09:58
@Tigrov Tigrov mentioned this pull request Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:code review The pull request needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants