Skip to content

Slow queries due to driver's emulate prepare #90

Closed
@nick-potts

Description

@nick-potts

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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions