---
title: "#166: How To Write Better SQL Queries"
publication: "DB Weekly"
issue: 166
published_at: "2017-08-04"
canonical_url: "https://dbweekly.com/issues/166"
---

Database Weekly 166   

This week's database news -[Read this on the Web](http://dbweekly.com/issues/166) 

[Database Weekly](http://dbweekly.com) Issue 166 — August 4, 2017     

[More Dangerous Subtleties of JOINs in SQL](http://alexpetralia.com/posts/2017/7/19/more-dangerous-subtleties-of-joins-in-sql?utm_source=dbweekly&utm_medium=email) — Two examples of how common, yet profoundly consequential, semantic errors in SQL can be. Alex Petraliatutorial [Implementing State Machines with SQL in Postgres](http://felixge.de/2017/07/27/implementing-state-machines-in-postgresql.html?utm_source=dbweekly&utm_medium=email) — A practical look at creating a FSM using a transition function, a user-defined aggregate function and a table to keep track of events. Felix Geisendörfertutorial [A Live Demo With a VividCortex Engineer](https://www.vividcortex.com/live-product-demo?utm_campaign=DB%20Weekly&utm_source=ppc&utm_medium=Weekly%20Live%20Demo) — Join a live demo with a VividCortex engineer to show how the VividCortex solution can eliminate your most critical visibility gaps. VividCortexsponsored [![\](https://copm.s3.amazonaws.com/83dafe1a.png)](https://www.vividcortex.com/live-product-demo?utm_campaign=DB%20Weekly&utm_source=ppc&utm_medium=Weekly%20Live%20Demo) [How To Write Better SQL Queries](https://medium.com/towards-data-science/sql-tutorial-how-to-write-better-queries-108ae91d5f4e?utm_source=dbweekly&utm_medium=email) — A reasonably thorough primer to SQL queries and the decisions you have to make while constructing them. Karlijn Willemstutorial [TiSpark: Run Apache Spark on Top of TiDB/TiKV](https://github.com/pingcap/tispark?utm_source=dbweekly&utm_medium=email) — A thin layer that brings Spark SQL to [TiKV](https://github.com/pingcap/tikv) (a distributed key value store) for doing complex OLAP queries. PingCAPtools [A Practical Guide to SQL Transaction Isolation](https://begriffs.com/posts/2017-08-01-practical-guide-sql-isolation.html?utm_source=dbweekly&utm_medium=email) — A detailed post on how transaction isolation works, particularly in Postgres. A good read if you just rely on the defaults. Joe Nelsontutorial [Shoveling Data to Redshift with Pipes and Filters](https://urjitbhatia.github.io/posts/2017/07/30/Shoveling-data-to-Redshift-with-pipes-and-filters.html?utm_source=dbweekly&utm_medium=email) Urjit Singh Bhatiatutorial [How to migrate from SQL to MongoDB](https://resources.mongodb.com/migrating-to-mongodb?jmp=cpress&utm_campaign=WW_CP_newsletter_sponsorship_FY17Q2&utm_content=sponsored&utm_medium=display&utm_source=dbweekly0804) — Learn why today's most innovative companies are migrating to MongoDB. MONGODBsponsored [Building a Simple GraphQL Server with Neo4j](https://www.oreilly.com/learning/building-a-simple-graphql-server-with-neo4j?utm_source=dbweekly&utm_medium=email) William Lyontutorial [How Far Can You Go with MySQL or MariaDB?](http://jfg-mysql.blogspot.com/2017/07/how-far-with-mysql-mariadb.html?utm_source=dbweekly&utm_medium=email) — There are installations heading into multiple terabytes. Jean-François Gagnéstory [Analyzing 320 GB of SQL for Comma Usage](https://hackernoon.com/winning-arguments-with-data-leading-with-commas-in-sql-672b3b81eac9?utm_source=dbweekly&utm_medium=email) — _“Leading with commas is not a popular style — but I’ll argue that it’s a productive one. Can I prove this?”_ Felipe Hoffastory [Open Source Redshift Vacuum and Analyze Tool](https://www.alooma.com/blog/vacuum-analyze?utm_source=dbweekly) — Save time on maintenance, use our dockerized vacuum & analyze tool. Pull the image, schedule, and get reports to your email. Alooma.​iotools sponsored [q: Run SQL directly on CSV files](https://harelba.github.io/q/?utm_source=dbweekly&utm_medium=email) — Loads CSV into SQLite and lets you query with SQL. Harel Ben-Attiatools [TablePlus: A Mac App for Working with Relational Databases](https://tableplus.io/?utm_source=dbweekly&utm_medium=email) — Currently supports Postgres, MySQL/MariaDB, and Redshift. TablePlus Ltdtools [Neo4j Releases Efficient Graph Algorithms Library for Neo4j](https://neo4j.com/blog/efficient-graph-algorithms-neo4j/?utm_source=dbweekly&utm_medium=email) — Covers things like PageRank, partitioning, and path finding. Michael Hungertools [Apache Calcite: A Foundation for High Performance Databases](https://calcite.apache.org/?utm_source=dbweekly&utm_medium=email) — A Java dynamic data management framework that includes a SQL parser, a relational algebra API, and a query planning engine. Apache Foundationtools [Rezoom.SQL: Statically Typed SQL ORM for F#](https://github.com/rspeele/Rezoom.SQL?utm_source=dbweekly&utm_medium=email) Robert Peelecode [An Opinionated MongoDB Style Guide](https://github.com/jsoendermann/MongoStyleGuide?utm_source=dbweekly&utm_medium=email) Jan Söndermanncode    

Database Weekly is curated by Peter Cooper [Read this issue on the Web](http://dbweekly.com/issues/166) [See our archives](http://dbweekly.com/issues) [Change your email address](*|UPDATE_PROFILE|*)  [Stop getting this newsletter](*|UNSUB|*)  

Published by [Cooperpress](https://cooperpress.com/)
Fairfield Enterprise Centre, Lincoln Way, Louth, LN11 0LS, UK
