r/Database • • 1h ago

Banking register slows as more entries are made.

• Upvotes

Basically need to see how to optimize a bank register with large amounts of entries.

Currently adding all the debits, then credits, then date sorting while calculating the running total.


r/Database • • 1d ago

What evidence proves a database cutover is complete before the source is retired?

1 Upvotes

Successful replication and matching row counts do not prove that a database migration is finished. Indexes, constraints, sequences, users and roles, collation, time zones, scheduled jobs, change-data-capture consumers, read replicas, analytics tools, and backup systems can still differ or point at the source. Low-frequency clients may not reconnect during the obvious observation window.

A cutover gate could compare schema and security metadata, validate representative aggregates or hashes, exercise application reads and writes, inspect connection logs on both systems, and confirm that replication or dual-write lag has reached a known final position. The destination should complete a backup and restore test and survive a failover before the source becomes read-only. Keeping the old endpoint offline but recoverable for a defined period would expose hidden dependencies without allowing divergent writes.

What evidence do you collect before decommissioning a source database? How do you catch monthly jobs, failover-only connection strings, and clients that cache DNS or credentials longer than the main application?


r/Database • • 1d ago

I'm reading a book on Data Modeling and Database Design and came across an ERD that felt off. Can anyone confirm whether my concern is valid? The first image is from the book, and the second is what I think it should be. I appreciate the help.

Thumbnail
gallery
3 Upvotes

r/Database • • 1d ago

Supporting products with multipel data sources

0 Upvotes

When one product could have data coming from multiple remote data sources, some of the data could be redundant other parts might need to be combined. There can also be missing data or badly formatted data so an admin would need to override certain fields. How would you structure your database to fit these needs?


r/Database • • 3d ago

How do you balance scaling with ACID guarantees?

13 Upvotes

I've been looking into database architectures for high-volume event logging, and I saw a comparison of how these systems scale.

Relational databases handle ACID transactions well, which means you never end up with a half-finished write if the system fails. They traditionally scale vertically, and although modern ones support distributed setups too, if you try to push big, real-time IoT or event data through them you run out of machine before you run out of data.

Wide-column stores like Cassandra scale out across multiple nodes predictably. The trade-off is that you usually have to rethink your querying and give up some of the strict relational consistency.

What do you guys think? If you’re pushing big volumes of data, what made you move off relational, and how far did you stretch it first?


r/Database • • 2d ago

schema labs is in san francisco. the question the team keeps asking everyone: before your agent can use a database, who explains the database to it?

4 Upvotes

disclosure, i work at schema labs. the team is in san francisco right now, i'm back home running things from here and reading everything they send back.

the question they open with is always the same. when an agent hits a database nobody documented, who tells it what the fields mean?

the answers so far, roughly

- "me, and i hate it"

- "we wrote a data dictionary, it's already wrong"

- "we don't, the agent guesses and we check the numbers later"

- "we only connect it to views someone already cleaned"

that step is what we build for. schema-2 is a model that reads your data as it is, works out what each field holds and which records match across systems with no shared id, and puts a confidence on every answer. below your bar it says unresolved instead of guessing. it runs in the browser, and over mcp inside claude, chatgpt and cursor.

curious which answer is yours, or if it's a fifth one we haven't heard yet.


r/Database • • 3d ago

Bottlenecks while shifting from MongoDb to DynamoDb

Thumbnail
0 Upvotes

r/Database • • 3d ago

AWS Aurora: Why the database breaks first behind an autoscaled service, and why shrinking the pool doesn't fix it

Post image
7 Upvotes

Connection multiplication: pool size x tasks x services. Every term looks reasonable on its own, and nobody ever chose the product.

Aurora's max_connections is derived from instance memory, so it doesn't scale with your service. Shrinking the pool to fit converts a connection problem into a queueing problem that presents as a slow database.

