Skip to content

Instantly share code, notes, and snippets.

@shvargon
shvargon / join_perf_example.md
Last active September 13, 2023 03:50 — forked from yashap/join_perf_example.md
Example of how sometimes a normalized schema + joins kills performance vs. denormalizing

Normalized/join vs. denormalized/no-join performance example

An example of how sometimes you have to denormalize your schema, so that you can build compound indexes, to get acceptable performance. In some cases a normalized schema with join(s) just won't be fast enough.

Note: I think in almost all cases you should start with a normalized schema and use joins. But when you hit cases like the above, it's fine to denormalize just for these specific cases - often you'll just have one or a few such cases in your entire app, where the combination of data size/shape/queries means you cannot have efficient queries without denormalizing.

@shvargon
shvargon / pre-commit
Last active April 21, 2020 12:37 — forked from zeenix/pre-commit
git hook to ensure commit doesn't break rustfmt
#!/usr/bin/env bash
# Put in your Rust repository's .git/hooks/pre-commit to ensure you never breaks rustfmt.
for FILE in `git diff --cached --name-only`; do
if [[ $FILE == *.rs ]] && ! rustfmt --edition=2018 --check $FILE; then
echo -e "\n Commit rejected due to invalid formatting of \"$FILE\" file."
exit 1
fi
done