TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How to get better in advanced SQL

132 pointsby dprophecyguyover 6 years ago
How to get better at indexing? How to get better at joins? How to get better in SQL optimization?<p>Must to know things about SQL and maybe relational databases?

13 comments

MarkusWinandover 6 years ago
Since you ased about indexing in particular, here is my site about indexing:<p><a href="https:&#x2F;&#x2F;use-the-index-luke.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;use-the-index-luke.com&#x2F;</a><p>You might also want to follow my other project:<p><a href="https:&#x2F;&#x2F;modern-sql.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;modern-sql.com&#x2F;</a>
评论 #19151029 未加载
评论 #19153693 未加载
评论 #19153185 未加载
评论 #19160234 未加载
评论 #19159566 未加载
password4321over 6 years ago
Ask HN: What is the best online resource to learn advanced SQL? <i>(Jan 2017: 448 points, 97 comments)</i><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13417326" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13417326</a>
hal_mcgeeover 6 years ago
Search for a copy of the DB2 SQL Cookbook. Lots of good explanations and examples. It&#x27;s free and no longer updated as I guess it is just too darn useful...<p>One of the problems with advanced SQL is you get into how the vendors implement advanced features. In Oracle you will get familiar with ORA-xxx and coding around those. DB2 throws different error messages and so does SQL Server. I have had to rewrite SQL going from one implementation to another because of these differences.
diehundeover 6 years ago
Just by doing advanced exercises. For example take a look at the SQL homework for one of the CMU courses on databases:<p><a href="https:&#x2F;&#x2F;15445.courses.cs.cmu.edu&#x2F;fall2018&#x2F;homework1&#x2F;" rel="nofollow">https:&#x2F;&#x2F;15445.courses.cs.cmu.edu&#x2F;fall2018&#x2F;homework1&#x2F;</a><p>While doing the exercises you&#x27;ll be doing some research and looking at question in stack overflow.
antoineMoPaover 6 years ago
What worked well for me was getting a job in a small industrial business with a lot of IOT sensors. This brought a lot of SQL queries to optimize...<p>Using tools like MySQL WorkBench or dBeaver is essential to try queries in a friendly interface (tools that show time spent on queries &amp; better tables than command line). Ideally, you should also search for database normalization.<p>If you don&#x27;t have a database to practice with, you can analyze a small business need (ex.: managing employee salary, address &amp; tasks), then create the schema. Then, you should generate tons of fake data to have a substantial time difference when optimizing queries. Try selecting all employees and their tasks, with different sorts. Try finding all employees with an address that starts with 4. Find all employees with a &quot;i&quot; in their name and where the task name is &quot;plumber&quot;, etc.<p>Also, read about rails&#x2F;laravel migrations, as they are the best methods I know to manage database versions.
dkarpover 6 years ago
I&#x27;ve found the leetcode[1] database problems have helped me quite a lot - especially to see different ways of solving problems and how to do things in SQL that you didn&#x27;t know you could.<p>1. <a href="https:&#x2F;&#x2F;leetcode.com&#x2F;problemset&#x2F;database&#x2F;" rel="nofollow">https:&#x2F;&#x2F;leetcode.com&#x2F;problemset&#x2F;database&#x2F;</a>
Pamarover 6 years ago
I would reccomend this book:<p><a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;Art-SQL-Stephane-Faroult&#x2F;dp&#x2F;0596008945" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;Art-SQL-Stephane-Faroult&#x2F;dp&#x2F;059600894...</a>
deanfranksover 6 years ago
&quot;SQL for Smarties&quot;, Joe Celko -- an excellent resource
评论 #19150739 未加载
JeffRosenbergover 6 years ago
Start generating and reviewing explain plans for your queries. There&#x27;s a ton of information available about how the engine is implementing your queries, and learning how to think like the database engine will really help you level-up the way you think about SQL.
rayrrrover 6 years ago
For SQL optimization, learn to use window functions and&#x2F;or Common Table Expressions if available in your variant of SQL. For joins, others have mentioned EXPLAIN: you can use that command to see the &quot;query plan&quot; for any query, which is sort of the equivalent of assembly code. You should learn which of your SQL variant&#x27;s &quot;join algorithms&quot; at the query plan level are the most performant, and aim to use those types of joins in your queries.
amingilaniover 6 years ago
If you&#x27;d like to gamify the process, I recommend CodeWars[0]<p>They give you challenges that progressively get harder. You can choose from many different languages but SQL is one of them. I&#x27;m not affiliated with them, but I used them for a few months to get incredibly good with Ruby.<p>[0]: referral link: www.codewars.com&#x2F;r&#x2F;EbsMWQ
umlautaeover 6 years ago
It depends a lot on the database flavor. My suggestion is to search for “tips and tricks“ for your particular DB.
ksherlockover 6 years ago
Learn relational algebra. Learn relational calculus. You&#x27;ll probably want to read a book or take a class on DB theory; blog posts won&#x27;t cut it.