Laravel eloquent update record without loading from database

Laravel eloquent update record without loading from database

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Bypassing the Select Query in Laravel Eloquent

It is a common misconception that you must always retrieve a model instance from the database before modifying it. The standard pattern involves fetching the record, hydrating it, changing its properties, and then calling save(). While this works perfectly fine for most scenarios, it forces your application to execute an extra SQL SELECT query just to perform an update. If you are dealing with high-throughput forms or background jobs where latency matters, eliminating that unnecessary read operation can significantly improve performance.

The user's intuition in the provided snippet is partially correct but misses a critical constraint regarding Eloquent's internal state management. You cannot simply instantiate a model and assign an ID to it expecting save() to work as intended without modification:

$post = new Post();
$post->id = 3; 
$post->title = "Updated title";
$post->save(); // This will fail or behave unexpectedly

When Eloquent encounters a primary key on a fresh instance, it assumes the model represents a row that needs to be inserted. Consequently, calling save() on this object triggers an INSERT statement rather than an UPDATE. If you ignore this and force the save, Laravel will attempt to insert a record with an existing ID. Depending on your database constraints, this might throw a unique constraint violation error immediately upon execution.

To update a record without loading it from the database, you must explicitly tell Eloquent that the model already exists. This is done by calling the exists() method or setting the $exists property directly before saving. Here is the correct implementation pattern:

// Option 1: Using the exists() helper (Recommended)
$post = new Post();
$post->id = 3;
$post->title = "Updated title";
$post->save(['use_existing' => true]); // This flag isn't standard, see below for correct way

Actually, the most robust approach without fetching the row is to use the exists property or chain the find() logic differently. However, if you strictly want to avoid the SELECT query entirely, you can utilize the newQuery()->update() method, which operates at the raw SQL level but remains fluent:

Post::where('id', 3)->update(['title' => 'Updated title']);

If your business logic requires full model access (accessors, mutators, events) but you still want to skip the hydration, you can set the internal $exists flag. This tells Eloquent's save() method to generate an UPDATE statement instead of an INSERT:

$post = new Post();
$post->id = 3;
$post->title = "Updated title";
$post->exists = true; // Marks the model as existing in the database
$post->save();

By setting $post->exists = true, Eloquent generates SQL that looks like UPDATE posts SET title = '...' WHERE id = 3. This effectively bypasses the initial SELECT query.

Trade-offs and Considerations

While this optimization reduces latency, it comes with specific implications you should weigh carefully. The primary downside is the loss of data consistency checks performed by Eloquent's mass assignment protection during hydration. When you load a model, Laravel fills attributes that were previously null or empty but not explicitly set in your input. If you skip loading, you must ensure all required fields are provided in your update payload to avoid accidental overwrites of unrelated columns.

Additionally, any database triggers or foreign key constraints that rely on the current state of the row might behave differently if not fully loaded into memory first. For instance, if a model has touches relationships (timestamps updated by events), those events will still fire correctly because Eloquent knows the record exists, but you lose access to the previous values of attributes without an explicit load or custom logic.

If you are building complex applications where the distinction between "new" and "existing" models is blurred, it is often safer to stick to find() or firstOrCreate(). However, for simple form submissions where you know the ID exists, forcing the existence flag is a valid optimization that keeps your codebase lean. For more advanced scaling patterns or specific bulk operations, exploring how LaravelCompany handles high-performance updates might provide additional architectural insights relevant to your specific stack needs.

Our network