2023-07-18 18:38:30 +00:00
|
|
|
|
<!doctype html>
|
2022-12-25 19:13:58 +00:00
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
|
|
|
<link
|
|
|
|
|
rel="stylesheet"
|
2024-09-27 19:40:57 +00:00
|
|
|
|
href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.6.1/github-markdown.min.css"
|
2022-12-25 19:13:58 +00:00
|
|
|
|
/>
|
2023-04-01 03:37:48 +00:00
|
|
|
|
<title>haunt98 posts</title>
|
2022-12-25 19:13:58 +00:00
|
|
|
|
</head>
|
|
|
|
|
<style>
|
|
|
|
|
.markdown-body {
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
min-width: 200px;
|
|
|
|
|
max-width: 980px;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
padding: 45px;
|
2024-03-01 10:11:20 +00:00
|
|
|
|
font-family:
|
|
|
|
|
Shantell Sans Normal,
|
|
|
|
|
Rec Mono Casual,
|
|
|
|
|
SF Pro,
|
|
|
|
|
Inter,
|
|
|
|
|
sans-serif;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.markdown-body pre {
|
|
|
|
|
font-family:
|
|
|
|
|
Berkeley Mono,
|
|
|
|
|
IBM Plex Mono,
|
|
|
|
|
SF Mono,
|
|
|
|
|
Jetbrains Mono,
|
|
|
|
|
monospace;
|
2022-12-25 19:13:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: 767px) {
|
|
|
|
|
.markdown-body {
|
|
|
|
|
padding: 15px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<body class="markdown-body">
|
2023-08-09 07:22:58 +00:00
|
|
|
|
<h2>
|
|
|
|
|
<a href="index.html"><code>~</code></a>
|
|
|
|
|
</h2>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h1 class="heading-element">SQL</h1>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-sql"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: SQL"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#sql"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
<p>
|
|
|
|
|
Previously in my fresher software developer time, I rarely write SQL, I
|
|
|
|
|
always use ORM to wrap SQL. But time past and too much abstraction bites
|
|
|
|
|
me. So I decide to only write SQL from now as much as possible, no more
|
|
|
|
|
ORM for me. But if there is any cool ORM for Go, I guess I try.
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
This guide is not kind of guide which cover all cases. Just my little
|
|
|
|
|
tricks when I work with SQL.
|
|
|
|
|
</p>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element">Stay away from database unique id</h2>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-stay-away-from-database-unique-id"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: Stay away from database unique id"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#stay-away-from-database-unique-id"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
<p>
|
|
|
|
|
Use UUID instead. If you can, and you should, choose UUID type which can
|
|
|
|
|
be sortable.
|
|
|
|
|
</p>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element">Stay away from database timestamp</h2>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-stay-away-from-database-timestamp"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: Stay away from database timestamp"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#stay-away-from-database-timestamp"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
<p>
|
2024-07-22 11:32:39 +00:00
|
|
|
|
Stay away from all kind of database timestamp (MySQL timestamp, SQLite
|
2022-12-30 09:26:06 +00:00
|
|
|
|
timestamp, ...) Just use int64 then pass the timestamp in service layer
|
|
|
|
|
not database layer.
|
|
|
|
|
</p>
|
|
|
|
|
<p>
|
|
|
|
|
Why? Because time and date and location are too much complex to handle. In
|
|
|
|
|
my business, I use timestamp in milliseconds. Then I save timestamp as
|
|
|
|
|
int64 value to database. Each time I get timestamp from database, I parse
|
|
|
|
|
to time struct in Go with location or format I want. No more hassle!
|
|
|
|
|
</p>
|
|
|
|
|
<p>It looks like this:</p>
|
|
|
|
|
<div class="highlight highlight-text-adblock">
|
|
|
|
|
<pre>
|
|
|
|
|
[Business] time, data -> convert to unix timestamp milliseconds -> [Database] int64</pre
|
|
|
|
|
>
|
|
|
|
|
</div>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element">Extra field for extra things</h2>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-extra-field-for-extra-things"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: Extra field for extra things"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#extra-field-for-extra-things"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2023-04-04 10:25:22 +00:00
|
|
|
|
<p>
|
|
|
|
|
Create new column in database is scary, so I suggest avoid it if you can.
|
|
|
|
|
How to avoid, first design table with extra field. It is black hole, put
|
|
|
|
|
everything in there if you want.
|
|
|
|
|
</p>
|
|
|
|
|
<p>I always use MySQL json data type for extra field.</p>
|
2024-01-03 10:17:15 +00:00
|
|
|
|
<p>JSON data type is also useful for dumping request, response data.</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>
|
|
|
|
|
<a
|
|
|
|
|
href="https://dev.mysql.com/doc/refman/5.7/en/json.html"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>For MySQL 5.7</a
|
|
|
|
|
>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a
|
|
|
|
|
href="https://dev.mysql.com/doc/refman/8.0/en/json.html"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>For MySQL 8.0</a
|
|
|
|
|
>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<p>
|
|
|
|
|
Use <code>JSON_EXTRACT(col, '$.key') IS NULL</code> to check json field
|
|
|
|
|
exist or not.
|
|
|
|
|
</p>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element">Use index!!!</h2>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-use-index"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: Use index!!!"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#use-index"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
<p>
|
|
|
|
|
You should use index for faster query, but not too much. Don't create
|
|
|
|
|
index for every fields in table. Choose wisely!
|
|
|
|
|
</p>
|
|
|
|
|
<p>For example, create index in MySQL:</p>
|
|
|
|
|
<div class="highlight highlight-source-sql">
|
2023-06-15 19:31:21 +00:00
|
|
|
|
<pre><span class="pl-k">CREATE</span> <span class="pl-k">INDEX</span> <span class="pl-en">idx_user_id</span>
|
|
|
|
|
<span class="pl-k">ON</span> user_upload (user_id);</pre>
|
|
|
|
|
</div>
|
|
|
|
|
<p>
|
|
|
|
|
If create index inside <code>CREATE TABLE</code>,
|
|
|
|
|
<a href="https://stackoverflow.com/a/1401615" rel="nofollow"
|
|
|
|
|
>prefer <code>INDEX</code> to <code>KEY</code></a
|
|
|
|
|
>:
|
|
|
|
|
</p>
|
|
|
|
|
<div class="highlight highlight-source-sql">
|
|
|
|
|
<pre><span class="pl-k">CREATE</span> <span class="pl-k">TABLE</span> <span class="pl-en">user_upload</span>
|
|
|
|
|
(
|
|
|
|
|
id <span class="pl-k">int</span>(<span class="pl-c1">11</span>) <span class="pl-k">NOT NULL</span>,
|
|
|
|
|
user_id <span class="pl-k">int</span>(<span class="pl-c1">11</span>) <span class="pl-k">NULL</span> DEFAULT <span class="pl-k">NULL</span>,
|
|
|
|
|
<span class="pl-k">PRIMARY KEY</span> (id),
|
|
|
|
|
INDEX idx_user_id (user_id)
|
|
|
|
|
);</pre>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
</div>
|
2023-04-17 10:14:54 +00:00
|
|
|
|
<p>Use <code>EXPLAIN</code> to check if index is used or not:</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>
|
|
|
|
|
<a
|
|
|
|
|
href="https://dev.mysql.com/doc/refman/5.7/en/explain-output.html"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>For MySQL 5.7</a
|
|
|
|
|
>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a
|
|
|
|
|
href="https://dev.mysql.com/doc/refman/8.0/en/explain-output.html"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>For MySQL 8.0</a
|
|
|
|
|
>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element">Be careful with UTF-8</h2>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-be-careful-with-utf-8"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: Be careful with UTF-8"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#be-careful-with-utf-8"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2023-10-05 06:39:09 +00:00
|
|
|
|
<p>TLDR with MySQL:</p>
|
|
|
|
|
<div class="highlight highlight-source-sql">
|
|
|
|
|
<pre><span class="pl-k">CREATE</span> <span class="pl-k">TABLE</span> <span class="pl-en">ekyc_approved</span>
|
|
|
|
|
(
|
|
|
|
|
id <span class="pl-k">varchar</span>(<span class="pl-c1">30</span>) <span class="pl-k">NOT NULL</span>,
|
|
|
|
|
<span class="pl-k">PRIMARY KEY</span> (id),
|
|
|
|
|
) ENGINE <span class="pl-k">=</span> InnoDB
|
|
|
|
|
DEFAULT CHARSET <span class="pl-k">=</span> utf8mb4;</pre>
|
|
|
|
|
</div>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element">Be careful with NULL</h2>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-be-careful-with-null"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: Be careful with NULL"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#be-careful-with-null"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
<p>
|
|
|
|
|
If compare with field which can be NULL, remember to check NULL for
|
|
|
|
|
safety.
|
|
|
|
|
</p>
|
|
|
|
|
<div class="highlight highlight-source-sql">
|
|
|
|
|
<pre><span class="pl-c"><span class="pl-c">--</span> field_something can be NULL</span>
|
2022-12-25 19:13:58 +00:00
|
|
|
|
|
|
|
|
|
<span class="pl-c"><span class="pl-c">--</span> Bad</span>
|
2024-03-08 08:12:41 +00:00
|
|
|
|
<span class="pl-k">SELECT</span> <span class="pl-k">*</span>
|
2022-12-25 19:13:58 +00:00
|
|
|
|
<span class="pl-k">FROM</span> table
|
|
|
|
|
<span class="pl-k">WHERE</span> field_something <span class="pl-k">!=</span> <span class="pl-c1">1</span>
|
2022-09-06 17:10:02 +00:00
|
|
|
|
|
2022-12-25 19:13:58 +00:00
|
|
|
|
<span class="pl-c"><span class="pl-c">--</span> Good</span>
|
2024-03-08 08:12:41 +00:00
|
|
|
|
<span class="pl-k">SELECT</span> <span class="pl-k">*</span>
|
2022-12-25 19:13:58 +00:00
|
|
|
|
<span class="pl-k">FROM</span> table
|
2022-12-30 09:26:06 +00:00
|
|
|
|
<span class="pl-k">WHERE</span> (field_something IS <span class="pl-k">NULL</span> <span class="pl-k">OR</span> field_something <span class="pl-k">!=</span> <span class="pl-c1">1</span>)</pre>
|
|
|
|
|
</div>
|
2024-07-22 11:32:39 +00:00
|
|
|
|
<p>Need clarify why this happen? Idk :(</p>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element"><code>VARCHAR</code> or <code>TEXT</code></h2>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-varchar-or-text"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: VARCHAR or TEXT"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#varchar-or-text"
|
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
2022-12-30 09:26:06 +00:00
|
|
|
|
></a>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
</div>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
<p>
|
|
|
|
|
Prefer <code>VARCHAR</code> if you need to query and of course use index,
|
|
|
|
|
and make sure size of value will never hit the limit. Prefer
|
|
|
|
|
<code>TEXT</code> if you don't care, just want to store something.
|
|
|
|
|
</p>
|
2024-04-20 16:38:27 +00:00
|
|
|
|
<p>If you need to store UUID, use <code>VARCHAR(255)</code>.</p>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element"><code>LIMIT</code></h2>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-limit"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: LIMIT"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#limit"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2023-06-15 19:31:21 +00:00
|
|
|
|
<p>
|
|
|
|
|
Prefer <code>LIMIT 10 OFFSET 5</code> to <code>LIMIT 5, 10</code> to avoid
|
|
|
|
|
misunderstanding.
|
|
|
|
|
</p>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element">
|
|
|
|
|
Be super careful when migrate, update database on production and
|
|
|
|
|
online!!!
|
|
|
|
|
</h2>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
<a
|
2023-11-19 15:59:21 +00:00
|
|
|
|
id="user-content-be-super-careful-when-migrate-update-database-on-production-and-online"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: Be super careful when migrate, update database on production and online!!!"
|
2022-12-30 09:26:06 +00:00
|
|
|
|
href="#be-super-careful-when-migrate-update-database-on-production-and-online"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
<p>
|
2024-07-22 11:32:39 +00:00
|
|
|
|
Please read docs about online ddl operations before do anything online
|
2022-12-30 09:26:06 +00:00
|
|
|
|
(keep database running the same time update it, for example create index,
|
|
|
|
|
...)
|
|
|
|
|
</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li>
|
|
|
|
|
<a
|
|
|
|
|
href="https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>For MySQL 5.7</a
|
|
|
|
|
>,
|
|
|
|
|
<a
|
|
|
|
|
href="https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-limitations.html"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>Limitations</a
|
|
|
|
|
>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<a
|
|
|
|
|
href="https://dev.mysql.com/doc/refman/8.0/en/innodb-online-ddl-operations.html"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>For MySQL 8.0</a
|
|
|
|
|
>,
|
|
|
|
|
<a
|
|
|
|
|
href="https://dev.mysql.com/doc/refman/8.0/en/innodb-online-ddl-limitations.html"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>Limitations</a
|
|
|
|
|
>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element">Heathcheck</h2>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-heathcheck"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: Heathcheck"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#heathcheck"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2023-08-17 09:40:38 +00:00
|
|
|
|
<p>Use <code>SELECT 1</code> to check if database failed yet.</p>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element">Tools</h2>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-tools"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: Tools"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#tools"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
<ul>
|
|
|
|
|
<li>
|
|
|
|
|
Use
|
|
|
|
|
<a href="https://github.com/sqlfluff/sqlfluff">sqlfluff/sqlfluff</a> to
|
|
|
|
|
check your SQL.
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
Use <a href="https://github.com/k1LoW/tbls">k1LoW/tbls</a> to grasp your
|
|
|
|
|
database reality :)
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
2024-02-29 12:29:26 +00:00
|
|
|
|
<div class="markdown-heading">
|
|
|
|
|
<h2 class="heading-element">Thanks</h2>
|
2023-11-19 15:59:21 +00:00
|
|
|
|
<a
|
|
|
|
|
id="user-content-thanks"
|
2024-03-08 08:12:41 +00:00
|
|
|
|
class="anchor"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
aria-label="Permalink: Thanks"
|
2023-11-19 15:59:21 +00:00
|
|
|
|
href="#thanks"
|
2024-02-29 12:29:26 +00:00
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span
|
|
|
|
|
></a>
|
|
|
|
|
</div>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
<ul>
|
|
|
|
|
<li>
|
2024-07-07 18:31:58 +00:00
|
|
|
|
<p>
|
|
|
|
|
<a href="https://use-the-index-luke.com/" rel="nofollow"
|
|
|
|
|
>Use The Index, Luke</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
</li>
|
|
|
|
|
<li>
|
2024-07-07 18:31:58 +00:00
|
|
|
|
<p>
|
|
|
|
|
<a
|
|
|
|
|
href="https://kevin.burke.dev/kevin/reddits-database-has-two-tables/"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>Reddit’s database has two tables</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
</li>
|
|
|
|
|
<li>
|
2024-07-07 18:31:58 +00:00
|
|
|
|
<p>
|
|
|
|
|
<a
|
|
|
|
|
href="https://shekhargulati.com/2022/07/08/my-notes-on-gitlabs-postgres-schema-design/"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>My Notes on GitLab Postgres Schema Design</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
</li>
|
2023-04-08 10:10:10 +00:00
|
|
|
|
<li>
|
2024-07-07 18:31:58 +00:00
|
|
|
|
<p>
|
|
|
|
|
<a
|
|
|
|
|
href="https://shekhargulati.com/2022/01/08/when-to-use-json-data-type-in-database-schema-design/"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>When to use JSON data type in database schema design?</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
2023-04-08 10:10:10 +00:00
|
|
|
|
</li>
|
|
|
|
|
<li>
|
2024-07-07 18:31:58 +00:00
|
|
|
|
<p>
|
|
|
|
|
<a
|
|
|
|
|
href="https://planetscale.com/blog/how-read-mysql-explains"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>How to read MySQL EXPLAINs</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
2023-04-08 10:10:10 +00:00
|
|
|
|
</li>
|
2023-04-17 10:14:54 +00:00
|
|
|
|
<li>
|
2024-07-07 18:31:58 +00:00
|
|
|
|
<p>
|
|
|
|
|
<a
|
|
|
|
|
href="https://brandur.org/fragments/database-health-check"
|
|
|
|
|
rel="nofollow"
|
|
|
|
|
>Honest health checks that hit the database</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
2023-04-17 10:14:54 +00:00
|
|
|
|
</li>
|
2023-08-17 09:40:38 +00:00
|
|
|
|
<li>
|
2024-07-07 18:31:58 +00:00
|
|
|
|
<p>
|
|
|
|
|
<a href="https://www.grouparoo.com/blog/varchar-191" rel="nofollow"
|
|
|
|
|
>Why are database columns 191 characters?</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
2023-08-17 09:40:38 +00:00
|
|
|
|
</li>
|
2024-03-14 18:50:05 +00:00
|
|
|
|
<li>
|
2024-07-07 18:31:58 +00:00
|
|
|
|
<p>
|
|
|
|
|
<a href="https://stackoverflow.com/a/43056611" rel="nofollow"
|
|
|
|
|
>Store UUID v4 in MySQL</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
2024-03-14 18:50:05 +00:00
|
|
|
|
</li>
|
2024-04-20 16:38:27 +00:00
|
|
|
|
<li>
|
2024-07-07 18:31:58 +00:00
|
|
|
|
<p>
|
|
|
|
|
<a href="https://stackoverflow.com/a/4849030" rel="nofollow"
|
|
|
|
|
>Difference between text and varchar (character varying)</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
2024-04-20 16:38:27 +00:00
|
|
|
|
</li>
|
2024-08-11 10:28:12 +00:00
|
|
|
|
<li>
|
|
|
|
|
<p>
|
|
|
|
|
<a href="https://stackoverflow.com/q/33889922" rel="nofollow"
|
|
|
|
|
>How to get the number of total results when there is LIMIT in
|
|
|
|
|
query?</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
|
|
|
|
</li>
|
|
|
|
|
<li>
|
|
|
|
|
<p>
|
|
|
|
|
<a href="https://stackoverflow.com/q/28888375" rel="nofollow"
|
|
|
|
|
>Run a query with a LIMIT/OFFSET and also get the total number of
|
|
|
|
|
rows</a
|
|
|
|
|
>
|
|
|
|
|
</p>
|
|
|
|
|
</li>
|
2022-12-30 09:26:06 +00:00
|
|
|
|
</ul>
|
2022-09-06 17:10:02 +00:00
|
|
|
|
|
2022-12-25 19:22:39 +00:00
|
|
|
|
<div>
|
|
|
|
|
Feel free to ask me via
|
|
|
|
|
<a href="mailto:hauvipapro+posts@gmail.com">email</a> or
|
2023-08-20 17:29:13 +00:00
|
|
|
|
<a rel="me" href="https://hachyderm.io/@haunguyen">Mastodon</a>.
|
|
|
|
|
<br />Source code is available on
|
2022-12-30 09:55:38 +00:00
|
|
|
|
<a href="https://github.com/haunt98/posts-go">GitHub</a>
|
2023-08-20 17:29:13 +00:00
|
|
|
|
<a href="https://codeberg.org/yoshie/posts-go">Codeberg</a>
|
|
|
|
|
<a href="https://git.sr.ht/~youngyoshie/posts-go">sourcehut</a>
|
|
|
|
|
<a href="https://gitea.treehouse.systems/yoshie/posts-go">Treehouse</a>
|
|
|
|
|
<a href="https://gitlab.com/youngyoshie/posts-go">GitLab</a>
|
2022-12-25 19:22:39 +00:00
|
|
|
|
</div>
|
2022-12-25 19:13:58 +00:00
|
|
|
|
</body>
|
|
|
|
|
</html>
|