Posts

Showing posts from April, 2022

Finding Long Running Queries in Oracle Database

            It could be tricky to detect when your database slows down for no reason. At first, you should check system resources (CPU - RAM usage, network etc.) and if find some bottlenecks, then go deeper. ADDM report should be useful for detecting most problem causes.           But it is also probable that some queries may be using server resources excessively. How to detect them? Well, there is one simple query to check that: select s.sql_text,sl.sid,sl.target||'-'||sl.opname Target,sl.totalwork,sl.sofar,sl.time_remaining Seconds_remaining,sl.elapsed_seconds,sl.sql_id,sl.username from v$session_longops sl,v$sql s,v$session se where s1.sid=se.sid and se.sql_id=s.sql_id and totalwork!=0 and sofar<>totalwork;

Faster Way To Dump And Restore In Postgres

     In general, people find dumping their whole databases in sever by pg_dumpall easily. But it takes too long since this tool is not utilized for using resources efficiently. Thus, it's essential to uncompress and parallelize jobs while taking dumps in PostgreSQL databases via pg_dump. Example command:                pg_dump -Z0 -j 8 -Fd mydb -f dump_folder -Z0 means "no compress" and -j 8 means use 8 cores. When using pg_restore, similar approach is applied to maximize performance. pg_restore -Fd -O -j 8 -d mydb dump_folder               

Compressing / Decompressing Backup Files With Pigz

1. Check Required Packages Ensure the yum packages openssl and pigz are installed on your system. 2. Compress and Encrypt Files Use the following command to compress and encrypt files: tar -c -I pigz backup.dmp | openssl enc -aes-256-cbc -e -k mypassword > backup.tar.gz.enc 3. Decrypt and Decompress Files Use the following command to decrypt and decompress files: openssl enc -aes-256-cbc -d -in backup.tar.gz | tar -I pigz -x