SQL is a verbose language, and one of the most verbose features are window functions. In a stack overflow question that I've encountered recently, someone asked to calculate the difference between the first and the last value in a time series for any given day: Input volume tstamp --------------------------- 29011 2012-12-28 09:00:00 28701 2012-12-28 10:00:00 … Continue reading How to Reduce Syntactic Overhead Using the SQL WINDOW Clause
Tag: mysql
JOIN Elimination: An Essential Optimiser Feature for Advanced SQL Usage
The SQL language has one great advantage over procedural, object oriented, and "ordinary" functional programming languages. The fact that it is truly declarative (i.e. a 4GL / fourth generation programming language) means that a sophisticated optimiser can easily transform one SQL expression into another, equivalent SQL expression, which might be faster to execute. How does … Continue reading JOIN Elimination: An Essential Optimiser Feature for Advanced SQL Usage
jOOQ 3.10 Supports Exciting MySQL 8.0 Features
In recent months, there had been some really exciting news from the MySQL team: (Recursive) Common Table Expressions in MySQL Introducing Window Functions These two SQL standard language features are among the most powerful SQL features that are available from most other databases. I frequently include them in conference talks about SQL (see my article … Continue reading jOOQ 3.10 Supports Exciting MySQL 8.0 Features
How to Execute SQL Batches With JDBC and jOOQ
Some databases (in particular MySQL and T-SQL databases like SQL Server and Sybase) support a very nice feature: They allow for running a "batch" of statements in a single statement. For instance, in SQL Server, you can do something like this: -- Statement #1 DECLARE @table AS TABLE (id INT); -- Statement #2 SELECT * … Continue reading How to Execute SQL Batches With JDBC and jOOQ
The 10 Most Popular DB Engines (SQL and NoSQL) in 2015
About two years ago, we've published this post about the 10 most popular DB engines, where we analyzed the data published by Solid IT on their DB Ranking website. In the meantime, the Solid IT measurement system has found to be a credible source, such that the website has also been cited at Gartner, InfoWorld, … Continue reading The 10 Most Popular DB Engines (SQL and NoSQL) in 2015
Use MySQL’s Strict Mode on all new Projects!
MySQL is a database that has been bending the SQL standard in ways that make it hard to move off MySQL. What may appear to be a clever technique for vendor lockin (or maybe just oversight of the standard) can be quite annoying in understanding the real meaning of the SQL language. One such example … Continue reading Use MySQL’s Strict Mode on all new Projects!
Don’t Migrate to MariaDB just yet. MySQL is Back!
Now that I have your attention, I'd like to invite you to a critical review of where we're at in the MySQL vs. MariaDB debate. Around one month ago, I visited Oracle Open World 2014, and I've met with Morgan Tocker, the MySQL community manager at Oracle to learn about where MySQL is heading. Who … Continue reading Don’t Migrate to MariaDB just yet. MySQL is Back!
Frightening Facts about MySQL
So you might've seen Destroy all Software's talk about JavaScript: Here's a similar talk (less funny more scary) about MySQL: https://www.youtube.com/watch?v=emgJtr9tIME
Should I Put That Table Alias or Not?
Infrequent SQL developers often get confused about when to put parentheses and/or aliases on derived tables. There has been this recent Reddit discussion about the subject, where user Elmhurstlol was wondering why they needed to provide an alias to the derived table (the subselect with the UNION) in the following query: SELECT AVG(price) AS AVG_PRICE … Continue reading Should I Put That Table Alias or Not?
Yet Another 10 Common Mistakes Java Developers Make When Writing SQL (You Won’t BELIEVE the Last One)
(Sorry for that click-bait heading. Couldn't resist ;-) ) We're on a mission. To teach you SQL. But mostly, we want to teach you how to appreciate SQL. You'll love it! Getting SQL right or wrong shouldn't be about that You're-Doing-It-Wrong™ attitude that can be encountered often when evangelists promote their object of evangelism. Getting … Continue reading Yet Another 10 Common Mistakes Java Developers Make When Writing SQL (You Won’t BELIEVE the Last One)