Skip to content

PHPORM-330 Fix: Convert query duration time to milliseconds #3374

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

Merged
merged 2 commits into from
Apr 30, 2025

Conversation

AmirRezaM75
Copy link
Contributor

Related Issue: laravel/telescope#1587

This merge request addresses an issue in the logQuery method of Laravel, where the execution time was being passed in microseconds instead of the expected milliseconds.

https://github.com/laravel/framework/blob/797c2bbd6701d13650a24697ab62529dc3df9fb9/src/Illuminate/Database/Connection.php#L847-L860

https://github.com/laravel/framework/blob/797c2bbd6701d13650a24697ab62529dc3df9fb9/src/Illuminate/Database/Events/QueryExecuted.php#L21-L26

I verified that using sleep function in my query.

public function create()
{
    $start = microtime(true);

    Post::whereRaw(['$where' => 'sleep(600) ||  true'])->first();

    $end = microtime(true);

    $diff = number_format(($end - $start) * 1000, 3);

    info("Execution time: $diff ms");

    return response()->noContent();
}

Before:

before

After:

after

[2025-04-29 07:03:42] local.INFO: Execution time: 615.043 ms

@AmirRezaM75 AmirRezaM75 requested a review from a team as a code owner April 29, 2025 07:05
@AmirRezaM75 AmirRezaM75 requested a review from GromNaN April 29, 2025 07:05
@AmirRezaM75 AmirRezaM75 changed the title Convert query duration time to milliseconds Fix: Convert query duration time to milliseconds Apr 29, 2025
@GromNaN GromNaN force-pushed the fix/duration_time branch from 2c66c8e to 1858d26 Compare April 30, 2025 08:30
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

Good catch. Thanks for the investigation and the fix @AmirRezaM75.
I added a non-regression test.
Tracked as PHPORM-330

@GromNaN GromNaN changed the title Fix: Convert query duration time to milliseconds PHPORM-330 Fix: Convert query duration time to milliseconds Apr 30, 2025
@AmirRezaM75
Copy link
Contributor Author

@GromNaN
My pleasure

One of the CI failed, is it because of my change?

@GromNaN
Copy link
Member

GromNaN commented Apr 30, 2025

Test failure is not related to this PR. It will be fixed by #3375

@GromNaN GromNaN force-pushed the fix/duration_time branch from d6bc603 to fbaeff5 Compare April 30, 2025 11:36
@GromNaN GromNaN merged commit 9d7d4dc into mongodb:5.x Apr 30, 2025
71 checks passed
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