I've run across a fun little trick to simulate latency in your development environments when testing some SQL queries. Possible use-cases including to validate that backend latency won't bring down your frontend, or that your UX is still bearable, etc. https://twitter.com/gunnarmorling/status/1361061234569805832 The solution is PostgreSQL and Hibernate specific, though to doesn't have to be. Besides, … Continue reading Simulating Latency with SQL / JDBC
Tag: simulation
Funky String Function Simulation in SQLite
SQLite is so light, it doesn't have any useful string functions. It doesn't have ASCII(), LPAD(), RPAD(), REPEAT(), POSITION(), you name it. It does, however, have a wonderful RANDOMBLOB() function. So if you really need a good random number generator, use a SQLite database and generate a 1GB blob. That should give you a couple … Continue reading Funky String Function Simulation in SQLite
Simulation of TRUNC() in Derby
Derby is missing out a lot of functions from the set of functions that other databases usually provide. One example is the TRUNC(value, decimals) function. According to the Wikipedia, truncation can be achieved as such: -- trunc(x, n) CASE WHEN x > 0 THEN floor(power(10, n) * x) / power(10, n) ELSE ceil(power(10, n) * … Continue reading Simulation of TRUNC() in Derby
How to simulate MySQL’s INSERT statement extensions
I have previously posted about the SQL MERGE statement, and how powerful it is here: https://blog.jooq.org/arcane-magic-with-the-sql2003-merge-statement/ Unfortunately, not all databases support this statement. Also, very often it is quite a bit of overkill, when what you want to do is to simply INSERT or UPDATE a single record, depending on whether it already exists. MySQL's … Continue reading How to simulate MySQL’s INSERT statement extensions