定制 zvook/php-postgresql-stat 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

zvook/php-postgresql-stat

Composer 安装命令:

composer require zvook/php-postgresql-stat

包简介

PHP PostgreSQL statistic monitoring tool

README 文档

README

Latest Stable Version Total Downloads License

Requirements

  • PHP 5.6+
  • PostgreSQL 9.2+ (9.5+ recommended)

Containing

  • Database statistic
  • Tables statistic
  • Indexes statistic
  • Functions statistic
  • Statements
  • Useless/Missing indexes analytic

Installation

  • Update your postgresql.conf
shared_preload_libraries = 'pg_stat_statements'
track_counts = on #enabled by default
track_functions = on #if you need it
track_io_timing = on #optional
  • Then connect to the database you want to track with user you will use to connect (not with postgres user!) and run:
CREATE EXTENSION pg_stat_statements

!Please note that you should run SQL above exactly inside your database and exactly by your backend user

  • Restart postgre server
  • Add to your composer.json
"require": {
    "zvook/php-postgresql-stat": "*"
}
  • Run
$ composer update

Demo

When package installed and postgreSQL configured you can build demo page to observe the situation. Go to the package root directory and edit demo.php with your database credentials. Then run:

php demo.php > demo.html

Open demo.html with browser

Basic Usage

!Please not that pg_stat_statements needs a time for collecting statistic to provide you adequate information

use zvook\PostgreStat;

$dbName = 'my_db';
$dbUser = 'my_user';
$dbPass = 'my_pass';

$pgStat = new PgStat($dbName, $dbUser, $dbPass);

# Get basic DB statistic
# Returns instance of zvook\PostgreStat\Models\DbStat
$pgStat->getDbStat();

# Get detailed tables statistic
# Returns an array of zvook\PostgreStat\Models\TableStat instances
$pgStat->getTablesStat();

# Get user functions statistic
# Returns an array of zvook\PostgreStat\Models\FunctionStat instances
$pgStat->getFunctionsStat();

# Get indexes statistic
# Returns an array of zvook\PostgreStat\Models\IndexStat instances
$pgStat->getIndexesStat();

# Get statements
# Returns an array of zvook\PostgreStat\Models\StatementStat instances
$pgStat->getStatementsStat();

# Get useless indexes (analytic)
# Returns the same as getIndexesStat()
$pgStat->getUselessIndexes();

# Get missing indexes (analytic)
# Returns the same as getTablesStat()
$pgStat->getLowIndexUsageTables();

Also you can find complete usage example in demo.php in the root dir of the package

Information

统计信息

  • 总下载量: 45
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固