sql

2023-06-02T20:26:04.887239Z

Does all things SQL include… how to get better at SQL? What courses/books/video tutorials do you guys suggest to elevate your SQL foo?

2023-06-07T09:16:27.345029Z

can I and should I do this in SQL, haha

➕ 1
slipset 2023-06-03T10:02:21.381659Z

I think that a curious mindset is valuable too. Asking “I wonder if I could do this in my database rather than in my application code” gets you a long way .

slipset 2023-06-03T10:03:37.875229Z

Getting familiar with PARTITION BY , common table expressions, remembering that you can have sub-queries almost all over the place are things that might help

slipset 2023-06-03T10:05:13.794359Z

eg select (select bar from foo where foo.id = id) from baz where qix = 'qux' is an example of a neat trick which lets you write more composable queries which is a huge win when working with #honeysql

mauricio.szabo 2023-06-06T21:55:44.141669Z

Remember that asking yourself "can I do this on my database" the answer usually is "yes", so try to not fall too deep into a rabbit hole, like trying to solve the Advent of Code in pure SQL: https://gitlab.com/mauricioszabo/advent-of-code-2021/-/tree/master/src 🤣

🙂 1
mauricio.szabo 2023-06-06T21:56:57.063089Z

The last day I dared it's basically an adapted version of the "A* Pathfinding" algorithm, but I never made it so it performed well to solve the second part of the challenge...

isak 2023-06-06T22:04:40.643129Z

I think it is a really great way to learn. E.g., create a sudoku solver in Clojure, then try it in SQL.

mauricio.szabo 2023-06-06T22:22:09.810529Z

Also I remember something I learned quite early - somebody was explaining SQL and he said: "SQL Hates Loops! Transform everything into tables and join, filter them, but don't do loops!" Another thing is to learn how to use EXPLAIN - might save a lot of time debugging things

isak 2023-06-02T20:49:49.548099Z

This one: https://use-the-index-luke.com/

2023-06-02T20:55:42.919709Z

Very interesting! From my 1 minute scan, thats about perf, right? I am also very interested in writing more advanced queries

isak 2023-06-02T21:59:16.596759Z

Yea, true. For learning about more advanced queries, I read/skimmed a few books such as this: https://www.amazon.com/T-SQL-Window-Functions-Developer-Reference-dp-0135861446/dp/0135861446/ref=dp_ob_title_bk Though that one is is for SQL Server, not sure what you use.

isak 2023-06-02T22:00:39.395579Z

But lately I'm not sure it is worth it, because it seems performance falls over so easily for complex queries

2023-06-02T22:18:27.584569Z

Postgres. Ironically I’ve been looking at whether we can leverage the database more :’).

🙂 1
2023-06-03T01:53:50.770979Z

I found https://theartofpostgresql.com very helpful