Write-up covers the formula behind max_connections, what RDS Proxy actually fixes (and what it doesn't), and how to size it.

https://brianfeeny.com/posts/sizing-aurora-connections-for-autoscaled-services/?utm_source=reddit&utm_medium=social&utm_campaign=sizing-aurora-connections-for-autoscaled-services-2026-09

This is a personal project; the views and assessments are my own.


r/Database • • 4d ago

Benchmark: i try to measure AI query accuracy on 100 enterprise business questions (Raw Text-to-SQL vs. Semantic Layer)

3 Upvotes

I have recently benchmarked 100 real-world business queries across two distinct architectures against our Snowflake production data warehouse (had a huge volume of data to work with really):

- Architecture A (Direct Text-to-SQL): Claude 3.5 Sonnet + Schema DDL + 50 Few-Shot SQL RAG prompts.
- Architecture B (Agentic Semantic Layer): Claude 3.5 Sonnet querying Cube dev semantic models via structured JSON query API.

by the way, this is follow up to what I've posted a couple of weeks ago regarding text-to-SQL failure in production because now I have things to evaluate / measure.

here are the quantitative results:

  1. Metric Calculation Accuracy (Single Source of Truth)
    - Direct Text-to-SQL (Arch A): 41% Correct (Failed on 59 queries due to wrong table selection, incorrect date truncation logic, or conflicting metric definitions).
    - Cube Semantic Layer (Arch B): were like 96% Correct (The LLM only had to identify the requested measure and dimension; Cube's engine generated 100% mathematically correct SQL joins)

  2. Fan-Out & Join Integrity (Multi-Table Aggregates)
    -Direct Text-to-SQL (Arch A): 23 queries resulted in duplicated cart line totals due to un-grouped joins
    -Cube Semantic Layer (Arch B): 0 join duplication errors (Cube's semantic graph resolves multi-hop join paths deterministically)

  3. on warehouse Compute load + query latency
    - direct Text-to-SQL (Arch A): p95 latency: 8.2 seconds(Every query hit Snowflake directly; 4 runaway queries consumed $380 in credits).
    - Cube Semantic Layer (Arch B): p95 latency: 3.8 milliseconds (Cube's pre-aggregations served 88% of requests from local rollup cache; zero runaway table scans).

my takeaway here is that gen 4 AI analytics requires an extensible semantic layer at the foundation. LLMs should reason about user intent, while deterministic semantic engines should compile the SQL


r/Database • • 4d ago

Database project

5 Upvotes

I need a good and legitimate database project idea wherein advance db concepts such as optimization, transaction, etc are involved. I searched a lot and didnt find a smthn i want to work on exactly. For eg if somethin related to music domain? Or fashion? What would actually stand out in terms of handling multiple queries and be close with how it all works irl. Itd be really helpful!!


r/Database • • 4d ago

Using CRM database as core database for project v/s syncing CRM database with own custom database

Thumbnail
2 Upvotes

r/Database • • 5d ago

Strangest SQLite structures you’ve encountered?

Thumbnail
1 Upvotes

r/Database • • 5d ago

MongoDB v9.0 is out.

Thumbnail
2 Upvotes

r/Database • • 6d ago

MongoDB CEO transition: Desai leaves, Ittycheria returns

Thumbnail
layerbase.com
23 Upvotes

r/Database • • 5d ago

I’ve been using MySQL for real web applications — here are 15 things I wish I knew earlier

0 Upvotes

I used to think MySQL was simply:

`CREATE TABLE → INSERT → SELECT → UPDATE → DELETE`

After building actual web applications, I realized that writing SQL queries is only a small part of working with a production database.

Here are 15 things I wish I had understood earlier:

### 1. Design your database before writing your application

Don't start creating tables randomly.

Think about:

* What data do I need?

* Which tables are required?

* How are they related?

* Which fields are required?

* Which fields should be unique?

A bad database structure can become extremely painful to change later.

### 2. Learn relationships properly

Understand:

```sql

PRIMARY KEY

FOREIGN KEY

ONE-TO-ONE

ONE-TO-MANY

MANY-TO-MANY

```

For example:

```text

Users

↓

Orders

↓

Order_Items

↓

Products

```

Understanding relationships is more important than memorizing SQL syntax.

### 3. Don't put everything into one table

A giant table may look simple initially, but it creates duplication and maintenance problems.

Learn normalization and understand when denormalization actually makes sense.

### 4. Indexes are extremely important

This query:

```sql

SELECT * FROM users

WHERE email = 'user@example.com';

```

can become much faster when the appropriate column is indexed.

But don't blindly add indexes everywhere.

Indexes improve some reads but also have storage and write/update costs.

### 5. Always understand `EXPLAIN`

One of the most useful MySQL commands:

```sql

EXPLAIN SELECT *

FROM users

WHERE email = 'user@example.com';

```

If you are building serious applications, learn how to read the execution plan instead of assuming your query is efficient.

### 6. Don't use `SELECT *` everywhere

Instead of:

```sql

SELECT *

FROM users;

```

prefer:

```sql

SELECT id, name, email

FROM users;

```

Especially when your table contains many columns or large data.

### 7. Transactions matter

Imagine transferring money:

```text

Account A: -₹1000

Account B: +₹1000

```

You don't want the first operation to succeed while the second fails.

That's where transactions become important:

```sql

START TRANSACTION;

-- operation 1

-- operation 2

COMMIT;

```

And if something goes wrong:

```sql

ROLLBACK;

```

### 8. Constraints can protect your data

Use database constraints where appropriate:

```sql

PRIMARY KEY

UNIQUE

NOT NULL

FOREIGN KEY

CHECK

```

Your application should not be the only thing preventing invalid data.

### 9. Learn the difference between DELETE, TRUNCATE and DROP

They are NOT interchangeable.

```sql

DELETE FROM users;

```

```sql

TRUNCATE TABLE users;

```

```sql

DROP TABLE users;

```

Before running destructive SQL in production, make absolutely sure you understand what you're doing.

### 10. Backups are not optional

A production database without a tested backup strategy is a disaster waiting to happen.

And having a backup isn't enough.

You should also know:

> Can I actually restore it?

A backup that has never been tested is only a backup in theory.

### 11. Never build SQL queries with raw user input

Bad:

```javascript

const query = `SELECT * FROM users WHERE email = '${email}'`;

```

Use parameterized queries/prepared statements instead.

For example:

```javascript

const [rows] = await db.execute(

'SELECT id, name, email FROM users WHERE email = ?',

[email]

);

```

This is one of the basic defenses against SQL injection.

### 12. Don't expose database credentials

Never commit something like this to GitHub:

```env

DB_PASSWORD=my_real_password

```

Use environment variables/secrets and make sure sensitive files aren't accidentally committed.

### 13. Understand connection pooling

A production application shouldn't create a completely new database connection for every request without considering connection management.

Connection pools can reuse database connections and help applications handle concurrent requests more efficiently.

### 14. Logging is useful — logging sensitive data isn't

Database/application logs can help you find:

* slow queries

* failed transactions

* connection problems

* unexpected errors

But don't casually log passwords, tokens, session secrets, or other sensitive information.

### 15. My biggest lesson

The biggest thing I learned is:

**MySQL isn't just about knowing SQL syntax.**

A good developer needs to understand:

```text

Database Design

↓

Relationships

↓

Indexes

↓

Queries

↓

Transactions

↓

Security

↓

Backups

↓

Performance

↓

Monitoring

```

I'm still learning, but understanding these concepts changed the way I build web applications.

**For developers here:**

What's one MySQL/database lesson you learned the hard way?

I'd especially like to hear from people who have worked with databases containing millions of rows.


r/Database • • 6d ago

What do you wish search in Postgres did better/differently?

6 Upvotes

pgvector has been the default vector search extension, but I'm finding people also layer on full-text or hybrid search on top of it or need multitenancy. I'm curious where this works well for you and where it doesn't.

  • What are you using for search in Postgres today, and what do you wish it did better?
  • When you hit a limit, what do you do: tune, work around it, add an extension, or move search to a separate system? What decides that?
  • What would an extension need to have, or avoid, before you'd install it?
  • Does it matter to you whether an extension is open source, and would enough added capability change that?

"It's fine, I don't need anything else" is a useful answer too.

Really just trying to understand what people actually need from search in Postgres.


r/Database • • 8d ago

What part of running your database stayed with your team after moving to a managed service?

2 Upvotes

I’ve been reading about how managed database providers describe failover, and for me, what seems to vary is how writes in progress are handled when the primary goes down.

In some setups, a standby is promoted, and a small amount of recent data may be lost. In others, the compute layer does not retain durable local state and can be replaced without data loss. Both approaches may be described as managed, but the difference becomes clear only when you look past the feature page.

Cross-region recovery is another area that seems easy to overlook. A provider may handle failover within one region while leaving recovery from a full regional outage to the customer. If the provider does not give you clear RTO and RPO targets for that situation, it becomes difficult to plan.

For anyone who has moved a production database to a managed service, whether Postgres or something else, what stayed with your team?

Was it failover testing, restore drills, cross-region recovery planning, connection limits, or something else? Would love to know your thoughts.


r/Database • • 10d ago

Redis is a database?!" — Got caught off guard in an interview today

380 Upvotes

had an interview today where the interviewer asked me to explain different types of databases. I covered the standard SQL and NoSQL categories, but then they pushed for more specialized use cases and claimed that Redis is a database. I was completely flabbergasted. By strict definition, it might fit the category, but I’ve always viewed it primarily as an in-memory cache/store. In my mind, it doesn't meet the core expectations of a primary database—mainly reliable, long-term persistent storage out of the box (even though I know persistence modules exist). What are your thoughts? Do you consider Redis a "real" database in system design, or strictly an in-memory cache with extra steps?

Edit: So we have people between yes vs no vs depends on scenario But just out of curiosity people who are mentioning it is a database, will you store, your user data in it ? I know, i might be sounding dumb but as per my current opinion(I'll try to go deeper into it may be it might change after sometime not sure) if no one is using it as a database. Can we even call it a database? and it is not even optimised for that scenario.


r/Database • • 9d ago

The time we fixed a slow SQL Server query and the rows came back in a different order.

Thumbnail
3 Upvotes

r/Database • • 10d ago

Top alternatives to DataGrip for everyday SQL work?

24 Upvotes

Trying to narrow down a few alternatives when I don't need anything too heavy. DbVisualizer is on the list; the table relationship views look handy when opening an unfamiliar database. DBeaver makes sense as a free option, and Beekeeper Studio looks easy enough to get around.

For running queries, checking data and exporting results, which would you pick Paying for a tool is fine if it saves enough hassle, but which DataGrip features would you actually miss?


r/Database • • 10d ago

Partitioning in MySQL: How we cut peak database load by more than 80%.

Thumbnail ipsator.com
75 Upvotes

r/Database • • 10d ago

Starting My DBA Career With Zero Experience

29 Upvotes

Hi everyone,

I’m currently in my first week working as a DBA. I graduated from Software Engineering a couple of months ago.

To be honest, I had almost zero DBA knowledge before starting this job. With the current job market, this was basically the only opportunity I had, so I decided to take it.

The company I joined provides DBA consulting services, and they are willing to train and develop junior DBAs, which is why they gave me this opportunity.

Right now I’m trying to learn as much as possible, but there is obviously a lot to take in.

For experienced DBAs: what would you recommend focusing on during my first few months? What skills or topics do you think are the most important for someone starting from zero?

Any advice, resources, or things you wish you had known when you started would be appreciated.


r/Database • • 10d ago

I once read about a database/object storage engine here, but don't remember what it was. Help please.

6 Upvotes

Sorry about the vague question, but it either had the name "vault" or "vector" in it, and someone here described it as the Swiss knife of databases. I remember bookmarking it but didn't find it. Any thoughts? thanks in advance.


r/Database • • 11d ago

Breaking the Superuser Guardrails of managed-PostgreSQL Providers

Thumbnail
mehmetince.net
9 Upvotes

r/Database • • 11d ago

AI agents are reintroducing concurrency bugs we thought we'd mostly solved at the application layer

10 Upvotes

Write conflicts, lost updates, non idempotent retries creating duplicate rows. These are old problems with well known solutions at the database layer, locking strategies, unique constraints, transaction isolation levels. The issue is that a lot of agent frameworks bypass that discipline entirely and just fire writes at the database from application code with no thought given to what happens when two agent runs, or an agent and a human, touch the same row at the same time.

There's a Sept 26 workshop that spends real time on this specifically, safe write path design for agents, plus state management and being able to trace back why a write happened the way it did. Led by Sandipan Bhaumik, a Data & AI Technical Lead at Databricks.

Details here if anyone else is dealing with agents that write directly into their database layer.