This post has been republished via RSS; it originally appeared at: Microsoft Tech Community - Latest Blogs - .
Did you know you can solve most of the puzzles in Advent of Code with SQL? In this episode of the Path To Citus Con podcast for developers who love Postgres, guests Dimitri Fontaine and Vik Fearing join co-hosts Claire Giordano and Pino de Candia to explore whether you can (or should) solve every data problem in SQL.
Learning SQL requires practice, just like any other skill. Dimitri will tell you why being lazy might just be a good reason to learn SQL. And how it can make your life easier and more efficient.
If you’re a fan of relational databases, you might have wondered how to pronounce the acronym SQL. Or maybe you’ve been mispronouncing it all along. So pronunciation is discussed too: Is SQL pronounced “ess-que-ell” or “sequel”? Vik, who is a member of the SQL Standard committee, has the answer to this question.
In this post, you’ll get some episode highlights with favorite quotes. At the end of this post, you’ll find links to where you can subscribe and listen to past episodes of the podcast.
Solving every data problem in SQL (or not)
Dimitri Fontaine (author of The Art of PostgreSQL and engineer at Microsoft) and Vik Fearing (member of the SQL Standard Committee and PostgreSQL Expert at EDB)—along with hosts Claire Giordano and Pino de Candia—had a sweeping conversation about the SQL language.
Topics included: writing The Art of PostgreSQL book, joining the SQL Standard Committee, programming puzzles in Advent of Code, favorite resources for learning SQL, the art and science of becoming expert at SQL—plus how to write a SQL query to resolve a time zone misunderstanding. Both Dimitri and Vik have been in the PostgreSQL world since the 2000s and they share a passion for the Postgres database and the language of SQL.
The podcast also explores the differences between a declarative language like SQL and other functional and imperative programming languages.
Let’s dive into some interesting bits from the episode...
Highlights & quotes from the episode with Dimitri & Vik
“You shouldn't solve every problem with SQL. SQL is a very good tool for what it does, but it's not the silver bullet. Some problems still need to be solved in other languages.” – Vik Fearing
Vik made this point 3 times over the course of this podcast episode. His main takeaway is that SQL is a great tool for certain problems, but it’s not a one-size-fits-all solution. Both Vik & Dimitri stressed that SQL is incredibly powerful and worth learning but is not the answer to every data problem in the world. When you encounter complex challenges that require a different approach, don’t hesitate to explore other programming languages.
“I got into SQL because of two things. The first one is I'm lazy. So if you open up any website that is trying to explain how to sort data, it's pretty complex pretty often, and you have a lot of different algorithms that are meant to be the best at the situation when you have this kind of data. […] I've always been a little fascinated by making complex things easy to use and simple to understand and so for me. SQL was that, it was filling a gap where some of the things are very complex.” – Dimitri Fontaine
Think about why you learned SQL, and you might just relate to this. One of the reasons for Dimitri is pure laziness, but in a good way. When you are faced with websites filled with complex explanations on sorting data using various algorithms, it’s easy to feel overwhelmed. According to Dimitri, SQL can come to the rescue as a beacon of simplicity.
“One example [of patterns often implemented in the application but which should be pushed down to the database] is finding equals. So for example, in the case of Olympic medals: If you usually get a gold, a silver and a bronze, but if the top two are exactly equal, then you get a gold, a gold, and a bronze. You don't get a silver. And programming that, I have noticed, is not the easiest thing to do. Whereas in SQL, it's just a rank. And rank will give you, exactly what you need.” – Vik Fearing
Ever encountered the challenge of dealing with equals, like in the world of Olympic medals? It can get tricky, especially when you need to handle situations where top positions tie. In programming, this can be quite a puzzle, but Vik explains that SQL offers a simple solution with its “rank” function—so pushing down work from the application into the database makes a lot of sense in this case.
“I think you need to get to the point where [using SQL] is an actual choice meaning that you know exactly how to do it in SQL and then you choose to do it in SQL or in something else. But until you have that skill level, that allows you to make it an explicit choice in your mind, like I could do it that way or this way and my preference today is this way. Well, then that's cool.” – Dimitri Fontaine
Dimitri’s advice to grow your skillset in SQL is to practice it everyday for at least 15-30 minutes. Use datasets that are interesting to you so that the Postgres queries you practice with also reveal interesting results. Likewise, you can think of possible ways on how SQL can help you answer questions using data from your job. The main idea is that you start using SQL to get answers to questions you care about.
Where to find Path To Citus Con podcast episodes (& transcripts)
Our next podcast episode will be recorded live on Discord:
- When = Wed Dec 6 @ 10am PST | 1pm EST | 6pm UTC
- Topic = My journey into Postgres Monitoring with Lukas Fittl and Rob Treat
- Calendar invite: To participate in the live text chat that happens in parallel to the live recording (it’s fun), mark your calendar. All the instructions for joining the live show on Discord are in the calendar invite.
You can find all the past episodes for the Path To Citus Con podcast on:
More useful links:
- Index of all past Path To Citus Con episodes
- Subscribe to the calendar to know when all the future shows are coming up here.
Thanks for listening! Since Path To Citus Con is a new(ish) podcast for developers who love Postgres, if you enjoy it, please tell your teammates. Also: we really appreciate ratings and reviews, so more people will discover the podcast. Let us know what you think!
Attribution: This blog post by Ari Padilla about Episode 9 highlights of the Path To Citus Con podcast (with guests Dimitri Fontaine & Vik Fearing) was originally published on the Citus Open Source Blog.