SQL Perfomance Test

Relational databases have been around for a very long time and they have evolved up to the point where they can handle processing millions of results within seconds. But for someone like me having a query that performs good isn’t enough, I am constantly wondering whether there is a way I can speed things up, whether there is a more efficient way to do it.

Recently I had to refactor part of an application which contained some queries. And at first glance, I could already tell the queries wouldn’t be as efficient as they could be, but before rewriting them, I decided to have a small experiment to determine the best approach to write them. The main concern I had with theses queries was how they gathered data from different tables. That will be the focus of this blog post.

Continue reading

Advertisements

C++ Converting Integer/Double To String

In my previous blog post, we noticed that concatenating strings was a mixed story depending on whether it were all real strings, or if you were mixing strings with integers and doubles. To understand the full picture we need to investigate how much of a penalty was taken because of the different way to convert the integer or double to a string. In this blog post, we will do exactly that.

Continue reading

C++ String Concatenation Appendix

In my previous blog post I compared the different ways of concatenating a string in C++. I did however miss one very obvious way to do this. In contrary to Java (where a String is immutable), C++ just offers an append method on a string. In this short blog post I repeat the previous test but now include the append method from string.

Continue reading

C++ String Concatenation

String concatenation is a very common operation to be done. From my time with Java, I have been warned many times that naive string concatenation could destroy the performance of your application. This is because the system has to create a lot of in-between strings, causing many copy operations to be executed. Instead you should use the provided StringBuilder.

Now that I came across a similar situation in C++, I was wondering whether the same is true here. In this blog post I will compare three different ways to concatenate a string. But I will go the extra mile as well, and see how combining strings and numbers has an effect on the concatenation.

Continue reading

C++ Coding Style

Although I spent my first years at University programming in C++ and only later switched to Java, it seems that because I started my professional career with Java, it has formed my coding style a lot more than I expected. As I am writing production code using C++ now, I see quite a lot of differences in coding style and I even feel that the way I syntactically structure my code simply doesn’t feel right with C++.

There are a lot of similarities between Java and C++, they both are Object Oriented programming languages and such you create classes with methods and members. Each of these need to have a decent name, which is language independent, as a name should be short and expressive at the same time. However, I tend to write more verbose C++ code compared to Java. In this blog post we will examine the cause of this and how you can deal with it.

Continue reading

Creating A Rotating Logger In Bash

Recently I was working on writing some bash script to gather some data. The data of course has to be written to somewhere, and just printing it to the console wasn’t an option because the script would run from time to time and it is the historical data (over a course of hours, or even days) that holds the real value.

Writing data to a file is easy, but if you leave it unattended the file will keep on growing. Just removing the file at a certain interval won’t work either because then you have a period where there is no historical data anymore. What I basically wanted were the features offered by all logger libraries, being a rotating logger that automatically overwrites files. I couldn’t immediately find any source that I could use so I decided to write my own.

Continue reading

C++ Float vs Double

Since I am no working with C++ and no longer use Java as my mainly programming language, I was wondering whether some of the past experiments would yield different results. In this blog post I will repeat the exercise of comparing floats and doubles but now for C++. Given that Java and C++ do handle types differently it is possible that the results may vary, however both languages implement floating points numbers in the same way, according to the IEEE standard.

Continue reading