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

Slow queries due to driver's emulate prepare #90

Open
nick-potts opened this issue Sep 5, 2024 · 2 comments
Open

Slow queries due to driver's emulate prepare #90

nick-potts opened this issue Sep 5, 2024 · 2 comments

Comments

@nick-potts
Copy link

nick-potts commented Sep 5, 2024

Description:
There's a significant performance issue when executing a specific query using the Laravel driver for SingleStore. The query runs much slower compared to executing it directly through the admin panel/TablePlus.

Steps to Reproduce:

  1. Set up the environment using the repository: https://github.com/nick-potts/laravel-verbs-singlestore
  2. Run php artisan app:seed-events to seed the database
  3. Execute the following query using the Laravel driver:
    select * from `verb_state_events` where `state_id` = 196875813868675074 and `state_type` = 'App\\States\\CustomerState' order by `id` asc limit 1000

Expected Behavior:
The query should execute quickly, similar to when run directly in SingleStore Studio or CLI.

Actual Behavior:

  • The query takes approximately 3.5 seconds to complete when run through the Laravel driver.
  • The issue persists in both production and local Docker SingleStore environments.

Additional Observations:

  1. The performance issue only occurs when using the Laravel driver.
  2. Changing the query from order by `id` asc to order by id asc (removing backticks) reduces execution time from 3.5s to 4ms.
  3. Removing the asc (despite the table being asc ordered by default) also fixes it.
  4. Dumping and re-importing the table does not reproduce the issue, suggesting a possible sharding/segment related problem.

Environment:

  • SingleStore version: 8.7.3 (local), 8.5.5 (production)

Additional Notes:

  • Enabling auto profiling seems to "fix" the issue, with query execution time dropping to 20ms.
  • The issue appears to be more pronounced under concurrent load, potentially due to CPU constraints.
@JackEllis
Copy link

@nick-potts Is this happening every run for that query? I'm tempted to pull this down and take a look as I'm sure this would be impacting us too.

@nick-potts
Copy link
Author

@JackEllis yes. However I couldn't get it to reproduce on Singlestore Cloud, only self hosted and docker.

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

No branches or pull requests

2 participants