> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pawsql.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> PawSQL 是一个产品：Cloud 是公网部署形态，Engine / Optimizer / Auditor / Advisor / Patroller 是同一产品的组件与交付形态，不是彼此独立的产品。 / PawSQL is a single product: Cloud is the public deployment form, while Engine / Optimizer / Auditor / Advisor / Patroller are components and delivery forms of the same product, not separate products.
> 术语以站内术语表为准：SQL 审核对应英文 SQL Review，查询重写对应 Query Rewrite，索引推荐对应 Index Recommendation；英文内容统一用 Review，不用 Audit。 / Use the site glossary for terminology: 审核 is SQL Review, 重写 is Query Rewrite, 索引推荐 is Index Recommendation; English content uses Review, never Audit.
> 引用能力范围或版本支持时以对应页面为准；标注 unknown、或 status 非 published 的内容表示尚未经产品核实，不应作为事实引用。 / Cite capability scope and version support from the corresponding page; content marked unknown, or with a status other than published, is not yet product-verified and must not be cited as fact.

# SQL Quality Gate for CI/CD

> Integrate automated SQL quality check, risk detection, and performance analysis into your CI/CD pipeline to block risky SQL before it reaches production.

## Audience

DevOps / platform engineering teams, DBAs, and engineering leads — the teams responsible for wiring SQL quality control into the delivery pipeline.

## Problem

Application code already has unit tests, code scanning, security checks, and CI/CD — but database SQL in many organizations is still reviewed manually by DBAs. As teams scale and release cadence increases, three problems emerge:

1. The DBA becomes a delivery bottleneck
2. SQL quality check standards are hard to enforce consistently
3. SQL performance problems are found too late

## Goal

Treat SQL like application code — give it an automated quality gate before release, turning manual approval into a repeatable, auditable gate.

## Workflow

Wire PawSQL into the commit and release flow:

```mermaid theme={null}
flowchart TD
    A[Developer Commit] --> B[Pull Request] --> C[CI/CD Pipeline]
    C --> D[SQL Quality Check] --> E[Policy Evaluation]
    E --> F{PASS / BLOCK}
    F -->|PASS| G[Merge]
    F -->|BLOCK| H[Fix SQL]
```

## Dependencies

Built from the following capabilities (see each capability page for check items and rewrite logic):

<CardGroup cols={2}>
  <Card title="SQL Quality Check" icon="list-check" href="/en/features/sql-review" />

  <Card title="Query Rewrite" icon="git-compare" href="/en/features/automatic-sql-rewrite" />

  <Card title="Index Recommendation" icon="layers" href="/en/features/index-recommendation" />

  <Card title="Execution Plan Analysis" icon="route" href="/en/features/execution-plan-visualization" />

  <Card title="Performance Validation" icon="gauge" href="/en/features/performance-validation" />
</CardGroup>

## Success Criteria

| Metric                                | Objective |
| ------------------------------------- | --------- |
| SQL auto-review coverage              | Increase  |
| Issues found before release           | Increase  |
| DBA manual review workload            | Decrease  |
| Average SQL review time               | Decrease  |
| Critical SQL reaching production      | Decrease  |
| Production slow SQL from new releases | Decrease  |

***

## Policy as Code

The gate's core value is turning a database development standard from a document into executable policy:

```text theme={null}
Policy
├─ No DELETE / UPDATE without a predicate
├─ No full table scan on large tables
├─ No forbidden DDL
├─ Index naming convention
├─ Maximum affected rows
└─ Database-specific production rules
```

Standards no longer live only in a wiki or a policy document; they run directly in the delivery pipeline.

### Multi-level rules

Large organizations typically need a shared baseline plus per-business differentiation:

* **Group level**: no `DELETE` / `UPDATE` without a predicate
* **Core systems**: high-risk DDL requires DBA approval
* **Internet businesses**: `OFFSET > 100000` flagged as a deep-pagination risk

### Configurable thresholds

Configure the maximum Critical / Warning count, ignorable rules, mandatory-block rules, and per-environment policy — for example a relaxed test environment and a strict production release.

## Decide the Release Action by Severity

Define a consistent severity-to-action mapping:

| Severity | Action                        |
| -------- | ----------------------------- |
| Info     | Record only                   |
| Warning  | Allow with warning            |
| Error    | Require confirmation / review |
| Critical | Block pipeline                |

```mermaid theme={null}
flowchart LR
    A[Critical] --> B[BLOCK]
    C[Error] --> D[DBA Review]
    E[Warning] --> F[PASS WITH WARNING]
```

## Connect the Gate to Your Pipeline

Integrate via REST API, Webhook, CLI / script, or DevOps platform:

<CardGroup cols={2}>
  <Card title="GitLab CI/CD" icon="git-merge" href="/en/user-guide/cicd/gitlab" />

  <Card title="GitHub" icon="git-merge" href="/en/user-guide/cicd/github" />

  <Card title="Tencent CODING" icon="git-merge" href="/en/user-guide/cicd/coding" />

  <Card title="BlueKing Pipeline" icon="git-merge" href="/en/user-guide/cicd/blueking" />

  <Card title="Jenkins / GitHub Actions via OpenAPI" icon="git-merge" href="/en/user-guide/cicd/openapi-pipeline" />
</CardGroup>

<CardGroup cols={2}>
  <Card title="Explore SQL Quality Check" icon="list-check" href="/en/features/sql-review">
    Review SQL standards, safety, and performance risks in CI/CD.
  </Card>

  <Card title="Explore Query Rewrite" icon="wand-sparkles" href="/en/features/automatic-sql-rewrite">
    Generate equivalent rewrites and index advice automatically.
  </Card>

  <Card title="Learn About Developer SQL Copilot" icon="code" href="/en/use-cases/developer-sql-copilot">
    Get real-time optimization advice while writing SQL.
  </Card>

  <Card title="Request a Demo" icon="plug" href="https://www.pawsql.com">
    Schedule a PawSQL product demo.
  </Card>
</CardGroup>
