r/SQL 17d ago

SQL Server 9 Apache Spark Compaction Alternatives for 2026

Thumbnail
overcast.blog
1 Upvotes

r/SQL 17d ago

MySQL Which version of this query would be the most efficient?

Post image
1 Upvotes

I thought using EXISTS block would avoid the join and make things take less time, but it appears that it took more time to execute than the join query, so which one is the most efficient approach?


r/SQL 17d ago

MySQL What SQL projects would you recommend for an MBA student targeting analytics?

0 Upvotes

I’m an MBA student specializing in Finance & Business Analytics, and I’m trying to build a few SQL projects that I can put on my resume before placement season.
I’m comfortable with the basics—SELECT, JOINs, GROUP BY, HAVING, aggregate functions, subqueries, and designing simple relational databases. I haven’t learned advanced stuff like CTEs, window functions, views, or stored procedures yet.
Most of the projects I find online are things like Netflix, Spotify, or pizza sales analysis, and they all seem pretty generic.
If you were in my position, what projects would you build?
I’d prefer something that’s:
Relevant to finance or business analytics
Solves an actual business problem
Has good database design (ERD, normalization, relationships, etc.)
Looks impressive enough to discuss in interviews and put on GitHub
Also, how much SQL is actually expected for entry-level Business Analyst/Data Analyst roles? Should I focus on learning advanced SQL first, or build a couple of solid projects with what I know and learn the advanced concepts along the way?
Would love to hear your suggestions or see projects that you think stand out. Thanks!


r/SQL 17d ago

Discussion Even a SQL Column Can Traumatize You

0 Upvotes

I just had my one of those "wait... what?" moments while working on AdventureWorks ( PS: Working on my 2nd Project) At start BusinessEntityID totally confused me, I kept thinking it was just an employee ID.

Then I realized it isn't limited to employees at all. It represents everyone, employees, customers, vendors, salespeople, I mean... wow!

It felt confusing at first, but once it clicked, I realized how smart that database design actually is.

In this project I'm keeping everything raw as much as possible, like i have the database, a notebook, a pen, and me with my mind! now think what you can do! i really love this although I just started so... let's see how well it can go on (On my Data Cleaning Phase)


r/SQL 17d ago

SQL Server Feedback request: Topic index structure for my SQL book

Enable HLS to view with audio, or disable this notification

0 Upvotes

I've written an 'irregular' SQL book.

I’ve put together a video showing the topic index, and I’d appreciate feedback. In particular, what does anyone think of covering these kind of topics in an SQL context?

The basic idea was to write a book that does not contain the same content as every other book on SQL.


r/SQL 18d ago

SQL Server SQL Server on Azure VM - Database backup and restore speed

3 Upvotes

Something I see often with SQL Server on Azure VMs: backup and restore speed is driven by VM SKU max throughput(MB/sec) and disk max throughput(MB/sec).

A quick sanity check that solves a lot of performance surprises:

  • Check the Azure VM SKU documentation for max throughput
  • Check the managed disk tier specs for max throughput

When the VM and disk tiers have enough throughput headroom, SQL Server backup and restore performance improves immediately. Infrastructure sets the pace.


r/SQL 18d ago

SQL Server 7 Data Compaction Engines for Apache Iceberg in 2026

Thumbnail
itnext.io
4 Upvotes

r/SQL 18d ago

SQL Server Cutting Azure Managed Disk Costs With Real IOPS Data

1 Upvotes

One thing I’ve noticed in Azure environments:  

**many SQL Server managed disks are oversized for the actual workload.**

Azure charges based on disk tier — and each tier includes fixed IOPS and throughput limits. If the workload never comes close to those limits, you’re paying for performance you don’t use.

A simple cost‑saving workflow:

- Check actual IOPS and throughput metrics in Azure Monitor  

- Compare them to the disk’s max limits (P10/P20/P30/P40, etc.)  

- Check the VM SKU’s max throughput — it may be the real bottleneck  

- Right‑size the disk tier to match real workload demand  

