Profiling Queries with SHOW STATUS
mysql> flush status;
mysql> select SQL_NO_CACHE count(*) from table;

– Check query plan now:

mysql> show status like 'Select%';

– Check engine operations:

mysql> show status like 'Handler%';

– Check if there was any ordering:

mysql> show status like 'Sort%';

– Check how many temporary tables have been created:

mysql> show status like 'Created%';

Read on »

Is a certain process running your CPU right into the ground? How do you find said process without picking your way through the ps aux results? With this command:

ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'

…at which point you can kill it with sudo kill -9.

./mysqld_safe --user=mysql --basedir=/usr/local/mysql-5.0.67-linux-x86_64-icc-glibc23
--ledir=/usr/local/mysql-5.0.67-linux-x86_64-icc-glibc23/bin --mysqld=mysqld
./mysqladmin ext -u root -p -ri60
./mysqladmin ext -u root -p -ri60 | grep tmp

The combination of FLUSH STATUS and SHOW SESSSION STATUS can be used to see what happens while MySQL executes a query. First, run FLUSH STATUS to reset session status variables to zero.

mysql> FLUSH STATUS;

mysql> SELECT COUNT(*) FROM TABLE;

Procedure to add a swap file

You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.

a) Login as the root user

b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):

# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

c) Set up a Linux swap area:

# mkswap /swapfile1

d) Activate /swapfile1 swap space immediately:

# swapon /swapfile1

e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:

# vi /etc/fstab

Append following line:

/swapfile1 swap swap defaults 0 0

So next time Linux comes up after reboot, it enables the new swap file for you automatically.

g) How do I verify swap is activated or not?

Simply use free command:

$ free -m

vi first  edit source file
then move your cursor to start of selection
ma       mark current position with letter a
then move your cursor to end of selection
y'a     yank to buffer x from current position to mark a
:e other  edit target file
move cursor to where you want the data
p       put from buffer x

Constructors

When you create a new instance (a new object) of a class using the new keyword, a constructor for that class is called. Constructors are used to initialize the instance variables (fields) of an object. Constructors are similar to methods, but with some important differences.

  • Constructor name is class name. A constructors must have the same name as the class its in.
  • Default constructor. If you don’t define a constructor for a class, a default parameterless constructor is automatically created by the compiler. The default constructor calls the default parent constructor (super()) and initializes all instance variables to default value (zero for numeric types, null for object references, and false for booleans).
  • Default constructor is created only if there are no constructors. If you define any constructor for your class, no default constructor is automatically created.
  • Differences between methods and constructors.
    • There is no return type given in a constructor signature (header). The value is this object itself so there is no need to indicate a return value.
    • There is no return statement in the body of the constructor.
    • The first line of a constructor must either be a call on another constructor in the same class (using this), or a call on the superclass constructor (using super). If the first line is neither of these, the compiler automatically inserts a call to the parameterless super class constructor.

    These differences in syntax between a constructor and method are sometimes hard to see when looking at the source. It would have been better to have had a keyword to clearly mark constructors as some languages do.

  • this(...) – Calls another constructor in same class. Often a constructor with few parameters will call a constructor with more parameters, giving default values for the missing parameters. Use this to call other constructors in the same class.
  • super(...). Use super to call a constructor in a parent class. Calling the constructor for the superclass must be the first statement in the body of a constructor. If you are satisfied with the default constructor in the superclass, there is no need to make a call to it because it will be supplied automatically.

To copy a block of text between files execute the commands:

Command Explaination
1. Edit the file containing the text you want to copy.
2. Go to the top line to be copied.
3. ma Mark this line as mark “a”.
4. Go to the bottom line to be copied
5. y'a Yank (y) the text from the current cursor location to the mark “a” ('a)
6. :split second-file Open another window containing the second file. (This the file in which the text is to be inserted.)
7. Go to the line where the insert is to occur. The text will be place after this line.
8. p Put the text after the cursor.

It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections .

strace -q -f -c -p

strace -f verbose=all -e write=all -o /tmp/strace.log -p [pid]

strace -T -t -q -f -e trace=file,open,close,read -o /tmp/prod.strace.log -p <oms or ui pid>

-f traces all child processes as they are created byt he currently traced process as a result of the fork() system call.

-e is a qualifying expression which modifies which events to trace or how to race them

verbose=all dereferences structures for all system calls

write=all performs a full hexadecimal and ASCII dump of all the data written to all file descriptors

-o output file

-p process id to trace

Replace -p [pid] with [command] to trace a specific command.