PHPackages                             trogers1884/laravel-mvstats - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. trogers1884/laravel-mvstats

ActiveLibrary[Database &amp; ORM](/categories/database)

trogers1884/laravel-mvstats
===========================

Laravel package for PostgreSQL statistics

v1.0.1(1y ago)04MITPHPPHP ^8.1|^8.2|^8.3

Since Dec 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/trogers1884/laravel-mvstats)[ Packagist](https://packagist.org/packages/trogers1884/laravel-mvstats)[ RSS](/packages/trogers1884-laravel-mvstats/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

Laravel PostgreSQL Materialized View Statistics
===============================================

[](#laravel-postgresql-materialized-view-statistics)

A Laravel package that automatically tracks and manages statistics for PostgreSQL materialized views.

Features
--------

[](#features)

- Automatically tracks creation, modification, and refresh operations on materialized views
- Records refresh durations, counts, and timestamps
- Provides statistics through an easy-to-query view
- Includes Artisan commands for statistics management
- Supports PostgreSQL 12 or later
- Compatible with Laravel 10+
- Requires PHP 8.1+

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require trogers1884/laravel-mvstats
```

The package will automatically register its service provider.

### Requirements

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.0 or higher
- PostgreSQL 12.0 or higher

### Database Objects Created

[](#database-objects-created)

This package creates the following database objects:

1. Tables:

    - `public.tr1884_mvstats_tbl_matv_stats` - Base statistics table
2. Views:

    - `public.tr1884_mvstats_vw_matv_stats` - Formatted view of statistics
3. Functions:

    - `public.tr1884_mvstats_fn_mv_activity_init()` - Initializes tracking for existing materialized views
    - `public.tr1884_mvstats_fn_mv_activity_reset_stats()` - Resets statistics
    - Several internal trigger functions
4. Event Triggers:

    - Triggers for tracking materialized view operations

Usage
-----

[](#usage)

### Viewing Statistics

[](#viewing-statistics)

Once installed, the package automatically tracks all materialized view operations. You can query the statistics view:

```
SELECT * FROM public.tr1884_mvstats_vw_matv_stats;
```

The view provides the following columns:

- `mv_name` - Name of the materialized view (schema.name format)
- `create_mv` - Creation timestamp
- `mod_mv` - Last modification timestamp
- `refresh_mv_last` - Last refresh timestamp
- `refresh_count` - Number of refreshes
- `refresh_mv_time_last` - Duration of last refresh
- `refresh_mv_time_total` - Total refresh time
- `refresh_mv_time_min` - Minimum refresh duration
- `refresh_mv_time_max` - Maximum refresh duration
- `reset_last` - Last statistics reset timestamp

### Artisan Commands

[](#artisan-commands)

#### Reset Statistics

[](#reset-statistics)

Reset statistics for a specific materialized view:

```
php artisan mvstats:reset-stats schema.view_name
```

Reset statistics for all materialized views:

```
php artisan mvstats:reset-stats --all
```

### Examples

[](#examples)

Query views that haven't been refreshed in the last 24 hours:

```
SELECT mv_name, refresh_mv_last
FROM public.tr1884_mvstats_vw_matv_stats
WHERE refresh_mv_last  0
ORDER BY avg_refresh_time DESC;
```

Uninstallation
--------------

[](#uninstallation)

### Option 1: Keep Historical Data

[](#option-1-keep-historical-data)

1. Remove the package:

```
composer remove trogers1884/laravel-mvstats
```

2. The database objects will remain for historical reference.

### Option 2: Complete Removal

[](#option-2-complete-removal)

1. First, remove all database objects:

```
SELECT public.tr1884_mvstats_fn_mv_drop_objects();
```

2. Then remove the package:

```
composer remove trogers1884/laravel-mvstats
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please see [SECURITY.md](SECURITY.md) for reporting procedures.

Credits
-------

[](#credits)

- [Tom Rogers](https://github.com/trogers1884)
- Jeremy Gleed (jeremy\_gleed at yahoo.com)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance40

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

514d ago

PHP version history (2 changes)v1.0.0PHP ^8.1

v1.0.1PHP ^8.1|^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/33fdd133f51e6eff6096d0dd0b15dd11184caa054ed0d7e1c70a1e8d5080a5c7?d=identicon)[trogers1884](/maintainers/trogers1884)

---

Top Contributors

[![trogers1884](https://avatars.githubusercontent.com/u/641590?v=4)](https://github.com/trogers1884 "trogers1884 (9 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/trogers1884-laravel-mvstats/health.svg)

```
[![Health](https://phpackages.com/badges/trogers1884-laravel-mvstats/health.svg)](https://phpackages.com/packages/trogers1884-laravel-mvstats)
```

###  Alternatives

[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[aglipanci/laravel-eloquent-case

Adds CASE statement support to Laravel Query Builder.

115157.2k](/packages/aglipanci-laravel-eloquent-case)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