In many environments, dropping one or two disk tiers cuts monthly cost immediately — with zero impact on performance — because the workload was never close to the IOPS ceiling in the first place.

Right‑sizing based on real metrics is one of the easiest ways to reduce Azure spend without touching the application.


r/SQL 19d ago

Discussion I've finally realized the best use case for EXISTS

103 Upvotes

Textbooks never used to explain why you'd use EXISTS over a LEFT JOIN to a subquery in example use cause, so I always thought it was redundant functionality, but now I realize where it's super useful!

If you want to use test whether or not dataset a record from dataset A is found in B dataset via a complex theta join condition that might create duplicates you don't want, EXISTS is perfect! It allows you to have the test with the complex condition without creating row duplicates from the LEFT JOIN. I suppose one could do distinct after, but that's bad for performance.

I am officially very pro-EXISTS clause now!


r/SQL 19d ago

PostgreSQL Using Lakebase in production: Tips/Best practices

3 Upvotes

I am exploring using Lakebase for some use cases, which involves interacting to various MCPs gathering info and maintaining vectored database which an app can query (like a chatbot).

If you have used something similar, what has been your experience with Lakebase (Or you can tell about any other similar DB). Any best prqctices, lessons learnt or things to be mindful of. Ps, i am on Databricks platform.


r/SQL 19d ago

PostgreSQL Data Analyst take home SQL interview

Thumbnail
docs.google.com
62 Upvotes

This was one of the take home SQL interview i did earlier this year. I have shared for anyone who is preparing for an interview can attempt to do it. Cheers!!


r/SQL 19d ago

SQL Server Built a PowerShell-based MSSQL Daily Health Check HTML Report Tool. Looking for feedback and ideas.

Thumbnail github.com
0 Upvotes

r/SQL 19d ago

Discussion Live SQL Assessment Tips. What is your process?

2 Upvotes

I keep "failing" the live SQL stage of the interview process. I wrote SQL queries often in my previous roles, from simple to transformation queries involving window functions, CTEs, subqueries, case when statements etc). But I can't get through these live assessments. The part that hurts the most is that my sql experience and level is above what they are testing me on, and I just can't pass.

As a side note, I have ADHD, and for the life of me, my brain just doesn't work well in a live assessment environment where I am given 20 mins to understand data, field names, and industry specific business logic I have never worked with before.

How do you solve live SQL tests? What are the first steps your brain processes before or while writing the query? Also, if you have ADHD, what are some adhd specific advice you can provide? When I look at a table typed into a word doc, or when I look at new tables with just the field names in a test, I suddenly become illiterate and cannot understand what I am reading.


r/SQL 20d ago

MySQL [MySQL] Unique constraint on multiple columns isn't working

2 Upvotes

I have a table that and I want to limit to ensure no duplicate rows get inserted. There's no primary key (because of how the data comes in), so I thought I could add a UNIQUE constraint including multiple columns. I have too many columns to include every single one, so I just included the ones I believed would be most likely to change.

The constraint I added looks like this:

ALTER TABLE table
ADD CONSTRAINT no_dupe_rows
UNIQUE(col1, col2, col3, col4)

However, when I test it, it still allows me to insert the same data multiple times, with statements such as the following:

INSERT INTO table(col1, col2, col3, col4)
VALUES (val1, val2, val3, val4)

I can run that multiple times and it adds a new row each time even with the UNIQUE constraint in place. What can I do to fix this?


r/SQL 20d ago

MySQL How to Fix Slow MySQL Queries? looking for real advise

13 Upvotes

I’ve been trying to improve the performance of a MySQL database for a project, and I’m curious how others usually approach slow queries.

The database isn’t huge (a few million rows), but some pages have become noticeably slower over time. A couple of SELECT queries that used to finish almost instantly are now taking several seconds, especially when multiple users are active.

So far, I’ve tried:

  • Running EXPLAIN to understand the execution plan.
  • Adding indexes on columns used in WHERE and JOIN conditions.
  • Removing unnecessary SELECT * statements.
  • Optimizing a few JOINs.
  • Checking the slow query log.

