From 4b18abf9ecabe1b81ffaf2f1cb80896cd0cb807a Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Mon, 18 Nov 2024 11:55:10 +0700 Subject: [PATCH] sql --- docs/2022-07-31-sql.html | 27 ++++++++++++++++++++++++--- docs/2023-06-25-useful-tools.html | 19 ++++++++++++------- posts/2022-07-31-sql.md | 17 ++++++++++++++--- posts/2023-06-25-useful-tools.md | 5 +++-- 4 files changed, 53 insertions(+), 15 deletions(-) diff --git a/docs/2022-07-31-sql.html b/docs/2022-07-31-sql.html index 7e00638..5af1d04 100644 --- a/docs/2022-07-31-sql.html +++ b/docs/2022-07-31-sql.html @@ -205,17 +205,17 @@
CREATE INDEX idx_user_id_created_at
     ON user_upload (user_id, created_at);
 
--- Do not
+-- Bad
 SELECT *
 FROM user_upload
 ORDER BY user_id, created_at DESC;
 
--- Do
+-- Good
 SELECT *
 FROM user_upload
 ORDER BY user_id DESC, created_at DESC;
 
--- Or do
+-- Also good
 SELECT *
 FROM user_upload
 ORDER BY user_id, created_at;
@@ -390,6 +390,27 @@ database reality :) +
+

Pastebin

+ +
+

+ Show index of table: +

+
+
SELECT DISTINCT
+    table_name,
+    index_name
+FROM information_schema.statistics;
+

Thanks

Memory