Shorts

0 articles found

How to watch Redis activity

Solution

Run:

$ redis-cli

Then, type MONITOR.

RabbitMQ – See connections

Solution

$ rabbitmqctl list_connections

 

MySQL Dump with condition

Solution

mysqldump -u root -p pass my_database my_table --where="id IN (100, 101)" > my_table_dump.sql

 

MySQL – Search for tables by column name

Solution

SELECT DISTINCT TABLE_NAME 
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%name%'
    AND TABLE_SCHEMA = 'my_database';

 

MySQL Query – Export result to CSV

Solution

mysql -u user -p pass -B -e "SELECT * FROM blog_post WHERE title LIKE '%MySQL%'" > output_file.csv

 

How to see how much disk space a MySQL table is taking up?

Solution

SELECT
    table_schema as `Database`,
    table_name AS `Table`, 
    ROUND(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES 
ORDER BY (data_length + index_length) DESC;

 

MySQL Query – Disable cache

Solution

Add SQL_NO_CACHE right after SELECT in any query. E.g.:

SELECT SQL_NO_CACHE * FROM post WHERE post.title LIKE '%MySQL%'

 

Measure the running time of a command

Solution

$ time any-command-to-run