Framework: Multiple Queries for same statement

Created on 31 Dec 2017  路  3Comments  路  Source: laravel/framework

Environment:

  • Laravel Version: 5.5.28
  • PHP Version: /
  • Database Driver & Version: mysql

Description:

Also within the same controller and same request (only one page called) the same DB/SQL Statement is fired multiple times. Shouldn't be there a kind of caching? Not necessarily across multiple page calls but within one instance of an model.

laravel_translations_queries

Steps To Reproduce:

  1. Create a Eloquent Model on a MySQL Database.
  2. Build a controller which calls this model and run multiple times the ::find(1) method.
  3. You will that the DB Query is fired multiple times also in the same page request.

Question:

When Laravel has this caching not as default, there are packages out which do model caching, but how to influence vendors model? How can I overwrite the default Laravel Model class IlluminateDatabaseEloquentModel?

All 3 comments

This repo is for bug tracking. Use the forums or slack channel for solving your issue

No, there is no such caching in Eloquent. The Eloquent models are just wrappers against database access. How can you be sure that querying twice will return identical data? What if you've written something to the database between two calls to ::find()?

Please ask on the forums, this repo is for bug reporting only. You can use https://laracasts.com/discuss or https://laravel.io/forum which are forums with a very large community of developers helping each other.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Demers94 picture Demers94  路  88Comments

GrahamCampbell picture GrahamCampbell  路  139Comments

MountainDev picture MountainDev  路  128Comments

JosephSilber picture JosephSilber  路  176Comments

PheRum picture PheRum  路  112Comments