aboutsummaryrefslogtreecommitdiff
path: root/content/posts
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-01-23 10:27:35 -0500
committerPaul Duncan <pabs@pablotron.org>2022-01-23 10:27:35 -0500
commite57d9e1d55c4880d3d2bc8d6df7e6cdf54906032 (patch)
tree454c582c88b565b7bc1704476e3e63bd6aff269d /content/posts
parent76d4a7866667a98f1e818a3051916fbc4eb4ae0c (diff)
downloadpablotron.org-e57d9e1d55c4880d3d2bc8d6df7e6cdf54906032.tar.bz2
pablotron.org-e57d9e1d55c4880d3d2bc8d6df7e6cdf54906032.zip
add content/posts/2022-01-23-pg-trigger-tests.md
Diffstat (limited to 'content/posts')
-rw-r--r--content/posts/2022-01-23-pg-trigger-tests.md44
1 files changed, 44 insertions, 0 deletions
diff --git a/content/posts/2022-01-23-pg-trigger-tests.md b/content/posts/2022-01-23-pg-trigger-tests.md
new file mode 100644
index 0000000..5c58b6f
--- /dev/null
+++ b/content/posts/2022-01-23-pg-trigger-tests.md
@@ -0,0 +1,44 @@
+---
+slug: pg-trigger-tests
+title: "Postgres Trigger Tests"
+date: "2022-01-23T10:01:49-04:00"
+---
+We already know statement-level `INSERT` [triggers][tr] are faster than
+row-level [triggers][tr] in [Postgres][].
+
+Out of curiosity I decided to time row-level and statement-level
+`INSERT` triggers with a variety of row counts.
+
+Here are the results:
+
+{{< figure
+ src="/files/posts/pg-trigger-tests/results.svg"
+ class=image
+ caption="Row Count vs Query Time"
+>}}
+
+The takeaway here is that if speed is a concern, then you should prefer
+statement-level [triggers][tr] to row-level [triggers][tr].
+
+The scripts used to create the test database, run the tests, and
+generate the results are available in the [companion GitHub
+repository][repo].
+
+[docker]: https://docker.com/
+ "Docker container orchestrator."
+[ruby]: https://ruby-lang.org/
+ "Ruby programming language."
+[python]: https://python.org/
+ "Python programming language."
+[matplotlib]: https://matplotlib.org/
+ "Matplotlib plotting library."
+[tr]: https://www.postgresql.org/docs/current/sql-createtrigger.html
+ "Postgres CREATE TRIGGER statement."
+[csv]: https://en.wikipedia.org/wiki/Comma-separated_values
+ "Comma-separated values"
+[svg]: https://en.wikipedia.org/wiki/Scalable_Vector_Graphics
+ "Scalable Vector Graphics"
+[postgres]: https://www.postgresql.org/
+ "PostgreSQL relational database."
+[repo]: https://github.com/pablotron/pg-trigger-tests
+ "Companion GitHub repository."