Skip to Content
CockroachDB: The Definitive Guide, 2nd Edition
book

CockroachDB: The Definitive Guide, 2nd Edition

by Guy Harrison, Jesse Seldess, Ben Darnell, Rob Reid
March 2025
Intermediate to advanced
542 pages
8h 50m
Japanese
O'Reilly Media, Inc.
Content preview from CockroachDB: The Definitive Guide, 2nd Edition

第8章 SQLチューニング SQLチューニング

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

CockroachDBは、スケーラブルな分散トランザクションデータベースシステムとして設計された。CockroachDBは、高性能で可用性が高く、グローバルに分散したアプリケーションの要求を満たすことができる。 しかし、アプリケーションコードやスキーマ設計の非効率性をすべて排除できる魔法の箱ではない。時折、開発者やアプリケーションは、必要なほど高速に動作しないSQL文をデータベースに送信する。その結果、有史以来、少なくともリレーショナルデータベースが出現して以来、SQLチューニングはデータベース開発者や管理者にとって大きな関心事となってきた。

この章では、CockroachDBのインテリジェントなコスト・ベース・オプティマイザがSQL文をどのように最適化するのか、またCockroachDBがこれらのクエリをより高速に実行できるようにするにはどうすればよいのかを説明する。また、チューニングが必要と思われるクエリを発見する方法、それらのSQL文が最適化されているかどうかを判断する方法、それらのクエリを高速化する方法についても説明する。

遅いSQLの発見

最新かつ包括的なクエリ統計が整備されていると仮定すると、クラスタを監視して問題のあるSQL文を特定する必要がある。

多くのアプリケーションはSQL文や論理トランザクション時間をログに記録し、パフォーマンスの悪いSQL文についての洞察を提供する。しかし、アプリケーションレベルのトレースがない場合、CockroachDB自体が全体的なSQL実行時間に関する情報を提供できる。

CockroachDB Cloudクラスタの場合、、以下の場所から始めるのが最適である:

ステートメントのページ

https://cockroachlabs.cloud/cluster/YOUR_CLUSTER_ID/sql-activity からアクセスできるこのページには、基本的な実行統計とともに、サーバ上で実行された SQL 文がリストされている。平均ステートメント時間や累積実行時間でソートして、注意が必要なSQLステートメントを特定することができる。特定の SQL 文をクリックすると、Statement Details に移動する。

ワークロード・インサイトのページ

https://cockroachlabs.cloud/cluster/YOUR_CLUSTER_ID/insights?tab=Workload+Insightsからアクセスできるこのページは、ステートメントとトランザクションの実行、そのステータス、再試行、遅い実行、または最適でないプランに遭遇したかどうかをリストする。ステートメントページと同様に、ワークロードインサイトはソート可能で、インサイトをクリックすると詳細な内訳が表示される。

スキーマ・インサイトのページ

https://cockroachlabs.cloud/cluster/YOUR_CLUSTER_ID/insights?tab=Schema+Insightsからアクセスできるこのページは、データベーススキーマオブジェクトを改善する機会をリストアップし、不足しているインデックスの追加、最適でないインデックスの更新、または使用されていないインデックスの削除の必要性を強調する。

Self-Hosted クラスタの場合、CockroachDB ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

CockroachDB: The Definitive Guide, 2nd Edition

CockroachDB: The Definitive Guide, 2nd Edition

Guy Harrison, Jesse Seldess, Ben Darnell, Rob Reid
CockroachDB: The Definitive Guide

CockroachDB: The Definitive Guide

Guy Harrison, Jesse Seldess, Ben Darnell

Publisher Resources

ISBN: 9798341634695