The document discusses covering indexes and provides examples of how they can improve query performance. A covering index contains all the columns needed to satisfy a query, avoiding the need to access table data stored on disk. Case studies show how adding a covering composite index on (subscription, name) improved a query to retrieve names by subscription date and order by name from over 3 seconds to under 0.01 seconds. Covering indexes are very beneficial for I/O-bound workloads by reducing disk access.
For more classes visit
www.snaptutorial.com
1. (TCO 1) Most DBMS are referred to as _____________database management systems. (Points : 4)
elemental
linked
hierarchical
relational
2. (TCO 1) A relational DBMS provides protection of the _______________________ through security, control, and recovery facilities. (Points : 4)
user
network
system
database
3. (TCO 2) If a foreign key contains either matching values or nulls, the table(s) that make use of such a foreign key is/are said to exhibit __________ integrity. (Points : 4)
For more classes visit
www.snaptutorial.com
1. (TCO 1) Most DBMS are referred to as _____________database management systems. (Points : 4)
elemental
linked
hierarchical
relational
2. (TCO 1) A relational DBMS provides protection of the _______________________ through security, control, and recovery facilities. (Points : 4)
user
network
system
database
3. (TCO 2) If a foreign key contains either matching values or nulls, the table(s) that make use of such a foreign key is/are said to exhibit __________ integrity. (Points : 4)
For more course tutorials visit
uophelp.com is now newtonhelp.com
www.newtonhelp.com
For what reason do commentators need to think about the internal controls of the affiliation? What are some key segments of inside control? Which are the most fundamental? In what way will the overseer need to modify the survey program if the inside controls are viewed as inadequate to help organization articulations?
Advanced MySQL Query Tuning - talk at Percona Live and MySQL Meetup tour.
Tuning Queries and Schema/Indexes can significantly increase performance of your application and decrease response times.
This year I will cover new MySQL 5.6 and 5.7 algorithms that has been designed to improve query performance and simply tuning.
Topics:
1. Group by and order by optimizations
2. MySQL temporary tables and filesort
3. Using covered indexes to optimize your queries
4. Loose and tight index scan in MySQL
5. Using summary tables to optimize your reporting queries
6. New MySQL 5.6 and 5.7 Optimizer features and improvements
SQL (Basic to Intermediate Customized 8 Hours)Edu4Sure
We covered some topics of Basic to Intermediate level SQL. It was 8 hours customized plan for a corporate client. Stay here for updated content and Videos.
A practical demonstration was given to the learners.
For any query/ training, please feel free to connect at partner@edu4sure.com / call or whatsapp at +91-9555115533.
Visit https://edu4sure.com/certificate-courses for more certificate training program
Introduction to SQL (for Chicago Booth MBA technology club)Jennifer Berk
Introduction to SQL for MBA students, presented spring 2012 to the Chicago Booth technology club.
Why an MBA would want to know SQL, a sandbox to practice in, and the basics of SQL syntax so you can pull your own datasets to analyze.
Presentation about the new features and improvements in MySQL 5.5. Held at the SAPO CodeBits on 2010-11-11. A video recording of the session can be found here: http://codebits.eu/intra/s/session/144
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...Dave Stokes
MySQL is on the way and this presentation covers the new features, improved performance, and better admin that will come with 5.7. But there are some things that are changing that you need to know before you upgrade
For more course tutorials visit
uophelp.com is now newtonhelp.com
www.newtonhelp.com
For what reason do commentators need to think about the internal controls of the affiliation? What are some key segments of inside control? Which are the most fundamental? In what way will the overseer need to modify the survey program if the inside controls are viewed as inadequate to help organization articulations?
Advanced MySQL Query Tuning - talk at Percona Live and MySQL Meetup tour.
Tuning Queries and Schema/Indexes can significantly increase performance of your application and decrease response times.
This year I will cover new MySQL 5.6 and 5.7 algorithms that has been designed to improve query performance and simply tuning.
Topics:
1. Group by and order by optimizations
2. MySQL temporary tables and filesort
3. Using covered indexes to optimize your queries
4. Loose and tight index scan in MySQL
5. Using summary tables to optimize your reporting queries
6. New MySQL 5.6 and 5.7 Optimizer features and improvements
SQL (Basic to Intermediate Customized 8 Hours)Edu4Sure
We covered some topics of Basic to Intermediate level SQL. It was 8 hours customized plan for a corporate client. Stay here for updated content and Videos.
A practical demonstration was given to the learners.
For any query/ training, please feel free to connect at partner@edu4sure.com / call or whatsapp at +91-9555115533.
Visit https://edu4sure.com/certificate-courses for more certificate training program
Introduction to SQL (for Chicago Booth MBA technology club)Jennifer Berk
Introduction to SQL for MBA students, presented spring 2012 to the Chicago Booth technology club.
Why an MBA would want to know SQL, a sandbox to practice in, and the basics of SQL syntax so you can pull your own datasets to analyze.
Presentation about the new features and improvements in MySQL 5.5. Held at the SAPO CodeBits on 2010-11-11. A video recording of the session can be found here: http://codebits.eu/intra/s/session/144
MySQL 5.7 NEW FEATURES, BETTER PERFORMANCE, AND THINGS THAT WILL BREAK -- Mid...Dave Stokes
MySQL is on the way and this presentation covers the new features, improved performance, and better admin that will come with 5.7. But there are some things that are changing that you need to know before you upgrade
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Jaime Crespo
Tutorial delivered at Percona MySQL Conference Live London 2013.
It doesn't matter what new SSD technologies appear, or what are the latest breakthroughs in flushing algorithms: the number one cause for MySQL applications being slow is poor execution plan of SQL queries. While the latest GA version provided a huge amount of transparent optimizations -specially for JOINS and subqueries- it is still the developer's responsibility to take advantage of all new MySQL 5.6 features.
In this tutorial we will propose the attendants a sample PHP application with bad response time. Through practical examples, we will suggest step-by-step strategies to improve its performance, including:
* Checking MySQL & InnoDB configuration
* Internal (performance_schema) and external tools for profiling (pt-query-digest)
* New EXPLAIN tools
* Simple and multiple column indexing
* Covering index technique
* Index condition pushdown
* Batch key access
* Subquery optimization
MariaDB Galera Cluster Webinar by Ivan Zoratti on 13.11.2013. Also available as on demand webinar at http://www.skysql.com/why-skysql/webinars/mariadb-galera-cluster-simple-transparent-highly-available
Magnus Hagander
PostgreSQL supports several options for securing communications when deployed outside the typical webserver/database combination. This talk will go into some details about the features that make this possible, with some extra focus on the changes in 8.4. The main areas discussed are:
* Securing the channel between client and server using SSL, including an overview of the threats and how to secure against them
* Securing the login process, using LDAP, Kerberos or SSL certificates, including the use of smartcards to log into the database
The talk will not focus on security and access control inside the database once the user is connected and authenticated.
MySQL users commonly ask: Here's my table, what indexes do I need? Why aren't my indexes helping me? Don't indexes cause overhead? This talk gives you some practical answers, with a step by step method for finding the queries you need to optimize, and choosing the best indexes for them.
Security Best Practices for your Postgres DeploymentPGConf APAC
These slides were used by Sameer Kumar of Ashnik for presenting his topic at pgDay Asia 2016. He took audience through some of the security best practices for deploying and hardening PostgreSQL
HBaseCon 2012 | HBase Schema Design - Ian Varley, SalesforceCloudera, Inc.
Most developers are familiar with the topic of “database design”. In the relational world, normalization is the name of the game. How do things change when you’re working with a scalable, distributed, non-SQL database like HBase? This talk will cover the basics of HBase schema design at a high level and give several common patterns and examples of real-world schemas to solve interesting problems. The storage and data access architecture of HBase (row keys, column families, etc.) will be explained, along with the pros and cons of different schema decisions.
MySQL Indexing : Improving Query Performance Using Index (Covering Index)Hemant Kumar Singh
Query performance can be enhanced by a major factor if Database Indexed are used properly. The main aim of this slide was to explain the benefits of Covering Index, but ended up writing everything I knew.
Here is the summary of what I have covered in this slide:-
1. What affects Database performance
2. What is Database Index
3. Types Of Database Index
4. Column Index
5. Composite Index
6. Covering Index
7. Indexing Guidelines
It would be interesting to know these as well -
Best practices for Indexing in Database(RDBMS)
Best practices for Indexing in MySQL
Best practices for Indexing in PostgreSQL
Best practices for Database Modeling
Best practices for SQL Query Construction
Performance impact of Indexing on Query Performance
Performance impact of Indexing on INSERT Queries
Consolidate all these knowledge and you should be happy to see the overall performance gain in your SQL Query and hence overall application will run faster.
Talk at "Istanbul Tech Talks" in Istanbul, April, 17, 2018. http://www.istanbultechtalks.com/
In this talk I will show how to get started with MySQL Query Tuning. I will make short introduction into physical table structure and demonstrate how it may influence query execution time. Then we will discuss basic query tuning instruments and techniques, mainly EXPLAIN command with its latest variations. You will learn how to understand its output and how to rewrite query or change table structure to achieve better performance.
Percona Live 2016 (https://www.percona.com/live/data-performance-conference-2016/sessions/why-use-explain-formatjson). Although EXPLAIN FORMAT=JSON was first presented a long time ago, there still aren't many resources that explain how and why to use it. The most advertised feature is visual EXPLAIN in MySQL Workbench, but this format can do more than create nice pictures. It prints additional information that can't be found in good old tabular EXPLAIN, and can help to solve many tricky performance issues. In this session, I will not only describe which additional information we can get with the new syntax, but also provide examples showing how to use it to diagnose production issues.
Pagination is common pattern for most web based applications, most often developers use LIMIT OFFSET, NUMBER mysql specific sql to paginate and get very slow response as user paginate to deep pages.
In this talk Surat Singh Bhati & Rick James are going to share efficient MySQL queries to paginate through large data set.
Advanced MariaDB features that developers love.pdfFederico Razzoli
MariaDB is one of the most widely used relational databases. It is compatible with MySQL for most practical purposes, and it is appreciated by developers communities all over the world.
Over the years, MariaDB has developed many features that are extremely useful for developers, saving a lot of development time and enabling its use in situations where it wouldn't be practical otherwise.
In this talk, we'll briefly discuss some of those features and why they are so useful. We'll talk about:
* Querying remote or heterogeneous data sources in SQL;
* Using temporal tables to analyse how data changes over time;
* Using JSON in a relational database;
* Miscellaneous tips and tricks.
15 Ways to Kill Your Mysql Application Performanceguest9912e5
Jay is the North American Community Relations Manager at MySQL. Author of Pro MySQL, Jay has also written articles for Linux Magazine and regularly assists software developers in identifying how to make the most effective use of MySQL. He has given sessions on performance tuning at the MySQL Users Conference, RedHat Summit, NY PHP Conference, OSCON and Ohio LinuxFest, among others.In his abundant free time, when not being pestered by his two needy cats and two noisy dogs, he daydreams in PHP code and ponders the ramifications of __clone().
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
UiPath Test Automation using UiPath Test Suite series, part 5DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 5. In this session, we will cover CI/CD with devops.
Topics covered:
CI/CD with in UiPath
End-to-end overview of CI/CD pipeline with Azure devops
Speaker:
Lyndsey Byblow, Test Suite Sales Engineer @ UiPath, Inc.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
2. Indexing basics
Data structure intended to speed up SELECTs
Similar to an index in a book
Overhead for every write
● Usually negligeable / speed up for SELECT
Possibility to have one index for several columns
5. BTree indexes
All leaves at the same distance from the root
Efficient insertions, deletions
Values are sorted
B+Trees
● Efficient range scans
● Values stored in the leaves
6. BTree indexes
Ok for most kinds of lookups:
● Exact full value (= xxx)
● Range of values (BETWEEN xx AND yy)
● Column prefix (LIKE 'xx%')
● Leftmost prefix
Ok for sorting too
But
● Not useful for 'LIKE %xxx' or LIKE '%xx%'
● You can't skip columns
7. Hash indexes
Hash table with hash and pointer to row
Drawbacks
● Useful only for exact lookups (=, IN)
● Not supported by InnoDB or MyISAM
Benefits
● Very fast
● Compact
8. R-Tree and T-Tree indexes
R-Tree Indexes
● Same principle as B-Tree indexes
● Used for spatial indexes
● Requires the use of GIS functions
● MyISAM only
T-Tree indexes
● Same principle as B-Tree indexes
● Specialized for in-memory storage engines
● Used in NDB Cluster
13. Different methods to access data
Disk : cheap but slow
● ~ 100 random I/O ops/s
● ~ 500,000 sequential I/O ops/s
RAM : quick but expensive
● ~ 250,000 random accesses/s
● ~ 5,000,000 sequential accesses/s
Remember :
● Disks are extremely slow for random accesses
● Not much difference for sequential accesses
15. Index-covered queries
When performance problems occur:
● Add indexes
● Rewrite your queries
● Or both
Do you need to fetch data (often on disk) ?
If the index contains the data, you don't
If you don't, your query is covered by an index (=index-
only query)
16. Index-covered queries
Query with traditional index:
● Get right rows with index
● Get data from rows
● Send data back to client
Index-covered query:
● Get right rows with index
● Get data from rows
● Send data back to client
17. Covering index and EXPLAIN
mysql> EXPLAIN SELECT ID FROM world.CityG
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: City
type: index
possible_keys: NULL
key: PRIMARY
key_len: 4
ref: NULL
rows: 4079
Extra: Using index
18. Advantages of a covering index
No access to the rows anymore !
Indexes smaller and easier to cache than data
Indexes sorted by values: random access can become
sequential access
Additional trick with InnoDB (more later)
=> Covering indexes are very beneficial for I/O bound
workloads
19. When you can't use a covering idx
SELECT *
Indexes that don't store the values:
● Indexes different from BTree indexes
● BTree indexes with MEMORY tables
● Indexes on a column's prefix
21. A case study
CREATE TABLE `customer` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL DEFAULT '',
`age` tinyint(4) DEFAULT NULL,
`subscription` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM
Name of people who subscribed on 2009-01-01 ?
We want this list to be sorted by name
22. The naïve way
mysql> EXPLAIN SELECT name FROM customer
WHERE subscription='2009-01-01' ORDER BY name
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: customer
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 5000000
Extra: Using where; Using filesort
23. First try ...
mysql> ALTER TABLE customer ADD INDEX idx_name
(name)
mysql> EXPLAIN SELECT name FROM customer
WHERE subscription='2009-01-01' ORDER BY name
*************************** 1. row ***************************
...
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 5000000
Extra: Using where; Using filesort
24. Better ...
mysql> ALTER TABLE customer ADD INDEX idx_sub
(subscription)
mysql> EXPLAIN SELECT name FROM customer
WHERE subscription='2009-01-01' ORDER BY name
*************************** 1. row ***************************
...
type: ref
key: idx_sub
rows: 4370
Extra: Using where; Using filesort
25. The ideal way
mysql> ALTER TABLE customer ADD INDEX
idx_sub_name (subscription,name)
mysql> EXPLAIN SELECT name FROM customer
WHERE subscription='2009-01-01' ORDER BY name
*************************** 1. row ***************************
...
type: ref
key: idx_sub_name
rows: 4363
Extra: Using where; Using index
26. Benchmarks
Avg number of sec to run the query
● Without index: 3.743
● Index on subscription: 0.435
● Covering index: 0.012
Covering index
● 35x faster than index on subscription
● 300x faster than full table scan
27. Even better for MyISAM
We can keep the covering index in memory
mysql> SET GLOBAL
customer_cache.key_buffer_size = 130000000;
mysql> CACHE INDEX customer IN customer_cache;
mysql> LOAD INDEX INTO CACHE customer;
Avg number of sec to run the query: 0.007
This step is specific to MyISAM !
28. Even better for InnoDB
InnoDB secondary keys hold primary key values
mysql> EXPLAIN SELECT name,id FROM customer
WHERE subscription='2009-01-01' ORDER BY name
*************************** 1. row ***************************
possible_keys: idx_sub_name
key: idx_sub_name
Extra: Using where; Using index
29. Another (harder) case study
Same table : customer
List people who subscribed on 2009-01-01 AND
whose name ends up with xx ?
SELECT * FROM customer WHERE
subscription='2009-01-01' AND name LIKE '%xx'
Let's add an index on (subscription,name) ...
30. Another (harder) case study
mysql> EXPLAIN SELECT * FROM customer WHERE
subscription='2009-01-01' AND name LIKE '%xx'
*************************** 1. row ***************************
...
key: idx_sub_name
key_len: 3
ref: const
rows: 500272
Extra: Using where
The index is not covering anymore
31. Query rewriting - Indexing
Rewriting the query
SELECT * FROM customer
INNER JOIN (
SELECT id FROM customer
WHERE subscription='2009-01-01'
AND name LIKE '%xx'
) AS t USING(id)
Adding an index
ALTER TABLE customer ADD INDEX
idx_sub_name_id (subscription,name,id)
33. Efficiency of the optimization
Beware of the subquery
10 subs./3 names with %xx
● Original query: 0.000 s
● Rewritten query: 0.000 s
300,000 subs./500 names with %xx
● Original query: 1.284 s
● Rewritten query: 0.553 s
Many intermediate situations
Always benchmark !
34. InnoDB ?
The index on (subscription,name) is already covering
for the subquery
Your work is easier: just rewrite the query if need be
But you still need to benchmark