Escolar Documentos
Profissional Documentos
Cultura Documentos
Agenda
Architecture of Database-related
Performance vs Architecture
Datastore
Relational Databases
MySQL
Caching
Put a cache in front of your database
Distribute Write-through for scaling reads Write-back for scaling reads and writes
Cache tier
Principles
Nothings perfect but some solutions are good enough for a while Scalability involve partitioning, indexing and replication
All data for real-time queries MUST be in memory. Disk is for writes only
Replication
Master - Slave
Only scaling reads
Master - Master
Scaling reads and writes but many limits
Functional Segmentation
Segment databases into functional areas
User
Feed Comment Attention Fans
Horizontal Split
Hash
Range
Lookup table Middle layer
Minimize Database
No business logic
No distributed transactions
No joins and sorting
Schema Design
Oracle RAC NO GO
NoSQL DB
The Schema
Best stage for optimize performance
Data type
Small is usually better
Index
Over indexing can be an overhead
On multiple column indexes the order fields within the index definition is important
Poor indexes are same as not having any indexes Good selectivity on index fields
Storage Engine
Understanding benefits and drawbacks of each storage engine Different storage engine has different index capability
Optimization Access
Thinking in Access
Any interaction with the database are the high cost Decrease data access is better than SQL tuning
Combining statements
Fetching all you need at once
REPLACE
INSERT IGNORE
Parallelism
Reorganizing processing
Q&A
@jackbillow
20111020~22
www.qconhangzhou.com6
QCon
www.qconbeijing.com