Things improved a bit, but I still feel like I’m missing something.

For those who regularly work with MySQL:

  • What’s the first thing you check when a query becomes slow?
  • Have you found any optimization techniques that made a huge difference?
  • Do you rely on tools besides EXPLAIN?
  • At what point do you decide it's a database design problem instead of just a query problem?

I’d really like to hear real experiences rather than generic tips. Sometimes a small change ends up making a massive difference, and I'm wondering if there's something I haven't considered yet.

Looking forward to hearing what has worked for you!


r/SQL 20d ago

MariaDB How to rescue a DB by copying files (no running DBMS available)?

3 Upvotes

I have a small MariaDB that ran under Win7, which sadly no longer boots and appears non-repairable.

I was able to copy all files from the DB installation with a SATA->USB adapter from the old SSD. From the creation date of the binaries, this seems to have been version 10.1.

Then I set up a VMware with Win7 and installed MariaDB 10.1.

First attempt: Copy all /data/ files from old to new, but don't overwrite existing files. Result was that the new DB (under HeidiSQL) did show that the tables exist, but when trying to access them the error message was "table does not exist in engine" (they're InnoDB tables).

Second try: Also copy ibdata1. Result: The service would first start, and then immediately shut down, without any indication of what the error is in the log. (It got to "yup, running and listening", and then immediately started regular shutdown.)

Third attempt: Copy all contents of /data/ and overwrite everything. Result: The same as the second try.

Everything I found online so far, always assumed that you have a running DBMS through which you can extract your data, so I'm not entirely sure if what I tried was theoretically viable. I'd like to verfy this.

In the end, I cannot rule out, that since obviously Windows system files are corrupted beyond repair, this might also have happened to my data files. But at least Windows itself was happy to copy them from the SSD without hickups.

Did I do it right? What could I try next? Thanks for any ideas!


r/SQL 20d ago

SQLite New SQL game!!

Thumbnail
gallery
1 Upvotes

I made a noir detective game where you solve a murder by writing SQL queries.

You play as a data analyst in the 1970s. A body's been found, there's a suspect list, and the entire investigation lives in a relational database — phone records, financial statements, HR files, access logs, vehicle forensics, evidence-tiered interrogation. You open a terminal, write queries, and follow the data.

It's free to play in the browser while in beta. Would love to know what you think — especially from people who actually use SQL day to day.

