sql
parent
aa75f90264
commit
4b18abf9ec
|
@ -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>
|
<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-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">SELECT</span> <span class="pl-k">*</span>
|
||||||
<span class="pl-k">FROM</span> user_upload
|
<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-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">SELECT</span> <span class="pl-k">*</span>
|
||||||
<span class="pl-k">FROM</span> user_upload
|
<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-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">SELECT</span> <span class="pl-k">*</span>
|
||||||
<span class="pl-k">FROM</span> user_upload
|
<span class="pl-k">FROM</span> user_upload
|
||||||
<span class="pl-k">ORDER BY</span> user_id, created_at;</pre>
|
<span class="pl-k">ORDER BY</span> user_id, created_at;</pre>
|
||||||
|
@ -390,6 +390,27 @@
|
||||||
database reality :)
|
database reality :)
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</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">
|
<div class="markdown-heading">
|
||||||
<h2 class="heading-element">Thanks</h2>
|
<h2 class="heading-element">Thanks</h2>
|
||||||
<a
|
<a
|
||||||
|
|
|
@ -583,11 +583,6 @@
|
||||||
></a>
|
></a>
|
||||||
</div>
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
|
||||||
<a href="https://theunarchiver.com/" rel="nofollow"
|
|
||||||
>https://theunarchiver.com/</a
|
|
||||||
>
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/iina/iina">https://github.com/iina/iina</a>
|
<a href="https://github.com/iina/iina">https://github.com/iina/iina</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -656,12 +651,17 @@
|
||||||
>https://sourceforge.net/projects/skim-app/</a
|
>https://sourceforge.net/projects/skim-app/</a
|
||||||
>
|
>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://github.com/alienator88/Pearcleaner"
|
||||||
|
>https://github.com/alienator88/Pearcleaner</a
|
||||||
|
>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p><del>Memory</del></p>
|
<p><del>Memory</del></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/linearmouse/linearmouse"
|
<a href="https://theunarchiver.com/" rel="nofollow"
|
||||||
>https://github.com/linearmouse/linearmouse</a
|
>https://theunarchiver.com/</a
|
||||||
>
|
>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
@ -669,6 +669,11 @@
|
||||||
>https://www.tunabellysoftware.com/balance_lock/</a
|
>https://www.tunabellysoftware.com/balance_lock/</a
|
||||||
>
|
>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="https://github.com/linearmouse/linearmouse"
|
||||||
|
>https://github.com/linearmouse/linearmouse</a
|
||||||
|
>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://github.com/tuyenvm/OpenKey"
|
<a href="https://github.com/tuyenvm/OpenKey"
|
||||||
>https://github.com/tuyenvm/OpenKey</a
|
>https://github.com/tuyenvm/OpenKey</a
|
||||||
|
|
|
@ -79,17 +79,17 @@ not mix:
|
||||||
CREATE INDEX idx_user_id_created_at
|
CREATE INDEX idx_user_id_created_at
|
||||||
ON user_upload (user_id, created_at);
|
ON user_upload (user_id, created_at);
|
||||||
|
|
||||||
-- Do not
|
-- Bad
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM user_upload
|
FROM user_upload
|
||||||
ORDER BY user_id, created_at DESC;
|
ORDER BY user_id, created_at DESC;
|
||||||
|
|
||||||
-- Do
|
-- Good
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM user_upload
|
FROM user_upload
|
||||||
ORDER BY user_id DESC, created_at DESC;
|
ORDER BY user_id DESC, created_at DESC;
|
||||||
|
|
||||||
-- Or do
|
-- Also good
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM user_upload
|
FROM user_upload
|
||||||
ORDER BY user_id, created_at;
|
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
|
- 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
|
## Thanks
|
||||||
|
|
||||||
- [Use The Index, Luke](https://use-the-index-luke.com/)
|
- [Use The Index, Luke](https://use-the-index-luke.com/)
|
||||||
|
|
|
@ -112,7 +112,6 @@ For fun
|
||||||
|
|
||||||
#### macOS
|
#### macOS
|
||||||
|
|
||||||
- https://theunarchiver.com/
|
|
||||||
- https://github.com/iina/iina
|
- https://github.com/iina/iina
|
||||||
- https://github.com/rxhanson/Rectangle
|
- https://github.com/rxhanson/Rectangle
|
||||||
- https://github.com/waydabber/BetterDisplay
|
- https://github.com/waydabber/BetterDisplay
|
||||||
|
@ -126,11 +125,13 @@ For fun
|
||||||
- https://github.com/jordanbaird/Ice
|
- https://github.com/jordanbaird/Ice
|
||||||
- https://github.com/zed-industries/zed
|
- https://github.com/zed-industries/zed
|
||||||
- https://sourceforge.net/projects/skim-app/
|
- https://sourceforge.net/projects/skim-app/
|
||||||
|
- https://github.com/alienator88/Pearcleaner
|
||||||
|
|
||||||
~~Memory~~
|
~~Memory~~
|
||||||
|
|
||||||
- https://github.com/linearmouse/linearmouse
|
- https://theunarchiver.com/
|
||||||
- https://www.tunabellysoftware.com/balance_lock/
|
- https://www.tunabellysoftware.com/balance_lock/
|
||||||
|
- https://github.com/linearmouse/linearmouse
|
||||||
- https://github.com/tuyenvm/OpenKey
|
- https://github.com/tuyenvm/OpenKey
|
||||||
- https://github.com/objective-see/LuLu
|
- https://github.com/objective-see/LuLu
|
||||||
- https://github.com/ivoronin/TomatoBar
|
- https://github.com/ivoronin/TomatoBar
|
||||||
|
|
Loading…
Reference in New Issue