r/SQL • • May 08 '26

SQLite How far did you go with SQLITE

12 Upvotes

I would like some feedback about how far did you go with sqlite, like what you built -> how it went -> how do you optimize so I can have a better overview so what can be done (when It done properly) with sqlite


r/SQL • • May 08 '26

SQL Server Friday Feedback: SSMS settings part 2

Thumbnail reddit.com
1 Upvotes

r/SQL • • May 07 '26

PostgreSQL A VSCode-inspired, open-source UI for Postgres

19 Upvotes

r/SQL • • May 08 '26

PostgreSQL PostgreSQL query on 60M-row JSONB table is slow - should I add expression indexes or move to a structured table?

Thumbnail reddit.com
0 Upvotes

We have a silver_fec_efiling_itemizations table with 60M+ rows where each row stores the full FEC itemization record as JSONB in a record_data column. A typical query looks like this:

SELECT

record_data->>'contributor_first_name' AS first_name,

record_data->>'contributor_last_name' AS last_name,

record_data->>'contributor_state' AS state,

record_data->>'contributor_employer' AS employer,

(record_data->>'contribution_amount')::numeric AS amount,

LEFT(record_data->>'contribution_date',10)::date AS contribution_date

FROM silver_fec_efiling_itemizations

WHERE record_type = 'Schedule A'

AND record_data->>'entity_type' = 'IND'

AND record_data->>'contributor_state' = 'MD'

AND record_data->>'contributor_employer' ILIKE '%MICROSOFT%'

AND record_data->>'contribution_date' >= '2025-01-01'

AND record_data->>'contribution_date' < '2026-01-01'

record_type has a B-tree index but the rest of the filters are on JSONB extractions.

We do have a downstream structured table (fec_filing_lineitems) that promotes most of these fields into typed columns (entity_state, transaction_date, schedule_code, entity_type) -- except employer.

Questions:

  1. Is it worth adding expression indexes + a pg_trgm GIN index on the silver table, or is 60M JSONB rows fundamentally the wrong place for these queries regardless of indexing?
  2. Any general advice on indexing patterns for "mostly-JSONB" tables at this scale?

r/SQL • • May 07 '26

PostgreSQL PgStudio - PostgreSQL VS Code Extension with SQL Notebooks, AI Assistant, and Explorer

Thumbnail
gallery
5 Upvotes

I got tired of switching between VS Code and a separate DB tool. So I built PgStudio.

SQL notebooks with inline results and charts, real-time dashboard, AI assistant (Copilot / OpenAI / Anthropic / Gemini / Ollama — your pick), EXPLAIN CodeLens, visual table designer, production safety controls.

AI never executes anything automatically — every suggestion lands in a notebook cell first.

Free. MIT. One command: `code --install-extension ric-v.postgres-explorer`

Happy to onboard collaborators and feedback.

https://pgstudio.astrx.dev/

https://github.com/dev-asterix/pgStudio/


r/SQL • • May 07 '26

PostgreSQL PgStudio - PostgreSQL VS Code Extension with SQL Notebooks, AI Assistant, and Explorer

Thumbnail
pgstudio.astrx.dev
5 Upvotes

I got tired of switching between VS Code and a separate DB tool. So I built PgStudio.

SQL notebooks with inline results and charts, real-time dashboard, AI assistant (Copilot / OpenAI / Anthropic / Gemini / Ollama — your pick), EXPLAIN CodeLens, visual table designer, production safety controls.

AI never executes anything automatically — every suggestion lands in a notebook cell first.

Free. MIT. One command: `code --install-extension ric-v.postgres-explorer`

Happy to onboard collaborators and feedback.

