I think for a lot of people, SQL is a skill that doesn't stick. You learn enough to do the queries you need for your project, they work then you forget about them as you work on the rest of your project. These skills are perishable. Left outer join? Yeah, I knew what that was some time ago, but not anymore The days of dedicated SQL programers are mostly gone.
Exactly. I own a software consultancy, and I tried explaining this to an engineering manager and he just didn't get it. For some reason, he couldn't understand that when you write SQL queries for a project, you typically do it once, and basically never again, with the exception of maybe adding or removing columns from the query. The "hard work," if you can call it that, is all in the joins. Then, I completely forget…
Practical SQL for Data Analysis
171–180 of 198 posts
Re: Practical SQL for Data Analysis
#172Re: Practical SQL for Data Analysis
#173Re: Practical SQL for Data Analysis
#174Earlier quoted context omitted.
Within the VA hospital system, the data admins often got onto their "soapboxes" to dress down the 1400+ data analysts for writing inefficient SQL queries. If you need 6 million patients, joining data from 15 tables, gathering 250 variables, a beginning SQL user has the potential to take 15-20 hours where they could be pulling for 1-2 if they do some up-front filtering and sub-grouping within SQL. If you already know…
I can't help thinking that with better processes and tools those 1400 analysts could instead be 50 analysts? (or even 5?) And that building an aggregation ETL pipeline, maybe inspired by this post, could be the solution?
Re: Practical SQL for Data Analysis
#175Earlier quoted context omitted.
Within the VA hospital system, the data admins often got onto their "soapboxes" to dress down the 1400+ data analysts for writing inefficient SQL queries. If you need 6 million patients, joining data from 15 tables, gathering 250 variables, a beginning SQL user has the potential to take 15-20 hours where they could be pulling for 1-2 if they do some up-front filtering and sub-grouping within SQL. If you already know…
How many TBs of data are we really talking here, if it's just 6M rows? Surely this processing could easily be done on a single machine.
Re: Practical SQL for Data Analysis
#176Now when the analysis is done and there's a conclusion about putting some of it in production, I am yet to see a single company that relies on pandas to do data transforms "online", i.e. on the live production data stream. Typically in my experience I would end up rewriting my data transforms in either a compiled language or SQL - i.e. something much more performant and maintainable.
As a result as you progress in your career you become very proficient in both pandas and SQL - and you also start glancing at the source code of some of the transforms performed by pandas when you need to port them to the language of choice of the company you're working for.
Re: Practical SQL for Data Analysis
#177Earlier quoted context omitted.
I understand your point generally but I don't understand this example. If you need data from 15 tables, you need to do those joins, regardless of prefiltering or subgrouping, right?
Well, yes but. Why do you need 15 tables for analysis queries and why isn't someone rolling those tables into something a bit easier with some backend process.
Re: Practical SQL for Data Analysis
#178Earlier quoted context omitted.
> Compared to pandas? No, it's not. I'm not saying you shouldn't use pandas, it depends on the size of the data. I'm working right now on a project where a SELECT * of the entire fact table would be a couple hundred gigabytes. The flow is SQL -> pandas -> manipulation, and as always in pipelines like those, the most work you can do at the earliest stage, the better.
Yeah, speaking as a data person, the SQL argument is correct. Python/R are much, much, much slower for this kind of work. OTOH, SQL is super limiting for a lot of data analysis tasks and you'll inevitably need the data in weird forms that require lots of munging. Personally, I'm a big fan of using SQL/Airflow/whatever to generate whatever data I'll need all the time at a high level of granularity (user/action etc), a…
OTGH, to some (I suspect often rather large) extent, that's because most people (I suspect including many "data scientists") are pretty bad at doing their data munging in SQL.
Re: Practical SQL for Data Analysis
#179Earlier quoted context omitted.
parent post says "devs do SELECT *" and ... relational databases can have a lot more data in one table, or related tables, than one query needs. It is often very wasteful of RAM to get ALL and filter again
If your query does " * " it gets all the columns in all the tables. Often, the optimizer when all the columns you need are on the index, never visits the actual table (I remember the term covered index). " * " basically screws this up. "Select *" should never be used in anything in an actual production environment.
Re: Practical SQL for Data Analysis
#180Earlier quoted context omitted.
I can't help thinking that with better processes and tools those 1400 analysts could instead be 50 analysts? (or even 5?) And that building an aggregation ETL pipeline, maybe inspired by this post, could be the solution?
VA is a massive org, this is not a particularly large number of analysts for a healthcare system of this size (or honestly any complex org).
I come from a small country, in total comparable to the 6 million veterans mentioned here.
1400 analysts is just a lot and I wouldn't imagine for example our national healthcare service could ever employ that amount of analysts?
Hm, or would they? It would make a pretty big dent in the total amount of persons in that field in our country.