logo资料库

介绍Mysql工作原理的书—Understanding MySQL Internals.pdf

第1页 / 共256页
第2页 / 共256页
第3页 / 共256页
第4页 / 共256页
第5页 / 共256页
第6页 / 共256页
第7页 / 共256页
第8页 / 共256页
资料共256页,剩余部分请下载后查看
Understanding MySQL Internals
Table of Contents
Preface
How This Book Is Organized
Who This Book Is For
Conventions Used in This Book
Using Code Examples
Comments and Questions
Safari® Enabled
Acknowledgments
MySQL History and Architecture
MySQL History
MySQL Architecture
Core Modules
Interaction of the Core Modules
Detailed Look at the Core Modules
Server Initialization Module
Connection Manager
Thread Manager
Connection Thread
User Authentication Module
Access Control Module
Parser
Command Dispatcher
Query Cache Module
Optimizer
Table Manager
Table Modification Modules
Table Maintenance Module
Status Reporting Module
Abstracted Storage Engine Interface (Table Handler)
Storage Engine Implementations (MyISAM, InnoDB, MEMORY, Berkeley DB)
Logging Module
Replication Master Module
Replication Slave Module
Client/Server Protocol API
Low-Level Network I/O API
Core API
Nuts and Bolts of Working with the MySQL Source Code
Unix Shell
BitKeeper
Preparing the System to Build MySQL from BitKeeper Tree
Building MySQL from BitKeeper Tree
Building from Source Distribution
Installing MySQL into a System Directory
Source Code Directory Layout
Preparing the System to Run MySQL in a Debugger
Debugger-Guided Source Tour
Basics of Working with gdb
Finding Things in the Source
Interesting Breakpoints and Variables
Making a Source Modification
Coding Guidelines
Stability
Portability
Performance
Style and Ease of Integration
Keeping Your BitKeeper Repository Up to Date
Submitting a Patch
Core Classes, Structures, Variables, and APIs
THD
NET
TABLE
Field
Utility API Calls
Preprocessor Macros
Global Variables
Client/Server Communication
Protocol Overview
Packet Format
Relationship Between MySQL Protocol and OS Layer
Authenticating Handshake
Authentication Protocol Security
Protocol Capabilities Bit Mask
Command Packet
Server Responses
Data Field
OK Packet
Error Packet
EOF Packet
Result Set Packets
Configuration Variables
Configuration Variables Tutorial
Configuration File and Command-Line Options
Internals of the Configuration Option Parsing
Example of Adding a New Configuration Option
Interesting Aspects of Specific Configuration Variables
big-tables
concurrent-insert
core-file
default-storage-engine
delay-key-write
ft_stopword_file
innodb_buffer_pool_size
innodb_flush_log_at_trx_commit
innodb_file_per_table
innodb_lock_wait_timeout
innodb_force_recovery
init-file
key_buffer_size
language
log
log-bin
log-isam
log-slow-queries
max_allowed_packet
max_connections
max_heap_table_size
max_join_size
max_sort_length
myisam-recover
query_cache_type
read_buffer_size
relay-log
server-id
skip-grant-tables
skip-stack-trace
slave-skip-errors
sort_buffer_size
sql-mode
table_cache
temp-pool
transaction-isolation
Thread-Based Request Handling
Threads Versus Processes
Advantages of Using Threads
Disadvantages of Using Threads
Advantages of Using Forked Processes
Disadvantages of Using Forked Processes
Implementation of Request Handling
Structures, Variables, Classes, and API
Execution Walk-Through
Thread Programming Issues
Standard C Library Calls
Mutually Exclusive Locks (Mutexes)
Read-Write Locks
Synchronization
Preemption
The Storage Engine Interface
The handler Class
handlerton
Adding a Custom Storage Engine to MySQL
Integration Instructions for Version 4.1
Integration Instructions for Version 5.1
Concurrent Access and Locking
Table Lock Manager
Read Lock Request
Write Lock Request
Storage engine interaction with the table lock manager
InnoDB Locking
Lock types
Record locking
Dealing with deadlocks
Parser and Optimizer
Parser
Lexical Scanner
Grammar Rules Module
Parse Tree
Optimizer
Basics of the Optimizer Algorithm
Using EXPLAIN to Understand the Optimizer
Understanding the output of EXPLAIN
Select types
Record access types
Extra field
Range Optimizer
Range
Index_merge
Range_desc
Fulltext
ROR_intersect
ROR_union
Group_min_max
Subquery Optimization
Core Optimizer Classes and Structures
JOIN
JOIN_TAB
select_result
SELECT Parse Tree
Execution of a SELECT on the code level
Storage Engines
Shared Aspects of Architecture
MyISAM
MyISAM Architecture
Datafile
Index file
MyISAM Key Types
B-tree keys
Full-text keys
Spatial keys
InnoDB
Memory (Heap)
MyISAM Merge
NDB
Archive
Federated
Transactions
Overview of Transactional Storage Engine Implementation
Implementing the handler Subclass
Defining the handlerton
Working with the Query Cache
Working with the Replication Binary Log
Avoiding Deadlocks
Replication
Overview
Statement-Based Versus Row-Based Replication
Two-Threaded Slave
Multi-Master
SQL Commands to Help Understand Replication
Binary Log Format
Creating a Custom Replication Utility
Index
Understanding MySQL Internals
Other resources from O’Reilly Related titles The Art of SQL Database in Depth High Performance MySQL Learning MySQL Learning SQL MySQL Cookbook™ MySQL Stored Procedure Programming Optimizing Oracle Performance The Relational Database Dictionary SQL Cookbook™ SQL Tuning Understanding the Linux Kernel oreilly.com oreilly.com is more than a complete catalog of O’Reilly books. You’ll also find links to news, events, articles, weblogs, sample chapters, and code examples. oreillynet.com is the essential portal for developers interested in open and emerging technologies, including new platforms, pro- gramming languages, and operating systems. Conferences O’Reilly brings diverse innovators together to nurture the ideas that spark revolutionary industries. We specialize in document- ing the latest tools and systems, translating the innovator’s knowledge into useful skills for those in the trenches. Visit conferences.oreilly.com for our upcoming events. Safari Bookshelf (safari.oreilly.com) is the premier online refer- ence library for programmers and IT professionals. Conduct searches across more than 1,000 books. Subscribers can zero in on answers to time-critical questions in a matter of seconds. Read the books on your Bookshelf from cover to cover or sim- ply flip to the page you need. Try it today for free.
Understanding MySQL Internals Sasha Pachev Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo
Understanding MySQL Internals by Sasha Pachev Copyright © 2007 O’Reilly Media, Inc. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com. Editor: Andy Oram Production Editor: Rachel Monaghan Copyeditor: Derek Di Matteo Proofreader: Rachel Monaghan Printing History: April 2007: First Edition. Indexer: Johnna VanHoose Dinse Cover Designer: Karen Montgomery Interior Designer: David Futato Illustrators: Robert Romano and Jessamyn Read Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Understanding MySQL Internals, the image of a banded broadbill, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. This book uses RepKover™, a durable and flexible lay-flat binding. ISBN-10: 0-596-00957-7 ISBN-13: 978-0-596-00957-1 [C]
This book is dedicated to my wife, Sarah, and my children Benjamin, Jennifer, Julia, Joseph, and Jacob.
Table of Contents Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi 1. MySQL History and Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 4 MySQL History MySQL Architecture 2. Nuts and Bolts of Working with the MySQL Source Code . . . . . . . . . . . . . . . . 19 19 19 22 24 25 26 27 28 29 30 33 34 36 37 39 40 Unix Shell BitKeeper Preparing the System to Build MySQL from BitKeeper Tree Building MySQL from BitKeeper Tree Building from Source Distribution Installing MySQL into a System Directory Source Code Directory Layout Preparing the System to Run MySQL in a Debugger Debugger-Guided Source Tour Basics of Working with gdb Finding Things in the Source Interesting Breakpoints and Variables Making a Source Modification Coding Guidelines Keeping Your BitKeeper Repository Up to Date Submitting a Patch vii
分享到:
收藏