Easy Prompt
写作生成文字进阶

PostgreSQL taste

来自 prompts.chat 的提示词:PostgreSQL taste

提示词正文

复制后可直接粘贴到模型或内部评测工具。

PostgreSQL taste of a backend engineer

  • Use bigint identity columns (GENERATED ALWAYS AS IDENTITY) for primary keys; reach for UUIDv7 only when ids must be generated outside the database. Confidence: 0.80
  • Store timestamps as timestamptz in UTC, never timestamp without time zone. Confidence: 0.95
  • Use text with a CHECK constraint instead of varchar(n) for length limits. Confidence: 0.80
  • Store money as numeric or as integer minor units, never as float. Confidence: 0.95
  • Name tables in plural snake_case and foreign keys as <singular>_id. Confidence: 0.70
  • Declare NOT NULL by default and allow NULL only when "unknown" is a real state. Confidence: 0.85
  • Enforce invariants in the database with foreign keys, UNIQUE, and CHECK constraints, not only in application code. Confidence: 0.90
  • Index every foreign key column that is used in joins or cascading deletes. Confidence: 0.85
  • Read EXPLAIN (ANALYZE, BUFFERS) before adding an index, and again after to prove it helped. Confidence: 0.90
  • Prefer partial and expression indexes over wide composite indexes for skewed filters. Confidence: 0.70
  • Create indexes on large tables with CREATE INDEX CONCURRENTLY. Confidence: 0.90
  • Use jsonb for genuinely schemaless attributes, but promote fields you filter on into real columns. Confidence: 0.80
  • Paginate with keyset (WHERE id > $last ORDER BY id LIMIT n) instead of large OFFSET values. Confidence: 0.85
  • Keep transactions short and never hold one open across a network call. Confidence: 0.90
  • Set statement_timeout and idle_in_transaction_session_timeout per application role. Confidence: 0.85
  • Put a connection pooler such as PgBouncer in transaction mode in front of the database. Confidence: 0.80
  • Use SELECT ... FOR UPDATE SKIP LOCKED for simple job queues before adding a separate broker. Confidence: 0.70
  • Use INSERT ... ON CONFLICT for idempotent upserts. Confidence: 0.85
  • Give each service its own role with least privilege; the application never connects as a superuser. Confidence: 0.90
  • Turn on pg_stat_statements and review the slowest queries every week. Confidence: 0.85
  • Write CTEs for readability, knowing Postgres 12+ inlines them unless you add MATERIALIZED. Confidence: 0.65
  • Test point-in-time recovery from backups regularly; an untested backup does not count. Confidence: 0.95

使用场景

同步入库后可继续人工润色

参考输出

暂无标准答案,建议按评分维度人工评审。

评分维度

重点评估可执行性、事实准确性、边界控制和结构完整度。

试用与模板

填写变量后复制,或保存到个人工作台模板。

这个模板没有变量,可直接复制使用。

用户评分

0 个评分
-

你的评分

登录后评分

评论

0

登录后评论

相关提示词