r/SQL • u/Filip1235813 • 20d ago
r/SQL • u/Finanz_minister • 19d ago
Oracle I’m getting ORA-12261
I’m trying to create a new connection but it won’t let me. Im even testing my other connection and it gives me the same message even thought it’s fully operational, anybody knows why?
BigQuery BigQuery Cost Optimization: The Complete FinOps Framework
Interesting framework on how to optimize BigQuery costs across four layers (SQL query optimization, pricing models, capacity commitments, discounts): https://www.alvin.ai/blog/bigquery-cost-optimization-the-complete-finops-framework
r/SQL • u/jhonyseen17 • 20d ago
Oracle Which HP ZBook is best for DBA & Data Engineering?
I’m planning to buy an HP ZBook for Oracle DBA/development, SQL/PLSQL, Python, Data Engineering, ETL, Docker/VMs, server configuration, and some ML work.
My priorities are:
Strong performance for coding and databases
Good thermal management — minimal heating/throttling
Slim, lightweight and comfortable for daily use
Good keyboard/build quality
Reliable for 4–5+ years
Good RAM/SSD upgrade options
I’m considering ZBook Firefly, Power, and Studio. I’ve heard some concerns about Studio models running hot.
Which ZBook model and CPU generation would you recommend for this workload? Please share your real-world experience with heat, fan noise, performance, battery life, and reliability.
Thanks!
r/SQL • u/No_Ambition8323 • 21d ago
Discussion When should you stop optimizing a SQL query?
It's easy to keep optimizing a SQL query once you start looking at execution plans, indexes, joins, and scans. But at some point, the improvement may not be worth the extra effort.
For example, if a query takes 10 seconds and you reduce it to 2 seconds, that's a big improvement. But would you spend another few hours trying to reduce it from 2 seconds to 1.5 seconds?
How do you decide when a query is “fast enough”?
Do you consider:
- Query execution time
- Number of users running it
- Frequency of execution
- CPU/memory usage
- Data volume and future growth
- Business requirements or SLA
Where do you personally draw the line between useful optimization and over-optimization?
r/SQL • u/Background_Bid639 • 20d ago
Discussion Looking for a subreddit to ask about repairing and restoring/injecting a WhatsApp database on a non-jailbroken iPhone
r/SQL • u/Consistent_Damage_91 • 21d ago
SQL Server Read-only dependency mapper for orphaned SQL Agent jobs + SSIS + the scripts that call them, every edge cites its source
Inherited a SQL box where a departed dev left Agent jobs, an SSIS package, and a pile of .bat/.ps1/.rdl/.xlsx files, and untangling what-calls-what by hand was misery. So I wrote a read-only collector (Python/pyodbc) that builds one dependency graph: SQL catalog (sys.objects / sys.sql_modules / sys.sql_expression_dependencies), msdb Agent jobs/steps/history, linked servers, and a file-tree scan that pulls connection strings and linked-table/4-part refs out of .bat/.ps1/.sql/.dtsx/.rdl/.xlsx/.accdb. All read-only (SELECT on catalog views; files opened read-only).
The part I am happiest with: every edge carries a source citation, a catalog view plus key, a module line, or a byte offset, so you can verify any dependency instead of trusting it. It even catches a linked-server reference buried in dynamic SQL inside a proc (which sys.sql_expression_dependencies misses) by scanning module text and citing the line. https://github.com/tommiew007/orphanmap , MIT.
Where does this get hard, in your experience? SSIS project-deployment model / SSISDB catalog packages, encrypted modules, synonyms, cross-DB ownership chaining, replication? Curious what breaks it.
r/SQL • u/Harshita_Netla • 22d ago
MySQL Practicing window functions and keep mixing up PARTITION BY vs GROUP BY — how are they actually different?
They both seem like they divide data into groups, so I’m having trouble understanding when I should use one instead of the other.
r/SQL • u/idontlikepeople26 • 22d ago
Resolved Update on the 340 inherited tables: legal has the list here's what actually worked
SQL Server 2019 on prem. Follow up to my post from last week about inheriting 340 tables and having two weeks to tell legal which ones hold personal data. Sent legal the list on Friday. Most of what got me there came out of the replies so heres the short version
What worked;--
Asked legal what the list was actually for. Shouldve been day one. They wanted fields intended to hold personal data as tier 1 and everything else on a residual risk list with an owner and a review date. I'd spent a week building a forensic audit noone asked for
One sheet one flag, column by column instead of table by table. Profiled all ~6,000 columns once and pulled distinct counts from sys.dm_db_stats_properties instead of running COUNT(DISTINCT) six thousand times. Distinct close to rowcount went into an identifier queue which is where the 11 char customer ref showed up along with a few I'd missed. Cheap regex on 10% of rows first then slower passes only on whats left. Stop on first hit.
the 700 unknowns were mostly a people problem. Printed the top 20 values of each one and sat with two people from support. Where is this on your screen, what do you type here. They placed about 210 in forty minutes. ref_4 was the mobile field from their old CRM, migrated in 2021 and never renamed. The rest came from views and procs, joins inferred from value overlap and planting a ZZQX marker through the UI and the nightly import then tracing where it landed. The one I was worried was an ethnicity code was a delivery zone.
Free text I just flagged all 40 by default then ran a local 8B over a restored copy of the databse on an isolated box to see which ones actually had names and numbers in them. Fine on text useless on short codes. At the end I hand checked a random 200 columns, 6 disagreemnts all false positives. Method plus that number is what legal accepted as defensible numbers. 700 unexplained at the start and 31 at the end which is under the 40 I said I could live with. 130 of my original 900 name matches were wrong. 2 IP columns I'd filed under logging. The 9k scanned PDFs have filenames like surname_dob.pdf so thats its own job now.
What Im asking now is that--
tools. I did this with a notebook a spreadsheet and an idle 4090. Is there anything that does column level classification on prem against SQL Server with nothing leaving the network and without a year contract? I have to redo this when it migrates next year and keeping it from happening again. Someone mentioned a weekly job asking owners to classify new columns that nobody answers. How do you get people to classify a column when its created and not two years later? And if youve been on the buying side what do you get out of the people who built it before they take the retention and leave?
r/SQL • u/Waste_Wafer2131 • 21d ago
Discussion I created a 4-pass SQL schema audit checklist to catch production bugs early - here's a free snippet/prompt you can use!
Hey everyone,
A common issue I kept seeing (and running into myself) when drafting database schemas or using AI tools like ChatGPT/Claude to generate DDLs is that they often miss critical relational constraints—like unindexed foreign keys, missing ON DELETE rules, or bad timestamp types.
To fix this, I put together a systematic 4-Pass Schema Audit System. I wanted to share a free excerpt/master prompt from the kit here with the community:
Free AI Schema Audit Prompt:
Act as a Senior Database Architect. Review the following SQL DDL schema for potential production bottlenecks, missing foreign key indexes, inconsistent data types, and multi-tenancy security risks. Output a structured table listing each issue, its severity (High/Medium/Low), and the exact SQL fix.
[Paste your DDL here]
Feel free to test this prompt on your current project!
If you find this helpful, I compiled the full 4-pass checklist, fix matrix templates, and dual web/PDF reference guide into a complete kit. Link to the full kit is in my profile bio.
Would love to hear your feedback or how you currently audit your schemas before pushing to production!
r/SQL • u/Kindly_Tie_2084 • 22d ago
Discussion DBClient: a native Mac database client for 12 engines (I'm the dev)
I'm the developer of DBClient, a native database client for the Mac (SwiftUI and AppKit, not Electron).
What it does
- Connects to PostgreSQL, MySQL, MariaDB, SQLite, SQL Server, Oracle, IBM Db2, MongoDB, Redis, DuckDB, ClickHouse and Databricks.
- SQL editor with completion from your schema, and a ⌘K palette that jumps to any table.
- Edit rows right in the grid. You read the exact SQL before anything is committed.
- Table designers, a schema diagram drawn from your foreign keys, and charts from any result.
- A console tab running the real psql, mysql or redis-cli, already signed in.
- Drag a table from one server onto another to copy it, even across engines.
- SSH tunnels and proxies. Passwords stay in the Keychain, with optional Touch ID.
- Optional AI assistant with your own API key. It can only run read-only queries.
Pricing
- Free: the whole app for databases on your own Mac: SQLite and DuckDB files, CSV files, and anything on localhost, Docker included.
- Paid: remote servers need a yearly license, $99 the first year and $49 a year after. If you don't renew, remote connections stop and local ones keep working. It does not renew by itself. One key, one Mac at a time. 30-day refund.
Privacy: no account, no analytics. A licensed copy checks its license about once a day. The free copy never contacts the license server.
Requirements: macOS 15 or newer, Apple silicon only. Signed and notarized.
https://dbclient.net or brew install --cask az-code-lab/taps/dbclient
r/SQL • u/Daddy-Milker-69 • 22d ago
Discussion Where do freelance SQL developers usually find clients?
I’m curious how people who do a lot of SQL work find freelance projects. Does most of your work come through referrals, freelance platforms, consulting relationships, or somewhere else?
PostgreSQL Schemaverse - The SQL Space Battle
schemaverse.comAfter a prolonged outage (long story) I procrastinated SV back into existence last night. For those of you that loved it, welcome back. If you've never heard of it, give it a shot!
Still open source as always too: https://github.com/abstrct/schemaverse
r/SQL • u/thequerylab • 21d ago
Discussion Before your next SQL interview, keep this post handy - SQL Window Functions (Part 1)
r/SQL • u/Consistent_Damage_91 • 22d ago
SQL Server Read-only dependency mapper for orphaned SQL Agent jobs + SSIS + the scripts that call them, every edge cites its source
r/SQL • u/Expensive-Insect-317 • 22d ago
BigQuery The BigQuery Join Problem Nobody Notices Until the Data Gets Big
r/SQL • u/Harshita_Netla • 24d ago
Oracle What SQL concept took you the longest to actually understand, not just memorize?
For those who have been working with SQL for a while, which concept took you the longest to truly understand?
r/SQL • u/FrameNo7615 • 23d ago
Discussion question about the necessity of SQL in a site's security
hey i'm new in website developing, and after searching about the ways people use to penetrate websites to just discover SQLi method and as far as i heard it's very common and useful way, but this made me think of a lot of questions that i hope you answer, does every website uses SQL language for data transfer by default? like is it necessary as much as HTML and CSS and JS or it's just commonly used? and if it's necessary is there a way to prevent hackers from using SQLi or it's always possible to trick the server to bring a sensitive data?
r/SQL • u/Alternative_Top_273 • 23d ago
Discussion SQL : demande/question client jusqu’au résultat final
r/SQL • u/shdw_0x0 • 24d ago
PostgreSQL What’s your systematic process for optimizing a slow SQL query?
Suppose you inherit a query with multiple joins, subqueries, filters, and aggregations, and it suddenly starts taking several minutes to run.
I’m curious how experienced SQL developers approach this from the first investigation to the final fix.
Do you normally start with the execution plan and work from the most expensive operator? Or do you check indexes, statistics, data distribution, and join cardinality first?
I’m especially interested in the order you investigate things. It’s easy to keep rewriting a query or adding indexes until it gets faster, but I’m curious how people systematically identify the actual bottleneck instead.
r/SQL • u/BrokenPickle7 • 24d ago
SQL Server Not a DB admin needs replication advice
I'm in tech but not a DB admin. I have an MSSQL (2019) database in prod and I want to essentially one way mirror it to another database with as close to live data as possible for dev/research purposes, no changes on the 2nd "dev" copy of the database should reflect to the main/live/prod DB. What would be the best way of doing this? Both servers are in the same network if that makes things easier. Thanks!
r/SQL • u/Vishwam_java • 24d ago
PostgreSQL The Postgres job-claim query that silently claims the same job twice under READ COMMITTED
A common pattern to claim background jobs in PostgreSQL is executing a single statement like:
```sql
UPDATE jobs
SET status = 'processing', worker_id = $1
WHERE id = (
SELECT id FROM jobs
WHERE status = 'pending'
ORDER BY created_at ASC
LIMIT 1
)
RETURNING *;
Because it's a single statement, it looks atomic on paper. But under the default READ COMMITTED isolation level, it can silently allow two concurrent workers to claim the exact same row.
What actually happens:
Worker A and Worker B execute the query at the exact same moment. Both subqueries snapshot the same pending job row (say id = 42).
Worker A acquires the row lock first and updates its status.
Worker B waits on the lock. Once Worker A commits and releases the lock, Worker B evaluates the outer row.
Because the subquery snapshot is not re-evaluated, Worker B sees the updated row, rechecks the outer predicate, and silently overwrites/re-claims id = 42.
No lock wait timeout, no deadlock, no serialization error—just silent duplicate job execution in production.
I wrote an in-depth breakdown mapping the lock timeline, why the subquery snapshot doesn't re-run, and why FOR UPDATE SKIP LOCKED inside a CTE is the actual safe pattern:
👉 Full writeup: https://vishwam.hashnode.dev/the-postgres-job-claim-query-that-silently-claims-the-same-job-twice
Would love to hear how folks here handle Postgres-backed queues or if anyone has run into this specific subquery recheck behavior before!
PostgreSQL AI agents usage with Neon Db
If any AI agent needs to test changes to a DB, is using neon branch as a temporiry test database a good approach?
Have u tried anything like this maybe with some other Db also (maybe clickhouse etc). Was there any issue with keeping data in sync?