search by tags

for the user

adventures into the land of the command line

postgres vs redis drag race

…but for some reason im gonna go with a boxing analogy

so i’ve been working on an api for fun, and at some point, i realised that postgres might not be as fast as i would like. i tried out a nosql alternative called redis to be my database, and then did a time comparison to see how they stacked up against one another.

some of the calls in the images that take between 4-6 seconds involve sending an email using google’s mail service. also, the postgres version of my test has 4x 1 second sleeps, to prevent getting a connection error. also, the postgres version of the tests does 5 extra tests which aren’t needed in the redis version of the tests. this is because when i started using redis and understood it’s data structure, i found i didn’t need to have these calls anymore and i could do the same with less. without further ado…

in the blue corner, we have the old elephant, the tried and true champion of free awesome reliability. because he’s getting on in age, he has do some extra work to achieve his goals, but he does it reliably every time! let’s see how he gets on! (cheers from the crowd)

41.64 seconds, a valiant time laid down by old postgres. what did you think keith? (keith) “yes quite a reliable time stan, most of the api calls were to the effect of between 0.1 and 0.9 seconds, but astonishingly, there was a 3.4 second call towards the end. could old postgres have been getting tired in those last few moments? back to you stan.” (stan) right well let’s see how the contender gets on.

in the red corner we have the (not so new) contender, mr redis. he’s been training with some new fancy techniques and so he doesn’t need to do everything that old postgres needs to do to get to the same result. redis, how do you do? (cheers from the crowd)

oh my god its an upset!! redis has put in an astonishing time of 23.39 seconds! (keith) “stan will you look at those api calls! 0.02 seconds. thats blindingly fast!” (stan) yeeeesssss, there were some up around the 0.1 second mark, but it is orders of magnitude faster without a doubt!

AND THE WINNER IS REDIS !!! wooooooo (more cheers from the crowd)