Pinned Tweet
Layerbase is where high velocity developers and their agents get cheap, reliable databases
layerbase.com
clickhouse lets you stick If on the end of any aggregate. one scan, several filtered numbers
SELECT count() AS total,
countIf(status = 'error') AS errors,
avgIf(ms, status = 'ok') AS ok_ms
FROM requests
works with sum, uniq, quantile, all of them
layerbase.com/db/clickhouse
want one field in a valkey hash to expire without killing the whole key? 9.0+ can do that
HSET session:42 user bob csrf abc123
HEXPIRE session:42 600 FIELDS 1 csrf
csrf disappears in 10 min, user stays. HTTL shows what's left
layerbase.com/db/valkey
using a mysql table as a job queue? add SKIP LOCKED so workers stop waiting on each other
START TRANSACTION;
SELECT id FROM jobs
WHERE status = 'queued'
ORDER BY id LIMIT 1
FOR UPDATE SKIP LOCKED;
each worker grabs a different row. 8.0+
layerbase.com/db/mysql
sqlite will happily store 'abc' in an INTEGER column. add STRICT and it errors instead
CREATE TABLE users (
id INTEGER PRIMARY KEY,
age INTEGER
) STRICT;
'42' still converts to 42. works in 3.37+
layerbase.com/db/sqlite
paying too much for mongodb atlas? FerretDB and DocumentDB both speak the mongo wire protocol on top of postgres, so your driver and most queries stay the same
swap the connection string, test your indexes, done
we import straight from atlas, $5/mo flat
layerbase.com/migrate/mongod…
adding a CHECK to a big postgres table scans every row and blocks writes. split it
ALTER TABLE orders ADD CONSTRAINT pos
CHECK (total >= 0) NOT VALID;
ALTER TABLE orders VALIDATE CONSTRAINT pos;
validate doesn't block writes
layerbase.com/db/postgresql
duckdb 2.0 added triggers. this one keeps every row you delete
CREATE TRIGGER keep_deleted
AFTER DELETE ON orders
REFERENCING OLD TABLE AS o
FOR EACH STATEMENT
INSERT INTO orders_deleted FROM o;
orders_deleted just needs the same columns
layerbase.com/db/duckdb
DuckLake now available in beta
part of existing pro plans
DuckDB 2 can now Query Postgres or MariaDB on the free tier
layerbase.com/ducklake
ducklake saves every write as a snapshot, so a bad DELETE isn't the end
FROM lake.snapshots();
INSERT INTO lake.orders
SELECT * FROM lake.orders AT (VERSION => 2)
WHERE customer_id = 42;
works until you expire old snapshots
layerbase.com/ducklake
MongoDB vs FerretDB vs DocumentDB benchmarks
layerbase.com/blog/ferretdb-…
Layerbase now supports DuckLake Postgres and R2
🦆🦆🦆
and
🦆🦆🦆
DuckDB v2 can now query Postgres and MariaDB as data sources
External PG/S3/R2 support is also coming later this week
layerbase.com/ducklake
documentdb does vector search from mongosh
db.runCommand({createIndexes:"docs",indexes:[{name:"v",key:{emb:"cosmosSearch"},cosmosSearchOptions:{kind:"vector-hnsw",similarity:"COS",dimensions:1536}}]})
then query with $vectorSearch. pgvector underneath
layerbase.com/db/documentdb
DocumentDB is now on Layerbase
(with branching)
layerbase.com/blog/documentd…
changing a column in sqlite means rebuilding the table. libsql just alters it
ALTER TABLE users
ALTER COLUMN email TO email TEXT NOT NULL;
catch is it only applies to new or updated rows. old rows aren't rewritten or rechecked, so clean up existing NULLs first
Railway paused builds two days in a row. Can you move your app without moving its database?
layerbase.com/blog/railway-o…