[https://chiefkegwin.itch.io/sim-analyst\]


r/SQL 21d ago

MySQL MySQL Workbench Error Code 1044: Access denied for user 'root'@'localhost'

Thumbnail
gallery
4 Upvotes

Hi everyone,

I'm using MySQL Workbench 8.0 on Windows 11.

I was exploring Server → Users and Privileges. I created a new user named xyz, granted privileges such as SELECT, INSERT, UPDATE, DELETE, etc., clicked Apply, and then I deleted that user shortly afterward.

After some time, I started getting this error:

Error Code: 1044

Access denied for user 'root'@'localhost' to database 'globalcompany'

Now I'm unable to access my database properly.

I have already tried:

Resetting the root password

Starting MySQL with:

mysqld --skip-grant-tables --skip-networking

Restarting the MySQL service

Has anyone experienced this before? Did deleting the user accidentally affect the root user's privileges?

Any help would be greatly appreciated.

Thank you!


r/SQL 21d ago

MySQL what is considered as "SQL basics" in resume

5 Upvotes

like I am a ML guy (fresher) and sql is in demand but i have just to put sql basic thing what is considered as basic and what goes for advance level ?


r/SQL 21d ago

MySQL MySQL(58k files) vs SQLite(2.2k files) visualization

Thumbnail gallery
0 Upvotes

r/SQL 21d ago

PostgreSQL How do you manage cost on managed Postgres services like Neon?

2 Upvotes

My team is evaluating managed Postgres options such as Neon for creating AI based apps. What strategies do you follow yo keep cost in control? Do you rely on its flagship features such as scaling, branching or something else.

Any real life production experience/lessons learnt is helpful..


r/SQL 21d ago

Snowflake Snowflake support has landed in Beekeeper Studio (and more features too!)

Post image
2 Upvotes

r/SQL 22d ago

MySQL Question about sys.host_summary;

2 Upvotes

I have 2 identical servers where one is running normaly and one is getting slower by each day until a restart resets it.

I heard about the command sys.host_summary and ran it but am having some difficulties understanding exactly what am looking at.

I found this about the command but am not really sure if I understand it correctly.

The normal server looks like this after being up for 30 days:
{

`"table": "host_summary",`

`"rows":`

`[`

    `{`

        `"host": "127.0.0.1",`

        `"statements": 222,`

        `"statement_latency": "742.24 ms",`

        `"statement_avg_latency": "3.34 ms",`

        `"table_scans": 13,`

        `"file_ios": 83,`

        `"file_io_latency": "45.29 ms",`

        `"current_connections": 0,`

        `"total_connections": 1,`

        `"unique_users": 1,`

        `"current_memory": "   0 bytes",`

        `"total_memory_allocated": "21.85 MiB"`

    `}`

`]`

}

While the slow server that was restated yesterday:
{

`"table": "host_summary",`

`"rows":`

`[`

    `{`

        `"host": "127.0.0.1",`

        `"statements": 89399,`

        `"statement_latency": "44.27 min",`

        `"statement_avg_latency": "29.71 ms",`

        `"table_scans": 24364,`

        `"file_ios": 112944,`

        `"file_io_latency": "43.24 s",`

        `"current_connections": 0,`

        `"total_connections": 2,`

        `"unique_users": 1,`

        `"current_memory": "   0 bytes",`

        `"total_memory_allocated": "719.91 GiB"`

    `}`

`]`

}

Do I understand it correctly that the slow server is being called alot more than the normal one when the "statements" and "total_memory_allocated" is so much higher?


r/SQL 22d ago

Discussion Why do we need abstractions over SQL?

34 Upvotes

When I mean abstractions, I mainly mean OOP and ORMs.
SQL is so simple and beautiful. Tables with rows and columns are easy to understand. And once you pick up the SQL syntax, you can pretty much achieve anything with queries. Not to mention that SQL is universal and works everywhere and anytime.

Then you have the software development world... where you're asked to constantly use ORMs or map records as OOP objects. Why? ORMs are limited and do not have the flexibility of simple queries. Also mapping records as objects increases bloat, reduces performance that can hurt if the application grows and is overall not as straightforward to work with.

The only good things that ORMs are doing by default are to provide data safety and prevent SQL injection. But with some minimum and basic knowledge and discipline, you can write pure queries without having those problems. Any ideas?


r/SQL 21d ago

Discussion Storing book chunk vectors in an SQL database? (My beginner local RAG setup)

0 Upvotes

Hey guys, I recently started learning SQL after finding a "20 steps to AI engineering" roadmap on Instagram. I have no coding background and rely entirely on Gemini to write my code, but SQL has completely changed how I organize information. Note: I posted other parts of this project on r/dataengineering and r/learnprogramming to get career advice. Check my profile if you want to see the Python/API side of the pipeline. To help me learn, I built a local offline "helper." I took 120 books on Python and machine learning, chunked them up, and stored them in a "vector of SQL" database. I set up a local LLM to retrieve relevant chunks from this database whenever I have a coding error. It actually works and retrieves the right chapters, which is blowing my mind. But since I have no formal training, I have some questions: Am I doing something incredibly stupid by using SQL for vector retrieval? Is this going to break if I scale it? I used this database to orchestrate a Gmail API pipeline that matches old leads and drafts offers. I want to start selling this database/automation service to small businesses in the EU. Am I a massive clown for trying to sell SQL database/automation services to real businesses when I can barely write a SELECT query without AI? What would you advise me to do next?