Database Management
Decision guidance for PostgreSQL, DuckDB, Parquet, and Neo4j in hybrid storage architectures.
Contents
- When to use which database
- PostgreSQL quick reference
- DuckDB quick reference
- Parquet quick reference
- PGVector quick reference
- Neo4j quick reference
- Cross-database conventions
- Performance debugging checklist
When to use which database
| Workload |
Use |
Why |
| Transactional (CRUD, users, sessions) |
PostgreSQL |
ACID, row-level locking, indexes |
| Analytical (aggregations, scans) |
DuckDB |
Columnar, vectorized, parallel |
| Data storage/interchange |
Parquet |
Compressed, columnar, portable |
| Metadata + relationships |
PostgreSQL |
Foreign keys, constraints |
| Ad-hoc exploration |
DuckDB |
Fast on Parquet, no ETL needed |
| Time-series with point lookups |
PostgreSQL + partitioning |
Partition pruning + indexes |
| Time-series analytics |
DuckDB on Parquet |
Scan performance |
| Vector similarity search |
PostgreSQL + PGVector |
HNSW/IVFFlat indexes, hybrid search |
| RAG / semantic search |
PostgreSQL + PGVector |
Embeddings + metadata in same DB |
| Graph traversals / relationships |
Neo4j |
Native graph, index-free adjacency |
| Pattern matching / fraud detection |
Neo4j |
Multi-hop traversal, path finding |
| Knowledge graphs / ontologies |
Neo4j |
Flexible schema, relationship-first |
Hybrid pattern example:
- PostgreSQL: transactional data, relationships, users (metadata)
- DuckDB + Parquet: analytical content, aggregations, time-series
PostgreSQL quick reference
Use for: Metadata, relationships, OLTP workloads, anything needing ACID.
Key decisions:
- Partition tables >100M rows or with retention requirements
- Index columns in WHERE/JOIN clauses, not everything
- Tune autovacuum for high-churn tables
See references/postgres-architecture.md for maintenance patterns.
See references/postgres-querying.md for advanced query techniques.
DuckDB quick reference
Use for: Analytics, aggregations, Parquet queries, data exploration.
Key decisions:
- Prefer Parquet files over CSV (10-100x faster)
- Let DuckDB auto-parallelize; don't micro-optimize
- For remote data, increase threads beyond CPU count
See references/duckdb-architecture.md for storage and parallelism.
See references/duckdb-querying.md for DuckDB-specific SQL features.
Parquet quick reference
Use for: Storing analytical data, data interchange, columnar compression.
Key decisions:
- Target 128MB-1GB file sizes
- Partition by low-to-moderate cardinality columns (date, region)
- Sort by columns used in filters for better pruning
See references/parquet-architecture.md for file design.
See references/parquet-querying.md for query optimization.
PGVector quick reference
Use for: Similarity search, RAG applications, semantic search, recommendations.
Key decisions:
- HNSW for low-latency, high-recall (default choice)
- IVFFlat for memory-constrained or batch-updated data
- Use iterative scan for filtered queries
- Consider hybrid search (vector + keyword) for 8-15% accuracy boost
See references/pgvector-architecture.md for index configuration.
See references/pgvector-querying.md for hybrid search and filtering.
Neo4j quick reference
Use for: Graph traversals, relationship-heavy queries, pattern matching, knowledge graphs.
Key decisions:
- Model around your queries, not your source data
- Promote properties to nodes when you need to traverse through shared values
- Use specific relationship types to avoid supernode bottlenecks
- Bound all variable-length paths (
[*1..5], never [*])
- Use parameters in Cypher for execution plan caching
See references/neo4j-architecture.md for data modeling, indexing, and maintenance.
See references/neo4j-querying.md for Cypher optimization and anti-patterns.
Cross-database conventions
Naming
| Convention |
Example |
Applies to |
| snake_case tables |
dataset_jobs |
All |
| snake_case columns |
created_at |
PG, DuckDB, Parquet |
| camelCase properties |
createdAt |
Neo4j |
| PascalCase labels |
:UserAccount |
Neo4j |
| Singular table names |
dataset not datasets |
PostgreSQL |
| Plural for collections |
datasets/ directory |
Parquet files |
Normalization decisions
| Pattern |
When to normalize |
When to denormalize |
| Lookup tables |
PostgreSQL, changes frequently |
DuckDB/Parquet, static data |
| Repeated values |
PostgreSQL, storage matters |
Parquet, compression handles it |
| Joins at query time |
PostgreSQL, complex relationships |
Parquet, pre-join for analytics |
Timestamps
- Store as UTC always
- PostgreSQL:
TIMESTAMPTZ
- Parquet:
TIMESTAMP with isAdjustedToUTC=true
- DuckDB: reads both correctly
Performance debugging checklist
PostgreSQL slow query
- Run
EXPLAIN (ANALYZE, BUFFERS) on the query
- Check for sequential scans on large tables
- Verify indexes exist on filter/join columns
- Check
pg_stat_user_tables for bloat (dead tuples)
- Review
work_mem if seeing disk sorts
DuckDB slow query
- Check if reading CSV instead of Parquet
- Verify not doing
SELECT * on remote data
- Check thread count matches workload
- Look for unnecessary type conversions
Parquet slow reads
- Verify predicate pushdown is working (check query plan)
- Check file sizes (too small = overhead, too large = no parallelism)
- Confirm data is sorted by filter columns
- Look for high-cardinality partition keys (too many small files)
PGVector slow search
- Verify index exists and is being used (EXPLAIN)
- Check
ef_search (HNSW) or probes (IVFFlat) settings
- Enable iterative scan for filtered queries
- Check if IVFFlat recall degraded (rebuild index if heavily updated)
- Consider partial indexes for common filters
Neo4j slow query
- Run
PROFILE on the query, read operators bottom-up
- Look for
AllNodesScan or NodeByLabelScan (missing index)
- Check for
CartesianProduct (disconnected MATCH patterns)
- Verify parameters are used instead of literals (plan caching)
- Check for unbounded variable-length paths
- Monitor
page_cache.hit_ratio (below 98% = need more page cache memory)
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: managing-databases-23description: Guides database architecture decisions for PostgreSQL, DuckDB, Parquet, PGVector, and Neo4j. Use when designing schemas, choosing storage strategies, optimizing queries, tuning maintenance, configuring vector search, modeling graph data, or diagnosing performance issues across OLTP, OLAP, similarity search, and graph workloads. Use when this capability is needed.4---56# Database Management78Decision guidance for PostgreSQL, DuckDB, Parquet, and Neo4j in hybrid storage architectures.910## Contents1112- When to use which database13- PostgreSQL quick reference14- DuckDB quick reference15- Parquet quick reference16- PGVector quick reference17- Neo4j quick reference18- Cross-database conventions19- Performance debugging checklist2021## When to use which database2223| Workload | Use | Why |24| ------------------------------------- | ------------------------- | ----------------------------------- |25| Transactional (CRUD, users, sessions) | PostgreSQL | ACID, row-level locking, indexes |26| Analytical (aggregations, scans) | DuckDB | Columnar, vectorized, parallel |27| Data storage/interchange | Parquet | Compressed, columnar, portable |28| Metadata + relationships | PostgreSQL | Foreign keys, constraints |29| Ad-hoc exploration | DuckDB | Fast on Parquet, no ETL needed |30| Time-series with point lookups | PostgreSQL + partitioning | Partition pruning + indexes |31| Time-series analytics | DuckDB on Parquet | Scan performance |32| Vector similarity search | PostgreSQL + PGVector | HNSW/IVFFlat indexes, hybrid search |33| RAG / semantic search | PostgreSQL + PGVector | Embeddings + metadata in same DB |34| Graph traversals / relationships | Neo4j | Native graph, index-free adjacency |35| Pattern matching / fraud detection | Neo4j | Multi-hop traversal, path finding |36| Knowledge graphs / ontologies | Neo4j | Flexible schema, relationship-first |3738**Hybrid pattern example:**3940- PostgreSQL: transactional data, relationships, users (metadata)41- DuckDB + Parquet: analytical content, aggregations, time-series4243## PostgreSQL quick reference4445**Use for:** Metadata, relationships, OLTP workloads, anything needing ACID.4647**Key decisions:**4849- Partition tables >100M rows or with retention requirements50- Index columns in WHERE/JOIN clauses, not everything51- Tune autovacuum for high-churn tables5253See [references/postgres-architecture.md](references/postgres-architecture.md) for maintenance patterns.54See [references/postgres-querying.md](references/postgres-querying.md) for advanced query techniques.5556## DuckDB quick reference5758**Use for:** Analytics, aggregations, Parquet queries, data exploration.5960**Key decisions:**6162- Prefer Parquet files over CSV (10-100x faster)63- Let DuckDB auto-parallelize; don't micro-optimize64- For remote data, increase threads beyond CPU count6566See [references/duckdb-architecture.md](references/duckdb-architecture.md) for storage and parallelism.67See [references/duckdb-querying.md](references/duckdb-querying.md) for DuckDB-specific SQL features.6869## Parquet quick reference7071**Use for:** Storing analytical data, data interchange, columnar compression.7273**Key decisions:**7475- Target 128MB-1GB file sizes76- Partition by low-to-moderate cardinality columns (date, region)77- Sort by columns used in filters for better pruning7879See [references/parquet-architecture.md](references/parquet-architecture.md) for file design.80See [references/parquet-querying.md](references/parquet-querying.md) for query optimization.8182## PGVector quick reference8384**Use for:** Similarity search, RAG applications, semantic search, recommendations.8586**Key decisions:**8788- HNSW for low-latency, high-recall (default choice)89- IVFFlat for memory-constrained or batch-updated data90- Use iterative scan for filtered queries91- Consider hybrid search (vector + keyword) for 8-15% accuracy boost9293See [references/pgvector-architecture.md](references/pgvector-architecture.md) for index configuration.94See [references/pgvector-querying.md](references/pgvector-querying.md) for hybrid search and filtering.9596## Neo4j quick reference9798**Use for:** Graph traversals, relationship-heavy queries, pattern matching, knowledge graphs.99100**Key decisions:**101102- Model around your queries, not your source data103- Promote properties to nodes when you need to traverse through shared values104- Use specific relationship types to avoid supernode bottlenecks105- Bound all variable-length paths (`[*1..5]`, never `[*]`)106- Use parameters in Cypher for execution plan caching107108See [references/neo4j-architecture.md](references/neo4j-architecture.md) for data modeling, indexing, and maintenance.109See [references/neo4j-querying.md](references/neo4j-querying.md) for Cypher optimization and anti-patterns.110111## Cross-database conventions112113### Naming114115| Convention | Example | Applies to |116| ---------------------- | ------------------------ | ------------- |117| snake_case tables | `dataset_jobs` | All |118| snake_case columns | `created_at` | PG, DuckDB, Parquet |119| camelCase properties | `createdAt` | Neo4j |120| PascalCase labels | `:UserAccount` | Neo4j |121| Singular table names | `dataset` not `datasets` | PostgreSQL |122| Plural for collections | `datasets/` directory | Parquet files |123124### Normalization decisions125126| Pattern | When to normalize | When to denormalize |127| ------------------- | --------------------------------- | ------------------------------- |128| Lookup tables | PostgreSQL, changes frequently | DuckDB/Parquet, static data |129| Repeated values | PostgreSQL, storage matters | Parquet, compression handles it |130| Joins at query time | PostgreSQL, complex relationships | Parquet, pre-join for analytics |131132### Timestamps133134- Store as UTC always135- PostgreSQL: `TIMESTAMPTZ`136- Parquet: `TIMESTAMP` with `isAdjustedToUTC=true`137- DuckDB: reads both correctly138139## Performance debugging checklist140141### PostgreSQL slow query1421431. Run `EXPLAIN (ANALYZE, BUFFERS)` on the query1442. Check for sequential scans on large tables1453. Verify indexes exist on filter/join columns1464. Check `pg_stat_user_tables` for bloat (dead tuples)1475. Review `work_mem` if seeing disk sorts148149### DuckDB slow query1501511. Check if reading CSV instead of Parquet1522. Verify not doing `SELECT *` on remote data1533. Check thread count matches workload1544. Look for unnecessary type conversions155156### Parquet slow reads1571581. Verify predicate pushdown is working (check query plan)1592. Check file sizes (too small = overhead, too large = no parallelism)1603. Confirm data is sorted by filter columns1614. Look for high-cardinality partition keys (too many small files)162163### PGVector slow search1641651. Verify index exists and is being used (EXPLAIN)1662. Check `ef_search` (HNSW) or `probes` (IVFFlat) settings1673. Enable iterative scan for filtered queries1684. Check if IVFFlat recall degraded (rebuild index if heavily updated)1695. Consider partial indexes for common filters170171### Neo4j slow query1721731. Run `PROFILE` on the query, read operators bottom-up1742. Look for `AllNodesScan` or `NodeByLabelScan` (missing index)1753. Check for `CartesianProduct` (disconnected MATCH patterns)1764. Verify parameters are used instead of literals (plan caching)1775. Check for unbounded variable-length paths1786. Monitor `page_cache.hit_ratio` (below 98% = need more page cache memory)179180---181> Converted and distributed by [TomeVault](https://tomevault.io/claim/rileyhilliard) — claim your Tome and manage your conversions.182<!-- tomevault:4.0:skill_md:2026-04-11 -->