Ideas to improve the user and developer experiences of databases
dnlhg.com
dnlhg.com
Raise your hand if you've committed the PostgreSQL to memory for looking at the DDL for a table, or identifying slow queries. Too many database management operations require highly specialized knowledge about a given database's internals.
Folks are far too willing to spend huge money on expensive licenses for db analytics tools to tell them when queries are slow or suboptimal.
Love the idea of making the db responsible for migrations. Downside there could be that db lock-in becomes a concern, and it might add cognitive overhead connecting application code to the current schema. How do you know if app code is up to date with the db without a live connection to prod?
The UX of 'damn I have to look that one weird query up again' to look up some metadata is not as good as it could be.
Lock-in is often mentioned as a downside to tech, but in my experience the budget never exists to change tech past a certain point anyways.
Honestly it always seems like an argument for better upfront planning, to me. Start out by assuming you're going to be locked-in to your choices forever, and make those choices with care.
But most programmers are using frameworks and ORMs and things that hide away what is actually happening with the database. A normal developer can look at a chunk of code on their side and have no real idea of what is happening on the database behind them.
What webdevelopers need is backend profiling information e.g. actual SQL queries and timings, shown beside all the frontend profiling information (e.g. in webdeveloper tools in the browser).
This profiling introspection can come from tooling in front of the database(s).
I recall seeing a blog about how the Stackoverflow team have nice tooling that does this for them. (Impossible to google for words like "stackoverflow profiling" and things!)
sure, inserts are slightly more inconvenient. but the clarity and performance control on reads unparalleled.
Something like: /* dbxperience:request=9a7cd2a6 */ SELECT ....
I have not tested it, but this is something google cloud sql recently promoted: https://cloud.google.com/blog/products/databases/get-ahead-o...
I use this in prod; it’s great. Expensive though.
https://www.datadoghq.com/blog/mysql-monitoring-with-datadog...
Datadog is tracing the request from the application akin to something like
openTrace("Query Name", queryStr)
db.Query(queryStr)
closeTrace()
The gap with that style of application-level tracing is that the database logs give no indication of where a query came from, hence the need for embedding a comment in the query with the trace ID.I would love for a better mechanism than SQL comments for distributed tracing all the way to the database.
What are you getting from the DB logs that you can't get elsewhere?
- Explain plans for slow queries, via auto_explain in Postgres. You could get really fancy here and convert the pieces of an explain plan (Aggregate, ModifyTable, FullTableScan) into proper distributed traces. Hard to tell, but it looks like GCP might offer that.
- Various errors logs associated with queries that require more detail than a SQL state code. For example, lock timeouts.
- Debugging, especially root cause analysis when you're trying to figure out why something broke. The trace IDs help build up context.
https://marketplace.visualstudio.com/items?itemName=apollogr...
Or suggest schema changes that would improve normalization or performance.
[link redacted]
The data to do this is built into Microsoft SQL Server, and the open source sp_BlitzIndex does exactly what you're asking for.
I thought it would be handy for those learning sql, but i dont think its a pro tool.
In anycase i am mainly posting this comment as it seems a simple thing to do but ive never seen another tool that does it.. maybe if i had taken the project a few steps further i would have found a reason its a terrible idea.
I lost interest in it though. I'm working some of the better things into a new project of mine, sqljoy.com (nothing there yet.) I've been developing it for over 8 months.
The closest thing right now is ArangoDB but it seems to swing too hard in the other direction (a boatload of features including a built-in web server).
My #1 feature request from PostgreSQL would be a way to branch the database easily with my git feature branches that is smarter than keeping N copies of everything and syncing them as needed.
* native partitioning
* something like Materialized (where it's easy to specify data that is derived or denormalized).
---
And on a different topic:
The Java SQL/database library, jOOQ [1] comes with a code generator that allows you to generate Java classes corresponding to your schema. This is pretty cool because it enables type-safe query building. It's a bit like connecting Java's type system to the database's type system. I find this to be really useful for ensuring correctness.
And if you're taking the approach from the first half of my comment, you can generate code any versions of the schema you need in the application.
[1] https://www.jooq.org/ jOOQ is really cool for a lot of reasons. The code generator is just one piece of it. For example, it can be used to translate between different vendors' dialects.
I also appreciate pgcli asking for confirmation when running a destructive command.
https://gist.github.com/colophonemes/9701b906c5be572a40a84b0...
I've been trying in vain to find something similar for MySQL. I think Lambdas are the killer feature that's missing from databases, you'd basically be able to handle all cache-invalidation / notification systems etc easily from the database layer, it would drastically simplify large numbers of common CRUD web-app problems.
It's only really useful for things that should happen, not for things that must happen.
It would be nice if I could run my mssql statements against sqllite for quick testing.
You don’t have to go deep before incompatibilities with ansi sql... top/limit statements.
>You don’t have to go deep before incompatibilities with ansi sql... top/limit statements. Neither TOP nor LIMIT are ANSI. We didn't get syntax in ANSI SQL for constraining rows until SQL 2008, with FETCH FIRST N ROWS. You could do it in SQL 2003 with window functions, but that was a bit wordy.
I want NextSQL to be about application development. Versioning, audit trailing, soft-deletes, privacy and data retention.
What I’d really like to see is how the combination of features could be more than the sum of its parts.
The ideas here are very good! But exist many other things that could have a greater impact:
1. We need an "wasm" for sql.
SQL is not a good language to transpile to.
ALL ORM ARE TRANSPILERS!
The relational model allow to do so much with so little (you don't even need to create a foreign procedural language if you add basic programming constructs). In FoxPro, you DB lang, your query lang and your programming lang was one and the same.
Much better.
Now today this could not fly -for some-, but a "wasm/llvm little" tailored to rdbms could be a very good idea.
Is exactly what things like GraphQL are, sadly, GraphQL is not made for DBs and is a hostile target for them.
1a: "But who will replace SQL, that is nuts!"
This is the major excuse. But things like graphql show is possible.
The "trick" is that this new query lang is SERVER SIDE. Developers will use it if is nice, and the major work is on libraries.
Solve this is not as hard as people think. In fact, is done MANY TIMES BEFORE!. But most not see it because not understand that what we are doing with SQL is making ad-hoc compilers.
And is done to JS with wasm. If is possible to do it for JS, sql is piece of cake.
2- We need Algebraic types: eliminate NULLS from their last bastion
Have algebraic types as first class will be a very good improvement here. No more null shenanigans, and will match what we know as today as best practiques.
Plus, will allow to fulfill better the ideal of a DB of "data modeling" of business requirements.
3- The auth support of RDBMS is for a bygone era.
The article show it, but the truth is that "nobody" use the auth support of rdbms outside some niches. A modern rdbms only need the equivalent of JWT and the ability to do custom auth checks. This will allow to actually plug the auth that is tailored to the app via:
4- We need "sql install simple-auth" aka: Package manager
As I said, I use fox pro. it was a full feature programming environment. This mean I have frameworks/libraries that I could distribute or integrate. A DB can benefit to install packages and declare its dependencies like with rust.
This could be great for example, to install a well vetted auth support for the db, or logging, or tracing, or extra functionality like fts.
And how about use wasm as the binary interface?
Is not the cost of string concatenation, is to provide the benefits of a good byte code that could allow, for example, type check input, schemas and other stuff on client side before touch the db. Is similar to how GraphQL unlock great tooling because is a specification that was designed for be a target of said tooling.