PHP code example of sapronovps / pgsqlindexanalyzer

1. Go to this page and download the library: Download sapronovps/pgsqlindexanalyzer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sapronovps / pgsqlindexanalyzer example snippets




use Sapronovps\PgsqlIndexAnalyzer\Connection\Connection;
use Sapronovps\PgsqlIndexAnalyzer\Option\Options;
use Sapronovps\PgsqlIndexAnalyzer\PgsqlIndexAnalyzer;

// Create options as array OR with Options class.
 
$options = [
'host' => 'localhost',
'dbName' => 'postgresql',
'user' => 'postgresql',
'password' => 'secretPassword',
];

// OR 
$options = new Options();
$options->setHost('localhost')
        ->setDbName('postgresql')
        ->setUser('postgresql')
        ->setPassword('secretPassword');
        
$connection = new Connection($options);

$pgsqlIndexAnalyzer = new PgsqlIndexAnalyzer($connection);

$tables = [
'table1',
'table2',
'table3',
];

$allIndexes = $pgsqlIndexAnalyzer->allIndexesByTables($tables);

$tables = [
'table1',
'table2',
'table3',
];

$unusedIndexesByTables = $pgsqlIndexAnalyzer->unusedIndexesByTables($tables);

$tables = [
'table1',
'table2',
'table3',
];

$overlappingIndexesByTables = $pgsqlIndexAnalyzer->overlappingIndexesByTables($tables);

$tables = [
'table1',
'table2',
'table3',
];

$indexesContainsInOtherIndexesByTables = $pgsqlIndexAnalyzer->indexesContainsInOtherIndexesByTables($tables);