sudo pacman -Syu 2024-11-18 11:55:10 +07:00
parent aa75f90264
commit 4b18abf9ec
4 changed files with 53 additions and 15 deletions

View File

@ -205,17 +205,17 @@
<pre><span class="pl-k">CREATE</span> <span class="pl-k">INDEX</span> <span class="pl-en">idx_user_id_created_at</span>
<span class="pl-k">ON</span> user_upload (user_id, created_at);
<span class="pl-c"><span class="pl-c">--</span> Do not</span>
<span class="pl-c"><span class="pl-c">--</span> Bad</span>
<span class="pl-k">SELECT</span> <span class="pl-k">*</span>
<span class="pl-k">FROM</span> user_upload
<span class="pl-k">ORDER BY</span> user_id, created_at <span class="pl-k">DESC</span>;
<span class="pl-c"><span class="pl-c">--</span> Do</span>
<span class="pl-c"><span class="pl-c">--</span> Good</span>
<span class="pl-k">SELECT</span> <span class="pl-k">*</span>
<span class="pl-k">FROM</span> user_upload
<span class="pl-k">ORDER BY</span> user_id <span class="pl-k">DESC</span>, created_at <span class="pl-k">DESC</span>;
<span class="pl-c"><span class="pl-c">--</span> Or do</span>
<span class="pl-c"><span class="pl-c">--</span> Also good</span>
<span class="pl-k">SELECT</span> <span class="pl-k">*</span>
<span class="pl-k">FROM</span> user_upload
<span class="pl-k">ORDER BY</span> user_id, created_at;</pre>
@ -390,6 +390,27 @@
database reality :)
</li>
</ul>
<div class="markdown-heading">
<h2 class="heading-element">Pastebin</h2>
<a
id="user-content-pastebin"
class="anchor"
aria-label="Permalink: Pastebin"
href="#pastebin"
><span aria-hidden="true" class="octicon octicon-link"></span
></a>
</div>
<p>
<a href="https://stackoverflow.com/a/5213364" rel="nofollow"
>Show index of table</a
>:
</p>
<div class="highlight highlight-source-sql">
<pre><span class="pl-k">SELECT DISTINCT</span>
table_name,
index_name
<span class="pl-k">FROM</span> <span class="pl-c1">information_schema</span>.<span class="pl-c1">statistics</span>;</pre>
</div>
<div class="markdown-heading">
<h2 class="heading-element">Thanks</h2>
<a

View File

@ -583,11 +583,6 @@
></a>
</div>
<ul>
<li>
<a href="https://theunarchiver.com/" rel="nofollow"
>https://theunarchiver.com/</a
>
</li>
<li>
<a href="https://github.com/iina/iina">https://github.com/iina/iina</a>
</li>
@ -656,12 +651,17 @@
>https://sourceforge.net/projects/skim-app/</a
>
</li>
<li>
<a href="https://github.com/alienator88/Pearcleaner"
>https://github.com/alienator88/Pearcleaner</a
>
</li>
</ul>
<p><del>Memory</del></p>
<ul>
<li>
<a href="https://github.com/linearmouse/linearmouse"
>https://github.com/linearmouse/linearmouse</a
<a href="https://theunarchiver.com/" rel="nofollow"
>https://theunarchiver.com/</a
>
</li>
<li>
@ -669,6 +669,11 @@
>https://www.tunabellysoftware.com/balance_lock/</a
>
</li>
<li>
<a href="https://github.com/linearmouse/linearmouse"
>https://github.com/linearmouse/linearmouse</a
>
</li>
<li>
<a href="https://github.com/tuyenvm/OpenKey"
>https://github.com/tuyenvm/OpenKey</a

View File

@ -79,17 +79,17 @@ not mix:
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;
@ -166,6 +166,17 @@ Use `SELECT 1` to check if database failed yet.
- Use [k1LoW/tbls](https://github.com/k1LoW/tbls) to grasp your database reality
:)
## Pastebin
[Show index of table](https://stackoverflow.com/a/5213364):
```sql
SELECT DISTINCT
table_name,
index_name
FROM information_schema.statistics;
```
## Thanks
- [Use The Index, Luke](https://use-the-index-luke.com/)

View File

@ -112,7 +112,6 @@ For fun
#### macOS
- https://theunarchiver.com/
- https://github.com/iina/iina
- https://github.com/rxhanson/Rectangle
- https://github.com/waydabber/BetterDisplay
@ -126,11 +125,13 @@ For fun
- https://github.com/jordanbaird/Ice
- https://github.com/zed-industries/zed
- https://sourceforge.net/projects/skim-app/
- https://github.com/alienator88/Pearcleaner
~~Memory~~
- https://github.com/linearmouse/linearmouse
- https://theunarchiver.com/
- https://www.tunabellysoftware.com/balance_lock/
- https://github.com/linearmouse/linearmouse
- https://github.com/tuyenvm/OpenKey
- https://github.com/objective-see/LuLu
- https://github.com/ivoronin/TomatoBar