跳到正文
cccskills
免费在 GitHub 公开中文介绍

fix-slow-queries

调查并修复 Paperclip 中缓慢的 PostgreSQL 查询,在本地复现问题,比较修复前后的速度、结果和权限范围,并整理为通过测试、可供审查的拉取请求。

原文查看原文说明

Diagnose and fix slow Paperclip PostgreSQL queries using Cloud and Neon evidence, local reproduction, performance and result comparisons, regression tests, and a PR with passing checks. Use for costly queries, repeated database work, or slow requests with a suspected database cause.

集成工具PostgreSQL

实测评分 未实测

查看安装方法

适用场景

  • 调查疑似由数据库引起的响应延迟
  • 降低频繁执行的查询负载
  • 比较修复前后的速度与结果
  • 提交已验证的性能改进供审查

中文介绍

功能

fix-slow-queries 查找 Paperclip 中缓慢的 PostgreSQL 查询,根据测量结果修复并创建拉取请求。它利用 Cloud 和 Neon 统计定位高负载操作,调查调用来源和执行计划,并用真实 PostgreSQL 与合成数据复现延迟。比较修复前后速度时,也检查返回值、顺序和权限范围是否保持一致。

适用场景

面向需要调查数据库相关响应延迟或重复查询负载的开发者。适合希望在提交审查时,一并提供修复依据、防止问题复发的测试,以及最新提交检查结果的情况。

使用示例

  • “调查这个请求缓慢是否由 SQL 引起。”
  • “复现高负载查询,在保持结果不变的前提下优化,并整理成拉取请求。”

注意事项

需要目标环境的调查权限、源代码和本地可用的 PostgreSQL。原则上避免修改数据库结构;确有必要时,还会用大规模数据测量变更耗时。合并、部署和修改生产数据库需要另行授权。仅在本地提速,不能视为已经确认生产环境的响应得到改善。

本介绍由 AI(OpenAI Codex)根据公开的 SKILL.md 撰写。准确的规格请查看下方原文。

文档检查

AI 根据 SKILL.md 的内容检查了需要注意的操作和使用前提。评分只依据实际运行的结果(实测对比)。

安全性发送数据、删除文件、执行命令等是否有说明
B部分不足要求使用合成数据进行本地验证,但所提供文本未说明如何处理 Cloud 和 Neon 凭据。
安装难易度所需工具和 API 密钥是否少且有说明
B部分不足需要 Cloud、Neon 访问权限及真实 PostgreSQL,具体准备步骤位于引用资料。

不计入评分。 由 AI(OpenAI Codex)于 2026年10月20日 评估。仅供参考,安装前请同时查看原文。

如果您认为评估有误,请申请复核

请写明哪一项有误以及原因。无需登录。我们会对照 SKILL.md 重新评估,并在此处更新结果。

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

包含的文件(4)

  • SKILL.md11.1 KB
  • agents/openai.yaml128 B
  • references/cloud-discovery.md6.7 KB
  • references/local-proof.md10.5 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Fix Slow Queries

Deliver a measured improvement with preserved behavior and a reviewable PR whose latest commit passes checks. A list of suspicious SQL or an unverified rewrite is an intermediate result. Respect a narrower request for diagnosis only.

1. Establish the target and finish line

  • Resolve the reported URL, environment, company/workspace, deployed revision, owning repository, and local checkout. Read its AGENTS.md and scoped rules. Paperclip and the private paperclip-cloud control plane have different rules.
  • Work in a dedicated branch/worktree. Reuse suitable existing work; keep the checkout running a live server out of branch switching and benchmark setup.
  • Select a bounded batch, usually the top two or three query families. Record deferred candidates so discovery does not turn into an unbounded rewrite.
  • The finish line is: reproducible baseline, faster treatment, output/behavior proof, relevant regression coverage, and green checks on each final PR head. A concrete access or infrastructure blocker must be reported as incomplete.

2. Find the actual database and rank the work

Read Cloud discovery when starting from a hosted workspace. Follow the chain from Paperclip Cloud fleet admin to the stack's Neon project, branch, endpoint, database, and runtime role. Record the corresponding application deployment and time window. Do not reuse IDs from a previous run.

Capture query text/fingerprint, calls, total execution time, mean time, rows, and available I/O, temporary-file, and lock-wait evidence. Rank both expensive individual calls and frequent work with high aggregate cost. Group variants by their actual caller; do not add unrelated query means into an endpoint latency.

Keep three claims separate:

ClaimEvidence needed
SQL is expensiveQuery statistics and a reproducible execution plan
The database path dominates a slow requestCorrelated SQL, connection wait, and application timings
More database capacity would helpResource/queue pressure in the same window and a capacity-specific experiment

