• Home
  • Services
    • HR Services
      • HR Advisory Services
      • Contract Staffing
      • HR Outsourcing Services
      • Manpower Supply Services
      • Payroll Processing
      • Permanent Placement
      • Recruitment and Placement Services
      • Recruitment Process Outsourcing
      • Staffing Agency Services
    • DBA Support
      • DBA Consultancy Services
      • PostgreSQL Support
    • Website Maintenance
    • Company Registration Services
    • Virtual Office Space Address
  • Company
    • FAQs
    • About Us
    • Contact
  • Locations
  • Blogs
    • Blog
    • Blog – PostgreSQL Support
    • Blog – PostgreSQL Migration
    • Blog – All DB’s
    • Blog – Linux
  • Courses

    About Courses

    • List Of Courses
    • Become an Instructor
    Greenplum

    Greenplum

    $1,500.00
    Read More
    Have any question?
    (+91)8838953252
    ITsupport@rayafeel.com
    Login
    RayaFeeL
    • Home
    • Services
      • HR Services
        • HR Advisory Services
        • Contract Staffing
        • HR Outsourcing Services
        • Manpower Supply Services
        • Payroll Processing
        • Permanent Placement
        • Recruitment and Placement Services
        • Recruitment Process Outsourcing
        • Staffing Agency Services
      • DBA Support
        • DBA Consultancy Services
        • PostgreSQL Support
      • Website Maintenance
      • Company Registration Services
      • Virtual Office Space Address
    • Company
      • FAQs
      • About Us
      • Contact
    • Locations
    • Blogs
      • Blog
      • Blog – PostgreSQL Support
      • Blog – PostgreSQL Migration
      • Blog – All DB’s
      • Blog – Linux
    • Courses

      About Courses

      • List Of Courses
      • Become an Instructor
      Greenplum

      Greenplum

      $1,500.00
      Read More

      Blog

      • Home
      • Blog
      • Blog
      • Script For Finding slow Running Query and Most CPU Utilization Query Using Top command PID

      Script For Finding slow Running Query and Most CPU Utilization Query Using Top command PID

      • Posted by Nijamutheen J
      • Categories Blog
      • Date January 16, 2019
      • Comments 0 comment

      This script is very useful after Issue top command you will get PID which one Process taken More CPU Utilization  example for  32696 is the most CPU utilization process means take the PID then run the following script it will prompt “Enter the value Of PID” then give PID as 32696 you will get query then take the explain plan for that particular query then do Performance Tuning.

      bash-4.1$ cat givepid.sh
      HOSTNAME=`hostname`
      PSQL="/opt/PostgreSQL/9.3/bin/psql"
      PORT=5432
      HOST="localhost"
      DB="template1"
      echo "Enter the value of PID";
      read pid
      $PSQL -d $DB -U $USER -p $PORT <<EOF
      \pset format wrapped
      SELECT now() - query_start as "runtime",state,query from pg_stat_activity WHERE pid= $pid;
      EOF
      exit 0;
      
      OUTPUT:
      Enter the value of PID
      32696
      Output format is wrapped.
          runtime     | state  |                                                                       query
      ----------------+--------+---------------------------------------------------------------------------------------------------------------------------------------------------
       00:00:01.93486 | active | select   timestatus::date from mhrornad_akl.edit_mut_new_audit WHERE ccode='270100010000760000' and report_status='Generated' and edit_mut_no=214
      (1 row)

      • Share:
      Nijamutheen J
      Nijamutheen J

      Nijamutheen J 7+ years of experience in PostgreSQL, Linux admin , web hosting - apache server , Oracle ,mySQL, Mriadb, vertica DB & Server security administrator

      My updated resume is https://www.tutorialdba.com/p/hi-i-have-4.html

      Previous post

      How to work with Linux top command ?
      January 16, 2019

      Next post

      Simple & Best Postgres Free Monitoring Script
      January 16, 2019

      Leave A Reply

      You must be logged in to post a comment.

      Connect with



      Search

      ADVERTISEMENT

      Latest Posts

      Don’t See What You’re Looking For? We’ll Customize a Package to Fit Your Business Office space!
      14May2022
      Need an Address, Phone Number, And Virtual Office In Chennai?
      14May2022
      Rayafeel Technologies can provide you with ideal meeting solutions
      14May2022
      Virtual Offices VS. Coworking Spaces: What’s The Difference?
      14May2022
      SQL Manager for Oracle Type 6 – 10
      13May2022
      PostgreSQL

      PostgreSQL

      $800.00 $500.00
      Greenplum

      Greenplum

      $1,500.00
      Oracle Database

      Oracle Database

      $350.00
      2ndquadrant.in

      (+91) 8838953252

      ITsupport@rayafeel.com

      Company

      • About Us
      • Our Team

      COURSES

      • List Of Course
      • Become An Instructor

      Support

      • DBA Support
      • Consultancy Services

      Recommend

      • Login
      • Contact Us

      IT Services by rayafeel.com. Powered by Rayafeel Technologies Pvt Ltd.

      • Privacy
      • Terms

      Become An Instructor?

      Join thousand of instructors and earn money hassle free!

      Get Started Now

      Connect with

      Login with Google Login with Twitter Login with Linkedin Login with Windowslive Login with Yahoo

      Login with your site account

      Connect with



      Lost your password?