Token导航 LogoToken导航

Agent Skill · 待分类

benchmarking-transaction-patterns(对标交易模式)

benchmarking-transaction-patterns 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

benchmarking-transaction-patterns 是待分类类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描已通过,按安装量在待分类类的 11,209 个 Skill 里排第 6,841。

总安装 416周安装 17GitHub Stars 9下载 135核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:benchmarking-transaction-patterns(对标交易模式)
来源仓库:https://github.com/cockroachlabs/cockroachdb-skills
仓库路径:skills/benchmarking-transaction-patterns
安装命令:
npx skills add https://github.com/cockroachlabs/cockroachdb-skills --skill benchmarking-transaction-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/cockroachlabs/cockroachdb-skills --skill benchmarking-transaction-patterns

这个 Skill 是做什么的

这个 Skill 的分类还没最终确定,用法以来源仓库的说明为准。

benchmarking-transaction-patterns 用于比较 CockroachDB 中不同事务模式的性能表现,适合数据库架构设计阶段使用。适用于 Codex、Claude、Cursor、Gemini CLI,专注于多语句事务与 CTE 事务在高并发下的行为差异分析。

通过标准化测试方法评估吞吐量、延迟与公平性指标,辅助选择最优事务实现方式。需确认是否具备访问数据库实例的权限,并注意测试过程中可能产生的资源消耗与网络开销。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/benchmarking-transaction-patterns

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/cockroachlabs/cockroachdb-skills --skill bench…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

benchmarking-transaction-patterns 怎么安装?

在终端执行 npx skills add https://github.com/cockroachlabs/cockroachdb-skills --skill benchmarking-tr…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

benchmarking-transaction-patterns 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

benchmarking-transaction-patterns 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

benchmarking-transaction-patterns 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

benchmarking-transaction-patterns 用的人多吗?

公开数据是累计安装 416 次,近一周安装 17 次,下载 135 次,GitHub 9 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

benchmarking-transaction-patterns 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。
  • 标注为只读权限,试用阶段不容易误改本地文件。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理待分类类任务、又不想每次都手写提示词的人。
  • 只想先试试效果、不希望它改动本地文件的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

待分类类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
infsh-cli

infsh CLI · Codex、Claude

4,374,576382权限未标注未明确未收录
ai-video-generation

AI 视频生成 · Codex、Claude

4,313,376382调用外部服务未明确有提醒
lark-openapi-explorer

云雀 OpenAPI 浏览器 · Codex、Claude

2,064,1209,011需要联网未明确有提醒
lark-workflow-standup-report

Lark 工作流程站立报告 · Codex、Claude

2,041,6328,978需要联网未明确通过
use-my-browser

使用我的浏览器 · Codex、Claude

1,848,49140操作浏览器未明确未通过
benchmarking-transaction-patterns

对标交易模式 · 本页

4169只读未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Benchmarking Transaction Patterns

Guides users through benchmarking, explaining, and comparing two formulations of the same transactional business workflow in CockroachDB: explicit multi-statement transactions versus single-statement CTE transactions. Focuses on performance under contention, fair test methodology, and result interpretation.

Complement to design skills: For general transaction design principles, see designing-application-transactions. For SQL syntax and query patterns, see cockroachdb-sql.

When to Use This Skill

  • Comparing explicit multi-statement transactions versus CTE-based single-statement transactions
  • Benchmarking CockroachDB workloads under high concurrency or hot-key contention
  • Investigating retry pressure, p95/p99 latency, or throughput differences between transaction formulations
  • Deciding whether to rewrite a multi-step application flow into a single SQL statement
  • Setting up a fair side-by-side benchmark with proper reset discipline
  • Interpreting benchmark results (throughput, retries, tail latency, failures)
  • Explaining why SQL Activity still shows waiting even with CTE transactions

Prerequisites

  • CockroachDB test cluster (do not benchmark on production)
  • SQL client or JDBC driver for benchmark execution
  • Understanding of CockroachDB SERIALIZABLE isolation and retry behavior
  • Familiarity with basic concurrency testing concepts

Core Concept

When two implementations perform the same business behavior, the transaction formulation itself can be a primary performance lever under contention.

Explicit Transaction Model

The application orchestrates the workflow as separate SQL statements inside a transaction: read state, apply logic, write changes, commit.

BEGIN;

SELECT balance FROM accounts WHERE id = $1;

-- Application decides whether transfer is allowed

UPDATE accounts SET balance = balance - $2 WHERE id = $1;
UPDATE accounts SET balance = balance + $2 WHERE id = $3;

INSERT INTO transfers (from_acct, to_acct, amount, created_at)
VALUES ($1, $3, $2, now());

COMMIT;

This keeps the transaction open across multiple statements and often includes application-side decision logic between steps.

CTE Transaction Model

The same read/decision/write logic is expressed as a single SQL statement, so the database evaluates and applies the business operation atomically without intermediate client orchestration.

WITH debit AS (
  UPDATE accounts
  SET balance = balance - $2
  WHERE id = $1
    AND balance >= $2
  RETURNING id
), credit AS (
  UPDATE accounts
  SET balance = balance + $2
  WHERE id = $3
    AND EXISTS (SELECT 1 FROM debit)
  RETURNING id
), ins AS (
  INSERT INTO transfers (from_acct, to_acct, amount, created_at)
  SELECT $1, $3, $2, now()
  WHERE EXISTS (SELECT 1 FROM debit)
    AND EXISTS (SELECT 1 FROM credit)
  RETURNING id
)
SELECT id FROM ins;

Why CTE Tends to Win Under Contention

The explicit version keeps the transaction open across multiple statements, increasing the time window for write conflicts, timestamp pushes, and retries. Under high concurrency, each retry repeats the read and write work and continues contending for the same hot data.

The CTE version collapses the same business logic into a single atomic statement, reducing transaction duration and sharply narrowing the contention window.

Steps

1. Prepare the Benchmark Environment

Set up a dedicated test database and schema. Do not mix benchmark workloads with other traffic.

CREATE DATABASE IF NOT EXISTS bankbench;
USE bankbench;

CREATE TABLE accounts (
  id INT PRIMARY KEY,
  balance DECIMAL(18,2) NOT NULL DEFAULT 0
);

CREATE TABLE transfers (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  from_acct INT NOT NULL,
  to_acct INT NOT NULL,
  amount DECIMAL(18,2) NOT NULL,
  created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);

2. Seed the Test Data

Use multi-row UPSERT for efficient seeding. Single-row inserts distort setup cost.

INSERT INTO accounts (id, balance)
SELECT generate_series(1, 10000), 1000.00
ON CONFLICT (id) DO UPDATE SET balance = 1000.00;

3. Run the Explicit Transaction Benchmark

Execute with realistic concurrency (e.g., 64-128 workers) and a fixed duration or iteration count. Record throughput, retries, p50/p95/p99 latency, max latency, and failures.

4. Reset Between Runs for Fair Comparison

For a fair benchmark, reset account balances between explicit and CTE runs so table size, index size, and account state remain comparable.

UPDATE accounts SET balance = 1000.00;

5. Run the CTE Transaction Benchmark

Execute with the same concurrency, duration, and parameters as the explicit run.

6. Compare Results

Always compare these metrics side by side:

MetricWhat to Look For
Throughput (txn/s)Higher is better; CTE typically sustains better under contention
Total retriesCTE often reduces to near-zero
p50 latencyMedian transaction time
p95 latencyTail latency under moderate contention
p99 latencyWorst-case tail; explicit model often shows spikes
Max latencyOutlier behavior
FailuresNon-retryable errors

Benchmark Reference Results

In a reported high-contention run comparing the two models:

MetricExplicitCTEChange
Throughput591.1 txn/s1,035.1 txn/s+75.1%
Wall time216.5s123.7s-42.9%
Average latency202.2 ms111.3 ms-45.0%
Total retries2,270,9770-100%

Extended runs preserved the same directional result at higher total volume, with the explicit model continuing to accumulate retries and occasional failures while the CTE model stayed at zero retries and zero failures.

Impact Summary

DimensionExplicit Multi-StatementSingle-Statement CTE
Round tripsMultiple client/server interactionsSingle request
Transaction lifetimeLongerShorter
Client retry complexityHigherLower
Atomic invariant enforcementSpread across statements/app logicContained in SQL
Expected throughputLower under contentionHigher under contention
Client-visible retriesMore likelyOften reduced

Decision Guidance

Prefer the Explicit Pattern When

  • The business workflow truly cannot be expressed cleanly in one SQL statement
  • Readability or staged business logic matters more than peak throughput
  • The contention level is low enough that retry amplification is not the dominant cost

Prefer the CTE Pattern When

  • The workflow is contention-heavy
  • The operation is naturally atomic
  • The application currently performs read-decide-write across multiple statements
  • The main goal is higher throughput, lower retries, and more stable p95/p99 latency

Fair Benchmark Rules

  1. Reset between runs for fair comparison so balances, table size, and index size stay consistent
  2. Treat no-reset runs as a demo, not an apples-to-apples benchmark
  3. Use --batch-size=1 when you want one business unit of work at a time for clean comparison
  4. Compare the right metrics — always include throughput, retries, p50, p95, p99, max latency, and failures
  5. Use multi-row UPSERT for seeding — single-row seeding distorts setup cost

Common Misconceptions

"CTE always wins in every workload" — No. The claim is narrower: when the same business workflow can be expressed as a single atomic statement and the workload is contention-sensitive, collapsing the transaction shape can materially improve performance and stability.

"SQL Activity showing waiting means CTE failed" — Single-statement CTE execution does not eliminate contention. Statements can still wait on row conflicts, write intents, latches, or scheduling. The right comparison is overall throughput, tail latency, and retry profile.

"Single-statement means no contention" — A CTE can still wait under contention. The benefit is a narrower contention window, not the elimination of contention.

Safety Considerations

  • Run benchmarks on dedicated test clusters, not production
  • Reset data between runs for fair comparison
  • Monitor cluster health during benchmark execution
  • Use realistic but not destructive concurrency levels
  • Validate that benchmark results transfer to your specific workload before making production changes

References

平台分布

Codex

35.03%
按下载量换算47

Claude

28.18%
按下载量换算38

Cursor

19.39%
按下载量换算26

Gemini CLI

10.53%
按下载量换算14

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills