Navicat Blog

Some Top SQL Query Mistakes: Part 2 - Non-SARGable Query Conditions Apr 26, 2022 by Robert Gravelle

Part 2: Non-SARGable Query Conditions

Like most programmers, database developers tend to write code that is more or less a direct translation of a given request. The fact that most programming languages - SQL included - are designed to be human readable, also contributes to this problem. Why is this a concern? All programming languages execute certain operations faster than others. In relational databases, the query optimizer analyzes SQL queries and determines the efficient execution mechanisms called query plans. The optimizer generates one or more query plans for each query, each of which represent one possible way to run a query. The most efficient query plan is then selected and utilized to run the query. As it turns out, SQL that mimics the language of a request is seldom the most efficient approach.

In this installment of the Top SQL Query Mistakes series, we'll explore one example of a poorly written SQL statement and rewrite it in a way that increases efficiency.

Some Top SQL Query Mistakes - Part 1 Apr 11, 2022 by Robert Gravelle

NOT IN Versus NOT EXISTS

There's a term the is commonly thrown around in programming circles called "anti-patterns". It refers to a response to a recurring problem that is not only ineffective, but also risks being highly counterproductive. The term was originally coined in 1995 by computer programmer Andrew Koenig, in his book Design Patterns, as the antithesis of design patterns that are considered to be both reliable and effective.

Working with Dates and Times in MySQL - Part 5 Apr 1, 2022 by Robert Gravelle

Querying by Date

In this final installment in this series on Dates and Times in MySQL, we'll be putting everything we've learned thus far into practice by writing SELECT queries to obtain date-related insights into our data.

Working with Dates and Times in MySQL - Part 4 Mar 22, 2022 by Robert Gravelle

Date/Time Creation

In this this series on Dates and Times, we've explored MySQL's five temporal data types, as well as some of its many date/time-oriented functions. In this installment, we'll be covering a few ways to create dates and times in MySQL.

Working with Dates and Times in MySQL - Part 3 Mar 14, 2022 by Robert Gravelle

Important Functions

In the first two installments of this series on Dates and Times, we covered MySQL's five temporal data types. Now it's time to turn our attention to some of MySQL's many date/time-oriented functions.

Getting the Current Date and Time

Back in May of 2021, we covered some of SQL Server's notable Date & Time functions, starting with how to obtain the current date and time. It offers the GETDATE() function for that purpose. MySQL's equivalent function is simply called NOW(). In Navicat for MySQL 16, we can invoke this function without connecting to a database, since we aren't selecting any table columns:

Navicat Blogs
Feed Entries
Blog Archives
Share