Examples

Page 14 of 50

Browse code examples

sqlSnippet

Btree Deduplicate Items Storage

Create two identical B-tree indexes differing only in deduplicate_items and compare pg_relation_size, showing how PG13 packs duplicate TIDs into posting lists.

sqlSnippet

For Update Of Targets One Table

FOR UPDATE OF o locks only the listed table rows in a join; without OF every participating table gets row locks, including pure filter-side tables.

sqlSnippet

INITCAP TRANSLATE Text Cleanup

Normalize messy contact strings with INITCAP for word-initial capitalization and TRANSLATE for per-character masking or deletion via an empty replacement set.

sqlSnippet

Regexp Split To Table Rows

Explode free-form tag lists into rows with regexp_split_to_table behind a LATERAL join; a [,;\s]+ delimiter absorbs the mixed separators split_part preserves.

sqlSnippet

String To Array Token Roundtrip

Tokenize a delimited column with string_to_array, filter with = ANY, and rebuild text with array_to_string, where a null string turns empty fields into NULL.

sqlSnippet

WindowAgg Plan Sort And Index

Read EXPLAIN for window queries: the Sort node feeding WindowAgg, how a matching index removes the Sort, and why distinct windows stack separate nodes.

goSnippet

GCD And LCM With big.Int

Compute GCD and LCM with math/big.Int so values beyond int64 never overflow, and reduce fractions by dividing out the common divisor.