[https://pgstudio.astrx.dev/](https://pgstudio.astrx.dev/)

[https://github.com/dev-asterix/pgStudio/](https://github.com/dev-asterix/pgStudio/)


r/SQL • • May 07 '26

MySQL How do you optimize SQL queries when working with millions of rows in production databases?

35 Upvotes

I’m curious about the practical techniques people use in real-world systems to improve query performance and reduce execution time on large datasets.


r/SQL • • May 07 '26

Oracle Weird optimizer/compiler behaviour on Oracle with JSON_TABLE?

3 Upvotes

TL;DR Adding JSON_TABLE makes the optimizer and compiler suddenly unable to think straight.

So I'm working as an intern rn and am writing a pretty complex script - distributing products between machines and their day and night queues, moving them away from overloaded machines, cutting portions of products between queues to make sure everything gets packaged, all while calculating delays for changing machine equipment depending on the sequence of projects.
I'm using a LOT of CTEs (yeah, I know) and the script runs in 40 to 80 seconds on the backup server (again, I know, but it's a script that only needs to be run once a day by one user and they're fine with it)
The problem is when I had to copy a CTE with a JSON_TABLE, the query suddenly takes so long it always times out on the system (over 5 minutes). This happens even if that CTE isn't referenced in the final SELECT or other CTEs,. Just the fact it's sitting there, no matter what table its taking the data from, even a fake view from DUAL, makes the process unable to finish in time.
Morever, in another part of the code I had a subquery within an LEFT OUTER JOIN ON statement, which is actually supposed to be illegal (not sure why, maybe I thought it would be faster even though it could be written with a WHERE). Still the compiler was fine, until I added the JSON_TABLE CTE, then it suddenly started to care about that too. The same happens if I use NESTED instead.

What could even be happening here? Is the presence of this function rewiring the compiler's logic completely?


r/SQL • • May 07 '26

SQL Server How find outlieers with TSQL

0 Upvotes

Hi all,
is there any way to integrate into my TSQL code logic to find statistical Outliers from list of numbers ? My list could contain very low number of observations within 5-10 range.

357066
339594
410763
98314913        --> Outlier
291277
4087            --> Outlier
981             --> Outlier 
31              --> Outlier

Thanks to all

r/SQL • • May 07 '26

MySQL ¿Cómo puedo hacer para optimizar un motor de búsqueda que está en php para que genere rápido los resultados que requiero?

Thumbnail reddit.com
0 Upvotes

r/SQL • • May 07 '26

SQL Server SQL2018 - variable date ranges

0 Upvotes

Hi - I need help with a variable date range formula. I need to capture data from Jun 1 of the previous year through May 31 of current year. The query needs to be able to run anytime through the year and needs to work in future years. So this year it would be 6/1/25 -5/31/26, but next year would be 6/1/26-5/31/27. I can't figure how without hardcoding the dates. I found a formula but it only works with earlier versions of sql. Can anyone assist?


r/SQL • • May 06 '26

MySQL Real-time SQL PVP. Same prompt, same data, fastest correct query wins.

51 Upvotes

Just shipped 1v1 PvP on a SQL game I've been building.

Both players see the same prompt and schema, race to write a query that returns the correct rows. Result sets are compared, so joins vs subqueries vs CTEs all work - speed is what matters.

Video is a real match. I'll be in the comments.

SQLProtocol.com


r/SQL • • May 06 '26

MySQL Help with HeidiSQL foreign keys

0 Upvotes

So I’m making an e-commerce site for school and I have a table named tbl_user with a primary key of “user_id”
This appears as a foreign key in tbl_basket but when I go to make the foreign key in tbl_order it says “SQL Error (1022) can’t write, duplicate key in table something”
Any help would be greatly appreciated


r/SQL • • May 06 '26

SQL Server AI SQL Tuner Studio 1.0.37 - new Locking & Blocking Analysis goal for SQL Server (10 evidence sections, sample report inside)

Thumbnail reddit.com
0 Upvotes

r/SQL • • May 05 '26

Snowflake Short visual Snowflake / SnowPro Core quiz videos — which topics are hardest?

Thumbnail
reddit.com
0 Upvotes

r/SQL • • May 05 '26

Discussion How are DE interviews these days? LeetCode + AI tools?

Thumbnail reddit.com
0 Upvotes

r/SQL • • May 05 '26

MySQL Forward filling of missing values through variables in MySQL

4 Upvotes

Hey folks!

While practicing MySQL last year, I came across the forward filling problem whereby you've to replace each NULL value in a column by the latest non-NULL value in that column.

For instance, a table ffill is as follows:

Table is 'ffill' with 6 records

The expected output is as below:

As we can see, the NULL values in dept column are forward filled. Here is the MySQL query I wrote back then to yield the output table above:

My question is, are there caveats of forward filling like this? What might they be? Will this way always work across the DBMSes? What would be the implications of this approach on large data sets?


r/SQL • • May 05 '26

Discussion Here's a quick SQL puzzle for learners

0 Upvotes

Given an input table tbl_puzzle, write a SQL query to produce the expected output table.

Note that in the tbl_puzzle, the column rule is of VARCHAR type.

What's to be done: If a rule value is 2+3, add the val for id 2 & 3 to yield 26 in column ans of expected output.


r/SQL • • May 03 '26

SQL Server In my ETL pipeline I used a Merge statement. When I asked Copilot to critique the pipeline it said Merge statements were not recommended by Microsoft. Why is this?

29 Upvotes

One of the critiques of the pipeline was the fact that I used Merge…instead of Insert and Update. I was wondering if anybody else ran into the same situation? Or knew why? I find that Merge TSQL statements are very easy to read and setup if I wanted to Insert then Update which basically does the same thing I would have written it that way. Is there some sort of memory buffer or leak or rowcount limitation when using Merge? Just trying to find out why Copilot stated this. (Should’ve thrown in upsert logic of update then insert!) (thanks to the users who pointed me in the right direction) (if it were me I wouldn’t ship something so buggy)


r/SQL • • May 04 '26

Discussion Bench: 17.3.x ValentinaDB vs DuckDB: SEARCH 2-27x faster

0 Upvotes

Hi all,

Let me share some information.

About two years ago, we were asked to add DuckDB support to Valentina Studio. As we explored this database, we realized that from an architectural perspective it is similar to Valentina DB and SQLite — a local embedded database engine. At the same time, like Valentina DB, DuckDB is column-oriented.

This observation led us to the idea of integrating DuckDB into Valentina Server as well. We implemented this integration approximately 1.5 years ago by adding DuckDB under our VKERNEL DLL layer, similar to what we had previously done with SQLite.

For a long time, we were focused on other priorities. However, we were naturally interested in benchmarking Valentina DB against DuckDB. In March, we started developing a benchmark suite using Google Benchmark.

During this work, we also introduced SIMD vectorization into Valentina DB, which significantly improved performance.

Below are the results for WHERE queries. These results are from approximately three weeks ago.

Benchmarks were executed on MacBook Arm M1, tables with 100K, 1M, and 10M records. Tests include both full table scans and filtered selections:

  • Small: ~10 records
  • Half: ~0.5N records
  • Large: ~N − 10 records

It is interesting to note that Valentina outperforms DuckDB in both indexed and non-indexed search scenarios.


r/SQL • • May 04 '26

PostgreSQL OLAP Server

0 Upvotes

Is there a free version of an OLAP server like SQL Server? Or is there a way to manage something similar, obviously requiring online data management, nothing local. I don't need scalability as it's for an academic project.


r/SQL • • May 02 '26

Discussion SQL developer Project ideas

15 Upvotes

Hi, so I want some ideas for SQL Developer. There is a job posting for SQL Developer Trainee and here is the description of job listing: Job Summary We are looking for a motivated SQL Developer Trainee to join our dynamic IT team. In this role, you will work under the guidance of experienced database professionals to learn and apply SQL development best practices, support database management, and contribute to data-driven solutions for our business needs.

Key Responsibilities: Learning & Development: Gain hands-on experience with relational database management systems (e.g., MS SQL Server, MySQL, Oracle). Learn to write, test, and optimize SQL queries for data retrieval and manipulation. Database Support: Assist in creating, maintaining, and troubleshooting database objects such as tables, views, stored procedures, and functions. Support database administrators and developers in routine maintenance and backup operations. Data Analysis & Reporting: Help develop simple reports and dashboards using SQL and reporting tools. Participate in data validation and quality checks. Collaboration: Work closely with developers, analysts, and other team members to understand business requirements. Participate in team meetings and contribute to project discussions. Documentation: Assist in documenting database schemas, processes, and best practices. Continuous Improvement: Stay updated with emerging database technologies and trends. Participate in training sessions and workshops to enhance technical skills.

Qualifications & Skills Education: Pursuing or recently completed a degree in Computer Science, Information Technology, or a related field. Technical Skills: Basic understanding of SQL and relational database concepts. Familiarity with at least one database management system (MS SQL Server, MySQL, Oracle, or similar). Willingness to learn new technologies and tools. Soft Skills:

Strong analytical and problem-solving abilities. Good communication and teamwork skills. Eagerness to learn and adapt in a fast-paced IT environment. Attention to detail and commitment to data accuracy. Experience: 0-1 years

So I want to make one or two projects which can make my chance of getting this job high.


r/SQL • • May 02 '26

SQLite What version of SQLite looks like this ?

0 Upvotes

This is a version of SQLite we used with our teacher on the school's computers. I'm trying to get it on my laptop now, but I can't find anything like this. Obviously I know it's not that big of a difference but I'd like to keep the same thing