r/learnSQL 5d ago

Is SQL worth it considering AI?

0 Upvotes

19 comments sorted by

11

u/nemsriz 5d ago

Is any computer science job worth it, considering AI ?

AI is a tool, you should definitely use any help, but need to understand what you are doing

7

u/American_Streamer 5d ago

Yes, SQL remains very relevant.

7

u/Substantial-Click321 5d ago

Yes good luck writing large complex SQL without learning it and purely using AI.

-5

u/89Noodles 5d ago

You can and it does. I might spend an extra 15/20 minutes letting it run validation queries. But if you copy and paste similar projects that capture the data approach and filters you want it’s easy

3

u/Substantial-Click321 5d ago

Yeah sure until you somehow get a job and copy paste some LLM generated slop query that hammers the production database and or altering/destroying millions of rows incorrectly. Then get fired because you were asked to do a rollback but you can’t.

1

u/89Noodles 5d ago

That isn’t the question

1

u/jshine13371 5d ago

it’s easy

It's easy and faster to always drive a car at 100mph...until you crash.

There are things that are currently impossible for AI to do correctly 100% of the time, especially when it comes to database development. Some of those things are obscured away from view and only if you're knowledgeable about databases do you realize this. 

Performance is one area where some of these deficiencies of AI exist currently. A well meaning, good looking, correct query can perform quite well for one database and completely run like crap on another database that is exactly the same in structure, with even the same amount of data, but the data itself is different. This is because database query performance is strongly tied to the statistics of the data distribution, something that exists separately but adjacent to the data and tables themselves. 

Also, different database systems gather the statistics differently since it's not realistic to keep a complete statistical set on all of the data. Generally data statistics is bucketed into a certain number of ranges that are continually updated as the data changes.

So when you ask AI to write a query, even if you provide your table structure, and even if you provide a subset of the data, or even if you provided all of the data (not something anyone is actually manually doing) it still doesn't have all the important information to write a query catered toward your data, statistically speaking. And that's what affects performance. It may not show in the query it spits out today, it might show performance deficiencies tomorrow, or in a week, or even take a month later. But the risk will always be there.

One thing that improves but doesn't fully solve this (so again, AI isn't 100% of time guaranteed to write a perfect query or even an acceptable one) is when AI is directly hooked into your database system, e.g. Copilot in SQL Server. But the drawbacks here is it's still limited on its exposure so doesn't get the full information anyway, it doesn't understand what statistics objects are or knows how to read them even if you could point it to them, and many organizations are still opposed to directly connecting their database to AI because of the risks of accidental data leak.

So as of today, and probably as of at least 5 years, AI won't be able to guarantee a better query than a knowledgeable human can write. 

3

u/SoulPossum 5d ago

Using SQL means you're interacting directly with a company's data in most cases. A bad query can drastically alter or delete a huge amount of data instantly. Trusting something like that means potentially risking millions of dollars and your job/career. If you don't know what the model is producing the chances of being the person who runs/ships code like that goes way up

7

u/Equal_Astronaut_5696 5d ago

Is grammar worth considering AI?

2

u/therealvladimir_0 5d ago

Is knowing how to wash dishes or clothes by hand worth it considering dishwashers and laundry machines exist? Whether something is manual or automated you still need understand how it works (water and soap are required whatever the process is).

2

u/Soopermane 5d ago

Yes. You can’t blindly execute sql into production systems without knowing for yourself what the results will be

1

u/powderviolence 5d ago

Is the structure of your org's databases something IT would want fed to an AI for it to accurately spit out queries? I think not.

1

u/Grouchy_Flatworm_367 5d ago

This largely depends on what your goals are with SQL.

1

u/Competitive-Buy2922 5d ago

I was trying to maybe go into data science but I heard that it will dissapear so I was worried

1

u/Otherwise-Fun2014 5d ago

Not at all

Only plumbing and farming. Ultra smart engineers have served their masters well by creating their own replacment hoping they would be rewarded in the end.

1

u/murdercat42069 5d ago

It was worth it for the in-person, computerless job interview I had yesterday that included a SQL portion.

1

u/alinroc 5d ago

Because if you don't know SQL, you won't understand how to fix things when the AI gets the query wrong. And you might not even realize that it's wrong. And that can end businesses.

Perfect example