NUKnightLab/sql-mysteries

Walkthrough has an example that may be inadvisable

jjhoo opened this issue · 3 comments

jjhoo commented

The query

SELECT DISTINCT city 
FROM crime_scene_report 
WHERE LOWER(city) = 'sql city';

has a WHERE condition that may perform poorly generally speaking. If there was an index on crime_scene_report.city it might not be utilized due to LOWER(city), leading to bad performance due to a full table scan.

Thanks for your interest in the project! That specific example is given in the context of learning about the existence of UPPER and LOWER functions, so it's hard to know how to teach those to people without running the theoretical risk you identify. Do you have a suggestion?

Adding a comment about that pitfall after the query. Or have a specific optional section at the end of that tutorial about performance considerations, if you feel it is too early to talk about those when UPPER and LOWER are introduced.

raylu commented

for an exploratory introduction to SQL, I think it's ok to leave out schema structure details like reasoning about query performance