Facebook Twitter GitHub LinkedIn LinkedIn LinkedIn
March 19, 2021

Speeding up SQL queries by orders of magnitude using UNION

By Ben Levy and Christian Charukiewicz  —  sql performance-optimization

SQL is a very powerful tool for querying data. It allows you to write queries against your relational data in a declarative manner, letting you describe what data that you want to retrieve without having to describe how to retrieve it. In most cases, this works very well, and the query optimizer in many database engines (MySQL, PostgreSQL, etc.) will create an efficient query plan.

Efficient query plans rely on a schema that uses appropriate data types, especially for primary key columns, where doing things such as misusing VARCHAR can kill performance. Another critical element of enabling fast query plans is appropriately indexing columns, which eliminates the need to perform full table scans when retrieving data. Unfortunately, even following these schema rules, it’s possible to write SQL queries that have surprisingly poor performance, often leading to the bewilderment of the developer writing such a query. Perhaps the most surprising aspect of this type of query is that it is often written in the most intuitive way to describe the data.

Read the whole post
January 11, 2021

Why Haskell is our first choice for building production software systems

By Christian Charukiewicz  —  haskell

Haskell is the first programming language we reach for when we build production software systems. This likely seems unusual to anyone who only has a passing familiarity with the language. Haskell has a reputation for being an advanced language with a steep learning curve. It is also often thought of as a research language with limited practical utility.

While Haskell does have a very large surface area, with many concepts and a syntax that will feel unfamiliar to programmers coming from most other languages, it is unrivaled in the combination of developer productivity, code maintainability, software reliability, and performance that it offers. In this post I will cover some of the defining features of Haskell that make it an excellent, industrial-strength language that is well-suited for building commercial software, and why it is usually the first tool we consider using for new projects.

Read the whole post
November 23, 2020

Reducing the pain of grouping SQL query results using Haskell

By Ben Levy and Christian Charukiewicz  —  haskell sql performance-optimization

Relational databases allow us to model the associations between different types of data in our system domain. Most application database schemas rely on normalization to avoid data duplication. We use SQL to retrieve this data from a database, but SQL has limitations. When we need data from several tables, we’re forced to make trade offs in how we query our data, and our query results often do not contain an ideal representation of the relationships between our data entites.

In order to mitigate this limitation of SQL, we typically transform the data we retrieve via our queries in our application layer. With a system written in Haskell, we can use the Semigroup typeclass and the append operation it exposes (<>) to transform the data into the shape we need by defining our desired custom data types and simple transformation functions. In this post we’ll explore this method of solving this problem in more detail.

Read the whole post
November 13, 2020

Who is Foxhound Systems?


Foxhound Systems is a custom software development company founded by Christian Charukiewicz and Ben Levy. We started Foxhound Systems because we care about great software, and having worked as professional software engineers for a long time, we believe we can help other organizations grow by creating fast, reliable, and well-designed software systems. We have both seen and had our hands in creating a wide variety of software and products, and one trait that we’ve shared along the way is that we’ve always been on the lookout for ways to learn, improve, and help others.

Read the whole post