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 more…
Admin MySQL
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.
Admin Linux, Unix ps
1
2
| ./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 |
1
2
| ./mysqladmin ext -u root -p -ri60
./mysqladmin ext -u root -p -ri60 | grep tmp |
Admin Linux, MySQL Upgrade MySQL
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;
Admin MySQL performance
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
Admin Linux swap
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
Admin Linux
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.
Admin J2EE Constractor
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. |
Admin Linux vi