Re: Change JOIN tutorial to focus more on explicit joins - Mailing list pgsql-docs

From Jürgen Purtz
Subject Re: Change JOIN tutorial to focus more on explicit joins
Date
Msg-id 81d5be9d-aa6f-f181-bea9-5a852b876cad@purtz.de
Whole thread Raw
In response to Re: Change JOIN tutorial to focus more on explicit joins  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: Change JOIN tutorial to focus more on explicit joins  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-docs
On 22.10.20 17:14, Pavel Stehule wrote:
>
> Why do you use parenthesis for ON clause?  It is useless. SQL is not C 
> or JAVA.


Two more general answers:
- Why do people use tabs, spaces, and newlines to format their code even 
though it's not necessary? SQL is a language to develop applications. 
And what are the main costs of an application? It's not the time which 
it takes to develop them. It's the time for their maintenance. During 
the course of one or more decades, different persons will have to read 
the code, add additional features, and fix bugs. They need some time to 
read and understand the existing code. This task can be accelerated if 
the code is easy to read. Therefore, it's a good habit of developers to 
sometimes spend some extra characters to the code than is required -  
not only comments. An example: there are clear precedence rules for 
Boolean operators NOT/AND/OR. In an extensive statement it may be 
helpful - for the developer himself as well as for anybody else -to use 
newlines and parentheses at places where they are not necessary to keep 
an overview of the intention of the statement. In such cases, 
code-optimization is the duty of the compiler, not of the developer.
- In my professional life as a software developer, I have seen about 15 
different languages. But only in rare cases, they have offered new 
features or concepts. To overcome this Babylonian linguistic diversity I 
tend to use such syntactical constructs which are common to many of them 
even, even if they are not necessary for the concrete language.

And the concrete answer: Omitting the parentheses for the join condition 
raises the danger that its Boolean operators are mixed with the Boolean 
operators of the WHERE condition. The result at runtime is the same, but 
a reader will understand the intention of the statement faster if the 
parentheses exists.

--

J. Purtz





pgsql-docs by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Change JOIN tutorial to focus more on explicit joins
Next
From: Pavel Stehule
Date:
Subject: Re: Change JOIN tutorial to focus more on explicit joins