Cumulative query statistics are not a recent-window trace. Capture reset times or two snapshots and calculate deltas. A large database-time total alone does not justify resizing Neon. Application CPU headroom also does not rule out a busy Node main thread.

3. Trace each candidate to its behavior

Use rg on distinctive SQL fragments, table names, JSON keys, and predicates. Trace the full path: route or scheduler → service → generated SQL → indexes. Record frequency, fan-out, page limits, redaction, authorization, and any second query the caller performs. Compare the deployed implementation with local code.

State a falsifiable cause and the contract the fix must preserve. Typical causes include casts on indexed columns, repeated detoasting of large JSON, broad candidate scans, unbounded result sets, duplicate reads, and unnecessary polling. Use plans and caller evidence to choose among them.

Inspect existing indexes and recent related fixes before adding another index. For advisory locks, identify the caller, key, transaction duration, and wait chain first. Preserve checkout, leases, ownership, recovery, and no-replay rules; removing a lock or polling loop is not a query optimization by itself.

4. Reproduce the baseline locally

Read Local proof before building or changing the benchmark. Use disposable real PostgreSQL and synthetic data with representative row counts, selectivity, and payload sizes. Record the PostgreSQL version and any difference from the hosted server.

Pin the pre-fix commit. Capture the complete SQL and parameters the real service generates, including projections, joins, ordering, limits, and relevant imported query helpers. Prove the baseline exhibits the suspected cost before editing. If it does not, improve the fixture or revise the hypothesis.

Save baseline results, timings, and EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON). Define the performance acceptance criterion for this fixture before measuring the treatment. Avoid a brittle universal millisecond threshold.

5. Implement and prove both kinds of green

Make the smallest change supported by the measurements. Author the fix on our branch from source and evidence. Related community reports can supply leads; respect any instruction to keep the implementation independent of their code.

Run baseline and treatment against equivalent fixtures under the same settings:

  • Performance: use warmups and repeated samples, report medians and spread, and examine plan/buffer changes. Alternate order or repeat in reverse order when caching could explain the gain. Report neutral or slower paths honestly.
  • Correctness: compare every returned SQL column and the externally visible behavior. Preserve ordering, duplicates, nulls, tenant scope, and redaction. A faster wrong result fails even when row counts match.

When intentionally bounding history, compare query speed at the same result limit separately from the contract change. Test default/max limits and older record access. Do not call truncated output equivalent to the former full list.

Reject or revise the change if either proof fails. Keep the reproducible harness with the source where repository conventions allow it; keep bulky evidence out of git. Exhaust viable query/caller changes and existing indexes before proposing an exceptional migration. Document the serious reason and why migration-free alternatives are insufficient. Do not add startup scripts, boot-time DDL, or recurring backfills to bypass the migration constraint.

If a migration remains necessary, follow the database migration rules and the production-size timing procedure in Local proof. Measure the complete migration, including index builds, backfills, and lock waits. First optimize a migration exceeding the roughly one-to-two-minute budget; if it cannot be brought within an acceptable duration, flag it for human review with the measured timings and alternatives before presenting it as deployable.

6. Verify the blast radius

Choose checks from the caller graph and affected contracts, not only the edited function. Relevant cases from this workflow include:

ChangeRegression evidence
UUID/JSON joinsCanonical, uppercase, malformed, missing and non-string IDs; native/legacy precedence; company scope
JSON projectionsScalar/array/object/null inputs, text conversion, all fields, redaction
History boundsService and route callers, UI/API defaults, older deep links, empty recent history, retry and navigation races
Ownership/recovery readsRetained processes, active leases, blocked replay, workspace failure, receipts and delivery
Polling/cachingIdle work reduction, committed-change wakes, missed events, restart/sleep recovery, fresh destructive checks

Use real database tests for SQL semantics. Exercise assembled services/routes and actual UI components when those are affected. Update query mocks when the builder shape changes; a broken mock is not evidence that runtime SQL is wrong.

Run focused checks first, then the owning repository's required pre-PR checks. For this repo, consult AGENTS.md for typecheck, full tests, build, and conditional map/token/migration gates. Capture command, commit, exit status, and log location. Do not call an interrupted suite a pass. Preserve its partial evidence and state what completed locally versus on the final commit in CI.

7. Create the PR and carry it through checks

