Skip to main content

Welcome to DBA Master – Database Tips, Tricks, and Tutorials

Welcome to DBA Master ! This blog is dedicated to all things related to database administration , SQL optimization , and performance tuning . Whether you're a beginner or a seasoned DBA, you'll find practical guides, troubleshooting tips, and real-world tutorials to help you work smarter with data. What to Expect: SQL performance tuning tips Indexing strategies Backup and recovery best practices High availability and replication techniques Database creation, configuration, and setup Monitoring queries and scripts for proactive performance management Migration guides across different database platforms Security essentials and best practices Recommended tools for DBAs Real-world error fixes and how to solve them Stay tuned — exciting content is coming soon. Feel free to bookmark and share: www.dbamaster.com ! Thanks for visiting!

PostgreSQL Reporting Tools(PgBadger) Installation & Configuration

The PostgreSQL log analyzer “pgBadger” is an open source “fast PostgreSQL log analysis report” program written in Perl that takes the log output from a running PostgreSQL instance and processes it into an HTML file. 

                The report it generates shows all information found in a nice and easy to read report format. 

These reports can help shed light on errors happening in the system, checkpoint behavior, vacuum behavior, trends, and other basic but crucial information for a PostgreSQL system.

FEATURES:

 pgBadger reports everything about your SQL queries:

  1.         Overall statistics.
  2.         The most frequent waiting queries.
  3.         Queries that waited the most.
  4.         Queries generating the most temporary files.
  5.         Queries generating the largest temporary files.
  6.         The slowest queries.
  7.         Queries that took up the most time.
  8.         The most frequent queries.
  9.         The most frequent errors.
  10.         Histogram of query times.
  11.         Histogram of sessions times.
  12.         Users involved in top queries.
  13.         Applications involved in top queries.
  14.         Queries generating the most cancellation.
  15.         Queries most cancelled.

The following reports are also available with hourly charts divided into periods of five minutes:

  1.         SQL queries statistics.
  2.         Temporary file statistics.
  3.         Checkpoints statistics.
  4.         Autovacuum and autoanalyze statistics.
  5.         Cancelled queries.
  6.         Error events (panic, fatal, error and warning).
  7.         Error class distribution.

There are also some pie charts about distribution of:

  1.         Locks statistics.
  2.         Queries by type (select/insert/update/delete).
  3.         Distribution of queries type per database/application
  4.         Sessions per database/user/client/application.
  5.         Connections per database/user/client/application.
  6.         Autovacuum and autoanalyze per table.
  7.         Queries per user and total duration per user.

pgBadger is also able to parse PgBouncer log files and to create the following reports:

  1.         Request Throughput
  2.         Bytes I/O Throughput
  3.         Queries Average duration
  4.         Simultaneous sessions
  5.         Histogram of sessions times
  6.         Sessions per database
  7.         Sessions per user
  8.         Sessions per host
  9.         Established connections
  10.         Connections per database
  11.         Connections per user
  12.         Connections per host
  13.         Most used reserved pools
  14.         Most Frequent Errors/Events

How to install pgbadger:

[root@server1 bin]# yum install pgbadger

Bin Path:

/usr/bin/pgbadger

Configuration:

vi postgresql.conf

log_destination = 'stderr' or 'csvlog' or 'syslog'

log_directory = 'log'

log_min_duration_statement = 0 

log_checkpoints = on

log_connections = on

log_disconnections = on

log_lock_waits = on

log_temp_files = 0

log_autovacuum_min_duration = 0

log_error_verbosity = default

log_destination = ‘stderr’ or 'csvlog':

log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h '

log_destination = ‘syslog’:

log_line_prefix = 'user=%u,db=%d,app=%aclient=%h '

log_statement = 'all'

lc_messages='C'

PgBadger Options:

-b | --begin datetime  : start date/time for the data to be parsed in log

-e | --end datetime    : end date/time for the data to be parsed in log

-f | --format logtype  : possible values: syslog, stderr, jsonlog, cvs

-d | --dbname database : only report on entries for the given database

-h | --help            : show this message and exit.

-o | --outfile filename: define the filename for the output. Default depends

                 on the output format: out.html

Run pgbadger Tool:

[root@server1 ~]# pgbadger /var/lib/pgsql/10/data/log/* -o /zzz/report.html

[========================>] Parsed 5961992 bytes of 5961992 (100.00%), queries: 34125, events: 107

LOG: Ok, generating html report...


Comments

Popular posts from this blog

Oracle Database 19C Performance Tunning - PART 1

Advantages: 1. Improved Query Performance •    Optimized SQL execution plans lead to faster query response times. •    Reduces unnecessary full table scans and improves indexing strategies. •    Parallel execution tuning speeds up large data processing tasks. 2. Better Resource Utilization •    Efficient use of CPU, memory, disk I/O, and network resources. •    Reduces contention on Redo Logs, Undo Tablespaces, and Buffer Cache. •    Helps in load balancing across multiple instances in RAC (Real Application Clusters). 3. Increased System Scalability •    Ensures that the database can handle a growing number of users and transactions. •    Proper tuning allows scaling without degrading performance. •    Optimized parallel processing ensures better performance on multi-core servers. 4. Lower Infrastructure Costs •    Reduces the need for add...

Oracle RMAN Backup And Restore

RMAN: (Oracle 8) RMAN (Recovery Manager) is a utility provided by Oracle Database to perform backup, restore, and recovery operations. It is a command line tool. Features of RMAN in Oracle 19c Comprehensive Backup Capabilities: Full and incremental backups. Block-level backups for efficient data storage. Archived redo log backups. Fast Recovery Area (FRA) integration for centralized backup storage. Efficient Recovery Options: Point-in-time recovery (PITR). Complete and incomplete recovery. Flashback database capabilities for quick undo of changes. Multitenant Database Support: RMAN fully supports container databases (CDBs) and pluggable databases (PDBs). Provides flexibility to back up and recover individual PDBs or entire CDBs. Automatic Space Management: Manages disk space in the FRA. Automatically deletes obsolete backups and archived logs. Data Deduplication and Compression: Backup optimization through block-level deduplication. Built-in compression algorithms to reduce storage req...

Oracle 19c Database Software Installation in OEL8

 Pre-requisites for OS level:            Set the static IP Address     Disable the Firewall (systemctl stop firewalld & systemctl disable firewalld)     set SELINUX=permissive on /etc/selinux/config  ##Need to restart the server use init 6 Oracle Installation Pre-requisites Methods     Automatic Setup     Manual Setup      Automatic requisites Setup: (avoid step 1 to step 5): dnf install -y oracle-database-preinstall-19c Install the dependencies: curl -o oracle-database-preinstall-19c-1.0-2.el8.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64/getPackage/oracle-database-preinstall-19c-1.0-2.el8.x86_64.rpm dnf -y localinstall oracle-database-preinstall-19c-1.0-2.el8.x86_64.rpm Manual Setup: step 1: Add the karenl parameters and values vi /etc/sysctl.conf     fs.file-max = 6815744 kernel.sem = 250 32000 100 128 kernel....