Skip to content

Instantly share code, notes, and snippets.

View simonrenoult's full-sized avatar
🏠
Working from home

Simon Renoult simonrenoult

🏠
Working from home
View GitHub Profile
View .zshrc
export PATH=$HOME/bin:/usr/local/bin:$PATH
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="avit"
HYPHEN_INSENSITIVE="true"
COMPLETION_WAITING_DOTS="true"
plugins=(autojump common-aliases docker extract httpie docker docker-compose kubectl)
source $ZSH/oh-my-zsh.sh
View HealthcheckApi.java
@RestController
public class HealthcheckApi {
private final SayImAlive sayImAlive;
public HealthcheckApi(SayImAlive sayImAlive) {
this.sayImAlive = sayImAlive;
}
@RequestMapping(value = "/healthcheck")
View script.sh
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o xtrace
# Script goes here...
View explain_select_with_quotes.sql
mysql> EXPLAIN SELECT SQL_NO_CACHE * FROM articles WHERE article_id = '150001';
+----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
| 1 | SIMPLE | articles | NULL | const | PRIMARY | PRIMARY | 34 | const | 1 | 100.00 | NULL |
+----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
1 row in set, 1 warning (0.00 sec)
View select_with_quotes.sql
mysql> SELECT SQL_NO_CACHE * FROM articles WHERE article_id = '150000';
+------------+---------------+-----------------+
| article_id | article_title | article_content |
+------------+---------------+-----------------+
| 150000 | Title 150000 | Content 150000 |
+------------+---------------+-----------------+
1 row in set (0.00 sec)
View select_without_quote.sql
mysql> SELECT SQL_NO_CACHE * FROM articles WHERE article_id = 150000;
View article.java
class Article {
private Integer article_id;
private String article_title;
private String article_content;
}
View explain_ignore_index.sql
mysql> EXPLAIN SELECT SQL_NO_CACHE * FROM articles IGNORE INDEX(PRIMARY) WHERE article_id = 150000;
+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+-------------+
| 1 | SIMPLE | articles | NULL | ALL | NULL | NULL | NULL | NULL | 996520 | 10.00 | Using where |
+----+-------------+----------+------------+------+---------------+------+---------+------+--------+----------+-------------+
1 row in set, 2 warnings (0.00 sec)
View ignore_index.sql
mysql> SELECT SQL_NO_CACHE * FROM articles IGNORE INDEX(PRIMARY) WHERE article_id = 150000;
+------------+---------------+-----------------+
| article_id | article_title | article_content |
+------------+---------------+-----------------+
| 150000 | Title 150000 | Content 150000 |
+------------+---------------+-----------------+
1 row in set, 1 warning (0.65 sec)
View use_primary.sql
mysql> SELECT SQL_NO_CACHE * FROM articles USE INDEX(PRIMARY) WHERE article_id = 150000;
+------------+---------------+-----------------+
| article_id | article_title | article_content |
+------------+---------------+-----------------+
| 150000 | Title 150000 | Content 150000 |
+------------+---------------+-----------------+
1 row in set (0.62 sec)