Use prepare-paperclip-pr for public Paperclip changes, check-pr for feedback, and prcheckloop for checks. Follow the owning repository's workflow instead when the fix belongs in paperclip-cloud.

  • Use the full PR template. Include cause, contract, benchmark command, baseline revision, fixture, before/after timings, equality evidence, regression results, and remaining risks. Label synthetic local timings as local SQL measurements. For an exceptional migration, include its justification, production-size fixture, complete duration, blocking time, optimization attempts, and any human decision still needed. Query speedup does not establish acceptable migration cost.
  • Split independent fixes into independently reviewable PRs; disclose actual dependencies. Attach every created PR to the current chat/task where supported.
  • After each push, refresh the head SHA. Address actionable reviews and failures, rerun affected local proof, and wait for fresh review and all expected checks on that SHA. Follow this repo's Greptile 5/5/no-unresolved-findings requirement.
  • Distinguish code failures from runner shutdowns or external outages. Rerun a demonstrated transient failure once. Cancel obsolete runs only after verifying they belong to this work and an older head; never terminate unrelated jobs.
  • Do not finish with "CI pending." Continue the loop within its repair bounds, or report the exact blocker, check URL, attempts, and next action. An empty check list, an old review score, or a draft-only subset of checks is not green.

Thanking contributors and closing their PRs requires explicit authorization. When authorized, explain which report our verified PR covers, acknowledge any uncovered scope, and leave unrelated PRs open. This skill does not itself grant permission to comment, close, merge, deploy, resize, or mutate a hosted database.

Constraints

  • your solution should not require a migration script to be run unless there is a serious reason - in almost all cases a migration script is a non starter
  • similarly you should not add some new boot script - e.g. dont' work around migration scripts by running the migration on every boot
  • if you add migrations, you should also have a sense on the time it will take on a large paperclip instance with thousands of tasks. the best option is to test on a clone of a production-size database and time it. if you don't have that you should make one. migrations that take an unacceptably large time to run (e.g. more than 1 or 2 minutes) must be flagged - first try to optimize the migration and then flag for a human if that's impossible

8. Hand off the evidence

Report each PR URL and final head, measured gains and neutral paths, correctness comparison, completed local checks, latest-head CI/review status, and limitations. If working from a Paperclip issue, attach evidence/work products using the repository's artifact workflow. Keep private identifiers and tenant data out of public PRs. State whether anything was deployed.

If rollout is authorized, verify the deployed revision and compare a fresh, comparable query-statistics window and request timing. Until then, production latency improvement remains unverified even when local SQL is much faster.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

add-product-e2e-eval

免费有简介

为Paperclip新增或扩展贯穿真实浏览器、服务器、数据库和runner的端到端评估,整理测试数据、判定条件与证据,并在现有报告中查看操作结果。

  • 新增完整用户操作流程的评估
  • 更新测试数据与判定条件
  • 在评估报告中加入截图和产物
paperclipai/paperclip10.7万2026年10月23日 更新

add-runner-eval

免费有简介

为Paperclip Runner添加或扩展行为评估,定义判定条件、执行目标和报告验证数据,利用正常及异常证据验证结果,并保留执行记录与费用。

  • 添加Runner行为评估
  • 用有效与无效证据检验判定
  • 更新执行列表和持续评估
paperclipai/paperclip10.7万2026年10月23日 更新

agent-browser

免费有简介

通过实际浏览器操作网页和应用,检查界面显示与运行情况。结合截图、简单表单填写、错误及网络请求记录,帮助复现问题并确认操作结果。

  • 检查界面修改后的显示效果
  • 读取由JavaScript渲染的内容
  • 复现界面问题并记录错误
paperclipai/paperclip10.7万2026年10月23日 更新

agentmail

免费有简介

通过 Paperclip 分配的 AgentMail 收件箱,查看任务关联邮件、发送新邮件或回复,并核查投递结果;重试时保留相同标识,避免重复发送。

  • 查看所负责任务关联的邮件
  • 从分配的收件箱发送新邮件
  • 回复会话中的指定邮件
paperclipai/paperclip10.7万2026年10月23日 更新

check-pr

免费有简介

检查GitHub、GitLab和Perforce变更中的评审意见、自动检查失败及说明缺漏,整理待办事项,并按请求协助修改和解决已处理的讨论。

  • 提交变更前进行检查
  • 确认失败的检查和待修改项
  • 整理人工及机器人评审意见
paperclipai/paperclip10.7万2026年10月23日 更新

company-creator

免费有简介

根据构想或现有代码仓库,梳理AI智能体的职责、汇报关系与工作交接,生成符合规范的公司或团队文件包,供组织协作和导入Paperclip使用。

  • 从构想建立智能体公司
  • 将代码仓库整理为团队
  • 设计职责分工与工作交接
paperclipai/paperclip10.7万2026年10月23日 更新

查看 paperclipai 的全部技能

报告此技能的问题