mirror of
https://github.com/jbranchaud/til
synced 2026-01-15 21:18:02 +00:00
Compare commits
4 Commits
52339c8146
...
450d96ea1a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
450d96ea1a | ||
|
|
5083c8e9f1 | ||
|
|
a4c67c33a3 | ||
|
|
bc767a0ad3 |
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1527 TILs and counting..._
|
||||
_1529 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -828,6 +828,7 @@ _1527 TILs and counting..._
|
||||
- [Manage Major Versions With Brew And Direnv](postgres/manage-major-versions-with-brew-and-direnv.md)
|
||||
- [Max Identifier Length Is 63 Bytes](postgres/max-identifier-length-is-63-bytes.md)
|
||||
- [Open Heroku Database In Postico From Terminal](postgres/open-heroku-database-in-postico-from-terminal.md)
|
||||
- [Output Explain Query Plan In Different Formats](postgres/output-explain-query-plan-in-different-formats.md)
|
||||
- [pg Prefix Is Reserved For System Schemas](postgres/pg-prefix-is-reserved-for-system-schemas.md)
|
||||
- [Postgres Does Not Support Unsigned Integers](postgres/postgres-does-not-support-unsigned-integers.md)
|
||||
- [Prepare, Execute, And Deallocate Statements](postgres/prepare-execute-and-deallocate-statements.md)
|
||||
@@ -1511,6 +1512,7 @@ _1527 TILs and counting..._
|
||||
- [List Stats For A File](unix/list-stats-for-a-file.md)
|
||||
- [List The Available JDKs](unix/list-the-available-jdks.md)
|
||||
- [List The Stack Of Remembered Directories](unix/list-the-stack-of-remembered-directories.md)
|
||||
- [List TXT DNS Records For A Domain](unix/list-txt-dns-records-for-a-domain.md)
|
||||
- [Load Env Vars In Bash Script](unix/load-env-vars-in-bash-script.md)
|
||||
- [Look Through All Files That Have Been Git Stashed](unix/look-through-all-files-that-have-been-git-stashed.md)
|
||||
- [Make Direnv Less Noisy](unix/make-direnv-less-noisy.md)
|
||||
|
||||
57
postgres/output-explain-query-plan-in-different-formats.md
Normal file
57
postgres/output-explain-query-plan-in-different-formats.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Output Explain Query Plan In Different Formats
|
||||
|
||||
The output of an [`explain` (or `explain analyze`) query
|
||||
plan](https://www.postgresql.org/docs/current/sql-explain.html) for a given
|
||||
query defaults to a `TEXT` format that is meant to be read by a person.
|
||||
|
||||
```sql
|
||||
> explain (analyze) select title from books where created_at > now() - '1 year'::interval;
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------------------------------
|
||||
Seq Scan on books (cost=0.00..1.28 rows=5 width=32) (actual time=0.011..0.017 rows=22 loops=1)
|
||||
Filter: (created_at > (now() - '1 year'::interval))
|
||||
Planning Time: 0.052 ms
|
||||
Execution Time: 0.027 ms
|
||||
(4 rows)
|
||||
```
|
||||
|
||||
If we instead want the query plan in a standardized format that is parseable
|
||||
and readable by a program, we can specify an alternate format like `JSON`,
|
||||
`YAML`, or `XML`.
|
||||
|
||||
Here is the same plan with `format json`:
|
||||
|
||||
```sql
|
||||
> explain (analyze, format json) select title from books where created_at > now() - '1 year'::interval;
|
||||
QUERY PLAN
|
||||
----------------------------------------------------------------
|
||||
[ +
|
||||
{ +
|
||||
"Plan": { +
|
||||
"Node Type": "Seq Scan", +
|
||||
"Parallel Aware": false, +
|
||||
"Async Capable": false, +
|
||||
"Relation Name": "books", +
|
||||
"Alias": "books", +
|
||||
"Startup Cost": 0.00, +
|
||||
"Total Cost": 1.28, +
|
||||
"Plan Rows": 5, +
|
||||
"Plan Width": 32, +
|
||||
"Actual Startup Time": 0.008, +
|
||||
"Actual Total Time": 0.014, +
|
||||
"Actual Rows": 22, +
|
||||
"Actual Loops": 1, +
|
||||
"Filter": "(created_at > (now() - '1 year'::interval))",+
|
||||
"Rows Removed by Filter": 0 +
|
||||
}, +
|
||||
"Planning Time": 0.050, +
|
||||
"Triggers": [ +
|
||||
], +
|
||||
"Execution Time": 0.023 +
|
||||
} +
|
||||
]
|
||||
(1 row)
|
||||
```
|
||||
|
||||
I present all four formats for a complex query plan [in this
|
||||
Gist](https://gist.github.com/jbranchaud/731b1a68f5cc70c4f7a9e1f5ef570836).
|
||||
43
unix/list-txt-dns-records-for-a-domain.md
Normal file
43
unix/list-txt-dns-records-for-a-domain.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# List TXT DNS Records For A Domain
|
||||
|
||||
The `dig` command can be used to list specifically the `TXT` DNS records for a
|
||||
domain using the `-t TXT` flag like so:
|
||||
|
||||
```bash
|
||||
$ dig -t TXT visualmode.dev
|
||||
|
||||
; <<>> DiG 9.10.6 <<>> -t TXT visualmode.dev
|
||||
;; global options: +cmd
|
||||
;; Got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41226
|
||||
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
|
||||
|
||||
;; OPT PSEUDOSECTION:
|
||||
; EDNS: version: 0, flags:; udp: 4096
|
||||
;; QUESTION SECTION:
|
||||
;visualmode.dev. IN TXT
|
||||
|
||||
;; ANSWER SECTION:
|
||||
visualmode.dev. 377 IN TXT "v=spf1 include:_spf.mx.cloudflare.net ~all"
|
||||
visualmode.dev. 377 IN TXT "google-site-verification=MBZ2S2fhnh2gHRxFniRrYW-O6mdyimJDRFj-f
|
||||
vblwtk"
|
||||
|
||||
;; Query time: 103 msec
|
||||
;; SERVER: fe80::7c4b:26ff:fe85:e164%6#53(fe80::7c4b:26ff:fe85:e164%6)
|
||||
;; WHEN: Tue Dec 03 12:49:38 CST 2024
|
||||
;; MSG SIZE rcvd: 179
|
||||
```
|
||||
|
||||
This is still rather verbose though. With the `+short` option we can pare down
|
||||
the output to the values of any TXT records and nothing else.
|
||||
|
||||
```bash
|
||||
$ dig -t TXT visualmode.dev +short
|
||||
"v=spf1 include:_spf.mx.cloudflare.net ~all"
|
||||
"google-site-verification=MBZ2S2fhnh2gHRxFniRrYW-O6mdyimJDRFj-fvblwtk"
|
||||
```
|
||||
|
||||
Neat! Now I can see that [my domain is correctly identifying itself with Google
|
||||
Search Console](internet/verify-site-ownership-with-dns-record.md).
|
||||
|
||||
[source](https://serverfault.com/a/148724)
|
||||
@@ -6,7 +6,7 @@ convert it using the `ebook-convert` binary from `Calibre`.
|
||||
First, install `Calibre`:
|
||||
|
||||
```bash
|
||||
$ brew cask install calibre
|
||||
$ brew install --cask calibre
|
||||
```
|
||||
|
||||
Then convert your ePub using `ebook-convert`:
|
||||
|
||||
Reference in New Issue
Block a user