Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Materialized View

Materialized View Laravel Package

th3mouk/materialized-view

Laravel package for creating and refreshing database materialized views via migrations and Artisan commands. It offers a simple way to cache expensive query results, but has few users and little maintenance activity, so vet it before production use.

Deep Wiki
Context7

th3mouk/materialized-view brings materialized views to Laravel applications, letting you precompute and cache expensive query results as real database tables. Since MySQL lacks native materialized view support, this package provides an elegant, Eloquent-friendly way to define views and keep them refreshed—dramatically speeding up dashboards and reporting queries.

  • Fluent schema builder for defining materialized views
  • Simple refresh commands and scheduled updates
  • Seamless Eloquent integration for querying cached views
  • Configurable refresh strategies for full or atomic rebuilds
  • Artisan commands for creating and managing views
Frequently asked questions about Materialized View
How do I install and configure th3mouk/materialized-view in Laravel?
Run composer require th3mouk/materialized-view in the Laravel project. Laravel package auto-discovery should register the service provider; if your app disables discovery, add the provider manually. Publish any package configuration if the install docs provide it, then point the package at a PostgreSQL connection and your SQL definition directory.
Does th3mouk/materialized-view require PostgreSQL, or can I use MySQL?
Based on the package description, it is PostgreSQL-native and manages PostgreSQL materialized views through Doctrine DBAL. It is not a MySQL materialized-view implementation. For MySQL you would need summary tables plus scheduled jobs or a different caching strategy.
What are good use cases for materialized views in Laravel?
Use it for expensive reporting queries, dashboards, search summaries, and denormalized read models where slightly stale results are acceptable. Materialized views keep repeated aggregation work off source tables by serving precomputed rows. Refresh on a schedule or after relevant data changes.
How do I create, synchronise, and refresh materialized views with Artisan?
The package provides Artisan commands to create, synchronise, rebuild, refresh, and drop cached materialized views. After installation, run php artisan list to see the exact command names and options exposed by your installed version. Use refresh for routine data updates and rebuild or synchronise when the SQL definition changes.
How does versioned SQL definition and rebuild work in this package?
SQL definitions are versioned files, so materialized view changes can be reviewed and tracked like other schema changes. Synchronise applies the current definitions, while rebuild recreates views when the underlying SQL changes. Keep definitions in source control and run the commands in deployment or migration steps.
Can I refresh a PostgreSQL materialized view concurrently?
Yes, PostgreSQL supports REFRESH MATERIALIZED VIEW CONCURRENTLY, and the package description lists concurrent refresh as a feature. Concurrent refresh usually requires a unique index on the view and can still block in some cases. Use it for production views where blocking regular refreshes would hurt readers.
How do I schedule materialized view refreshes and handle production concerns?
Schedule the package's refresh Artisan command with Laravel's scheduler and run it after source-data updates or at a cadence your dashboard can tolerate. In production, monitor refresh duration, lock contention, disk usage, and staleness, and use concurrent refresh where the view supports it. Avoid refreshing large views during peak traffic unless you have tested the impact.
Which Laravel and PHP versions are supported, and is the package maintained?
Check the package's composer.json and repository release history for exact Laravel and PHP constraints, because those details are not available in the provided context. The package targets PostgreSQL via Doctrine DBAL, so confirm your Laravel version and database driver match before adopting. Pin a tested version and review changelogs before upgrading in production.
How should I test materialized views in a Laravel application?
Use a PostgreSQL test database because the feature relies on PostgreSQL materialized views and Doctrine DBAL. In test setup, run migrations, synchronise the view definitions, and seed source tables. Then assert the view contents or Artisan command results; SQLite is not a suitable substitute for integration coverage.
What are alternatives to th3mouk/materialized-view for caching expensive Laravel queries?
Alternatives include Laravel's cache with Redis or database stores, manually managed PostgreSQL materialized views, summary tables maintained by queued jobs, and query-result caching packages. Choose this package when you want versioned SQL definitions plus Artisan-driven synchronise, rebuild, and concurrent refresh. For non-PostgreSQL databases, use a summary-table or cache-based approach instead.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections