Token导航 LogoToken导航

Agent Skill · 研究检索

database-optimization-commerce(数据库优化商务)

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

database-optimization-commerce 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 56,510。

总安装 449周安装 18GitHub Stars 19下载 145核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:database-optimization-commerce(数据库优化商务)
来源仓库:https://github.com/finsilabs/awesome-ecommerce-skills
仓库路径:skills/database-optimization-commerce
安装命令:
npx skills add https://github.com/finsilabs/awesome-ecommerce-skills --skill database-optimization-commerce
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/finsilabs/awesome-ecommerce-skills --skill database-optimization-commerce

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

电商场景下商品筛选、订单创建等高并发访问的性能调优专知。针对 category+price+brand 等多维过滤设计高效索引组合。提出订单表水平拆分与读副本分流的具体实施方案。适用于大促期间流量高峰前的容量压测与瓶颈定位。

database-optimization-commerce 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/database-optimization-commerce

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

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

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

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

常见问题

6 条

database-optimization-commerce 怎么安装?

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

database-optimization-commerce 支持哪些 AI 工具?

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

database-optimization-commerce 需要什么权限?

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

database-optimization-commerce 是免费的吗?

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

database-optimization-commerce 用的人多吗?

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

database-optimization-commerce 安全吗?

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

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

值得选的地方

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

先想清楚的地方

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

适不适合你

更适合

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

不太适合

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

研究检索类 Skill 对比

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

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
database-optimization-commerce

数据库优化商务 · 本页

44919只读未明确通过

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

SKILL.md 原文

Database Optimization — Commerce

Overview

E-commerce databases face distinct query patterns: high-cardinality product filtering (category + price + attributes), session-scoped cart lookups, write-heavy order creation, and read-heavy catalog browsing that must scale to concurrent users. This skill covers identifying slow queries, designing effective indexes for product filtering, partitioning order tables, and routing read traffic to replicas.

When to Use This Skill

  • When product listing pages are slow due to unindexed filter combinations (category + price + brand)
  • When checkout throughput is limited by order insertion latency
  • When read load on the primary database is causing write latency to increase
  • When a slow query log reveals queries doing sequential scans on large tables
  • When planning a database schema for a new custom e-commerce platform

Core Instructions

Step 1: Determine your situation

Database optimization applies primarily to self-hosted setups. Understand your constraints first:

PlatformDatabase ControlWhat to Optimize
ShopifyNone — Shopify manages all infrastructureFocus on Liquid template rendering speed, app performance, and Shopify's built-in query optimization via Search & Discovery app
WooCommerceFull — you manage MySQL/MariaDB on your hostOptimize WooCommerce queries with caching plugins (Redis Object Cache, WP Rocket), add database indexes via WP Optimize plugin, and configure your hosting MySQL settings
BigCommerceNone — BigCommerce manages all infrastructureFocus on theme performance, image optimization, and reducing third-party app overhead
Custom / HeadlessFull — you own PostgreSQL (or MySQL)Apply all the techniques below; PostgreSQL is assumed in code examples

Step 2: Quick wins for WooCommerce (managed WordPress/WooCommerce)

Before touching database indexes directly, apply these WooCommerce-specific optimizations:

  1. Install Redis Object Cache (free, wordpress.org):

- Your host must support Redis (most managed WordPress hosts — WP Engine, Kinsta, Cloudways — do) - Install and activate the plugin; go to Settings → Redis and click Enable Object Cache - This caches all WooCommerce database queries in memory, dramatically reducing repeat query times

  1. Install WP-Optimize (free, wordpress.org):

- Go to WP-Optimize → Database and run Clean database to remove orphaned order meta, expired transients, and post revisions - WooCommerce stores build up millions of rows of orphaned meta over time — regular cleanup is essential - Schedule automatic cleanup weekly

  1. Enable the WooCommerce HPOS (High-Performance Order Storage):

- Go to WooCommerce → Settings → Advanced → Features - Enable High-Performance Order Storage — this moves orders from WP post tables to dedicated order tables with proper indexes - Critical for stores with 10,000+ orders

  1. Upgrade to a host with MySQL 8.0+ — older MySQL versions lack important index improvements; WP Engine, Kinsta, and Cloudways all run MySQL 8.0+

Step 3: PostgreSQL optimization for custom storefronts


Identify slow queries
-- Enable pg_stat_statements to find the worst offenders
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

-- Top 20 slowest queries by total cumulative time
SELECT
  round(total_exec_time::numeric, 2) AS total_ms,
  round(mean_exec_time::numeric, 2) AS mean_ms,
  calls,
  round((total_exec_time / sum(total_exec_time) OVER()) * 100, 2) AS pct_of_total,
  left(query, 200) AS query
FROM pg_stat_statements
WHERE calls > 100
ORDER BY total_exec_time DESC
LIMIT 20;

-- Diagnose a specific slow query
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
SELECT p.id, p.name, p.price
FROM products p
JOIN product_categories pc ON pc.product_id = p.id
WHERE pc.category_id = 42
  AND p.price BETWEEN 1000 AND 5000
  AND p.status = 'active'
ORDER BY p.created_at DESC
LIMIT 24;
-- Look for "Seq Scan" on large tables — this means a missing index
Design indexes for product filtering
-- Partial index on active products only (smaller, faster)
CREATE INDEX CONCURRENTLY idx_products_status
  ON products (status) WHERE status = 'active';

CREATE INDEX CONCURRENTLY idx_products_price
  ON products (price) WHERE status = 'active';

-- Composite index for the most common filter combination
-- INCLUDE adds non-key columns for index-only scans (no table heap access)
CREATE INDEX CONCURRENTLY idx_products_listing
  ON products (status, brand_id, price, created_at DESC)
  INCLUDE (name, slug, thumbnail_url);

-- GIN index for flexible JSONB attribute filtering
-- Enables: attributes @> '{"color": "blue", "size": "M"}'
CREATE INDEX CONCURRENTLY idx_products_attributes
  ON products USING gin(attributes);

-- ALWAYS index foreign keys (PostgreSQL does NOT do this automatically)
CREATE INDEX CONCURRENTLY idx_product_categories_product_id
  ON product_categories (product_id);
CREATE INDEX CONCURRENTLY idx_order_lines_order_id
  ON order_lines (order_id);
Partition the orders table by date
-- Create orders table with range partitioning on created_at
CREATE TABLE orders (
  id          UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  customer_id UUID NOT NULL,
  status      TEXT NOT NULL,
  total_cents INTEGER NOT NULL,
  created_at  TIMESTAMPTZ NOT NULL DEFAULT NOW()
) PARTITION BY RANGE (created_at);

-- Quarterly partitions
CREATE TABLE orders_2025_q1 PARTITION OF orders
  FOR VALUES FROM ('2025-01-01') TO ('2025-04-01');
CREATE TABLE orders_2025_q2 PARTITION OF orders
  FOR VALUES FROM ('2025-04-01') TO ('2025-07-01');
-- (continue for Q3, Q4, 2026...)

-- Indexes on the parent propagate to all partitions
CREATE INDEX CONCURRENTLY ON orders (customer_id, created_at DESC);
CREATE INDEX CONCURRENTLY ON orders (status, created_at DESC);
Route reads to replicas
// lib/database.js — two connection pools
import { Pool } from 'pg';

const primaryPool = new Pool({ connectionString: process.env.DATABASE_URL, max: 20 });
const replicaPool = new Pool({ connectionString: process.env.DATABASE_REPLICA_URL, max: 50 });

export const db = {
  // Writes and anything requiring freshness — primary
  async write(sql, params = []) {
    const result = await primaryPool.query(sql, params);
    return result.rows;
  },
  // Catalog reads — replica (slight staleness is acceptable)
  async read(sql, params = []) {
    const result = await replicaPool.query(sql, params);
    return result.rows;
  },
  // Transactions — always primary
  async transaction(fn) {
    const client = await primaryPool.connect();
    try {
      await client.query('BEGIN');
      const result = await fn(client);
      await client.query('COMMIT');
      return result;
    } catch (e) {
      await client.query('ROLLBACK');
      throw e;
    } finally {
      client.release();
    }
  },
};

Route reads correctly:

  • Catalog pages, product search, order history → db.read() (replica)
  • Cart operations, checkout, inventory decrement → db.write() or db.transaction() (primary)
Use keyset pagination (never OFFSET for large catalogs)
-- OFFSET 10000 reads and discards 10,000 rows — slow at scale
-- Use keyset pagination instead: pass the last row's cursor values

-- First page
SELECT id, name, price, created_at FROM products
WHERE status = 'active'
ORDER BY created_at DESC, id DESC
LIMIT 24;

-- Next page (pass last row's created_at and id as cursor)
SELECT id, name, price, created_at FROM products
WHERE status = 'active'
  AND (created_at, id) < ('2025-03-01T12:00:00Z', 'uuid-of-last-row')
ORDER BY created_at DESC, id DESC
LIMIT 24;

Best Practices

  • Use EXPLAIN (ANALYZE, BUFFERS) to validate index usage — EXPLAIN alone shows estimates; ANALYZE runs the query and shows actuals; "Seq Scan" on a large table means a missing index
  • Create indexes CONCURRENTLY — without CONCURRENTLY, index creation locks the table for writes; always use it in production
  • Index all foreign keys — PostgreSQL does not auto-index foreign keys; customer_id, order_id, and product_id in join tables must be explicitly indexed
  • Set work_mem carefully — increasing work_mem speeds up sorting but multiplies with connection count; benchmark before raising it
  • Run VACUUM ANALYZE regularly — table bloat from dead tuples slows all queries; configure autovacuum aggressively on high-write tables like carts and sessions

Common Pitfalls

ProblemSolution
Index not used for multi-column filtersComposite index column order matters: equality columns first (status, brand_id), range columns last (price, created_at)
Slow JSONB attribute filteringAdd a GIN index on the full attributes column for @> containment queries; use expression indexes for range queries on specific JSON keys
Read replica lag causing stale cart dataRoute cart reads to primary; only route catalog and order history reads to replica where slight staleness is acceptable
Partition pruning not workingEnsure WHERE clause includes the partition key (created_at) so PostgreSQL can skip irrelevant partitions
Slow pagination on page 50+Replace OFFSET with keyset pagination using the last row's values as a cursor

Related Skills

  • @flash-sale-scaling
  • @monitoring-alerting-commerce
  • @ecommerce-caching
  • @load-testing-commerce

平台分布

Codex

37.82%
按下载量换算55

Claude

29.13%
按下载量换算42

Cursor

17.84%
按下载量换算26

Gemini CLI

9.04%
按下载量换算13

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

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

安装前确认

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

继续浏览同类 Skills