SlideShare une entreprise Scribd logo
1  sur  52
Télécharger pour lire hors ligne
MySQL Anti-Queries
and Sphinx Search
Percona Live, MySQL Users Conference
Santa Clara, 2013
PALOMINODB
OPERATIONAL EXCELLENCE
FOR DATABASES
Vlad Fedorkov
www.palominodb.com
Let’s meet each other
• Performance geek
• Working for PalominoDB
o http://www.palominodb.com
• Twitter @vfedorkov
• Now fighting with clouds
What is MySQL
• Database we love
• Database we use
o So sometimes we hate it too
o Depends on how much data you have
• Most important
o Database that improving
 Thanks to Percona, Oracle and MariaDB!
 Special thanks to MySQL community
• Does it work in every case?
MySQL today
• Software
o Can’t complain about concurrency anymore
o Warm up is much-much better today
o Optimizer doing much better now
o Replication is now multi-threaded
• Environment
o Flash storage makes IO very fast and concurrent
o Cheap and fast RAM
o Awesome cloud services available
o Galera, Tungsten, MySQL cluster
What’s wrong with MySQL?
• One-by-one:
o ACID compliance is inconveniently slow
o B-Tree index is not perfect for some queries
o Query execution is single threaded
o Full-text indexes are not that fast
o Replication wants to keep data consistent
o lot more inconvenient things just ask me!
• So maybe some queries are bad, not MySQL
itself?
MySQL as a microscope
• Excellent for specific operations
o Very fast at primary key lookup
o Fast enough on index lookups
 some range scans too
• Makes sure your data is safe
• Optimized for transactional (InnoDB)
workload
Full-table scans
• SELECT * FROM table WHERE myfunc(a) = 5
• SELECT * FROM table WHERE a NOT IN
(1,2,3)
o WHERE a <> 5
• SELECT * FROM table WHERE c LIKE ‘%ing’
• SELECT COUNT(*) FROM …
• Reading the whole table is expensive
• Buffer pool flooded with rarely used data
• Indexes are not helpful
Inefficient index usage
• SELECT * FROM table WHERE enabled=0
o archived, deleted
• SELECT * FROM table WHERE sex=1
o WHERE age_range=5
• SELECT * FROM table WHERE state=CA
o WHERE city=‘New York’
• Better than full-table scan but still inefficient
Some sorting operations
• ORDER BY against non indexed field
• ORDER BY a DESC, b ASC, c DESC
• ORDER BY RAND() ASC
o ORDER BY RAND() DESC works much better
Temporary table operations
• Some operations forces MySQL to create
o In memory table
o On disk table
• Subqueries
• GROUP BY
• DISTINCT + ORDER BY
o If you have TEXT or BLOB field MySQL will create on
disk table at all times
These queries like nails
C’mon, you can do that!!!
… or use something more convenient?
What do we need?
• Avoid full-scans as much as we can
o Make them faster when we can’t get rid of them
• Avoid slow IO operations
o Put most data to memory
 It is cheap now
Let’s meet Sphinx
• Stand alone daemon
o Written in C++ and very fast
• Works without MySQL
o At all
• Can be connected using mysql client
o PHP/Ruby/JDBC/.NET/etc
• Runs on lots of platforms
o Linux/Windows/Mac/everywhere
Sphinx
Pros
• Highly scalable
• Keeps vital data in
memory
• Very fast in scans
• Powerful full-text syntax
• High availability support
Cons (yet)
• Don’t have B-tree indexes
• No out-of-the-box replication
from MySQL
• Not completely ACID
Full-table scans
• Sphinx keeps attributes in memory at all
times
• It scale queries
o Well actually you have to tell how
 But only once
• Limit amount of documents to walk though
• You can utilize Full-Text search power
o As a nice bonus 
Full-Text functions
• And, Or
o hello | world, hello & world
• Not
o hello -world
• Per-field search
o @title hello @body world
• Field combination
o @(title, body) hello world
• Search within first N
o @body[50] hello
• Phrase search
o “hello world”
• Per-field weights
• Proximity search
o “hello world”~10
• Distance support
o hello NEAR/10 world
• Quorum matching
o "the world is a wonderful
place"/3
• Exact form modifier
o “raining =cats and =dogs”
• Strict order
• Sentence / Zone / Paragraph
• Custom documents weighting
& ranking
SphinxQL.
mysql> SELECT id, ...
-> FROM myisam_table
-> WHERE MATCH(title, content_ft)
-> AGAINST ('I love sphinx') LIMIT 10;
...
10 rows in set (1.18 sec)
mysql> SELECT * FROM sphinx_index
-> WHERE MATCH('I love Sphinx') LIMIT 10;
...
10 rows in set (0.05 sec)
MySQL
Sphinx
Just like MySQL
$ mysql -h 0 -P 9306
Welcome to the MySQL monitor. Commands
end with ; or g.
Your MySQL connection id is 1
Server version: 2.1.0-id64-dev (r3028)
Type 'help;' or 'h' for help. Type 'c'
to clear the current input statement.
mysql>
What is SphinxQL?
• SQL-based query language in Sphinx
• Works without MySQL!
o MySQL client library required
 JDCB, .NET, PHP, Ruby
• Required different port
• Almost same syntax as in MySQL
o But not exactly the same
SQL & SphinxQL
● WITHIN GROUP ORDER BY
● OPTION support for fine tuning
● weights, matches and query time control
● SHOW META query information
● CALL SNIPPETS let you create snippets
● CALL KEYWORDS for statistics
Extended syntax
mysql> SELECT …, YEAR(ts) as yr
-> FROM sphinx_index
-> WHERE MATCH('I love Sphinx')
-> GROUP BY yr
-> WITHIN GROUP ORDER BY rating DESC
-> ORDER BY yr DESC
-> LIMIT 5
-> OPTION field_weights=(title=100, content=1);
+---------+--------+------------+------------+------+----------+--------+
| id | weight | channel_id | ts | yr | @groupby | @count |
+---------+--------+------------+------------+------+----------+--------+
| 7637682 | 101652 | 358842 | 1112905663 | 2005 | 2005 | 14 |
| 6598265 | 101612 | 454928 | 1102858275 | 2004 | 2004 | 27 |
| 7139960 | 1642 | 403287 | 1070220903 | 2003 | 2003 | 8 |
| 5340114 | 1612 | 537694 | 1020213442 | 2002 | 2002 | 1 |
| 5744405 | 1588 | 507895 | 995415111 | 2001 | 2001 | 1 |
+---------+--------+------------+------------+------+----------+--------+
5 rows in set (0.00 sec)
GEO-Distance support
• Bumping up local results
o Requires coordinates for each document
o Two pairs of float values (Latitude, Longitude)
• GEODIST(Lat, Long, Lat2, Long2) in Sphinx
SELECT *, GEODIST(docs_lat, doc_long, %d1, %d2) as dist,
FROM sphinx_index
ORDER BY dist DESC
LIMIT 0, 20
Range support
• Price ranges (items, offers)
• Date range (blog posts and news articles)
• Ratings, review points
• INTERVAL(field, x0, x1, …, xN)
SELECT
INTERVAL(item_price, 0, 20, 50, 90) as range,
@count
FROM my_sphinx_products
GROUP BY range
ORDER BY range ASC;
Extended services
• Drill-down (narrow search, faceted search)
• Typos correction
• Search string autocompletion
• Related documents
Misspells correction service
• Provides correct search phrase
o “Did you mean” service
• Allows to replace user’s search on the fly
o if we’re sure it’s a typo
 “ophone”, “uphone”, etc
o Saves time and makes website look smart
• Based on your actual database
o Effective if you DO have correct words in index
Autocompletion service
• Suggest search queries as user types
o Show most popular queries
o Promote searches that leads to desired pages
o Might include misspells correction
Related search
• Improving visitor experience
o Providing easier access to useful pages
o Keep customer on the website
o Increasing sales and server’s load average
• Based on documents similarity
o Different for shopping items and texts
o Ends up in data mining
Excerpts (snippets)
• BuildExcerpts() or CALL SNIPPETS
• Options
o before_match (<b>)
o after_match (</b>)
o chunk_separator (…)
o limit
o around
o force_all_words
Installation: How?
● From binary packages
● http://sphinxsearch.com/downloads/
● From source
● http://sphinxsearch.googlecode.com/svn/
● configure && make && make install
– Make sure to use --enable-id64
– for huge document collection
– already included in pre-compiled packages
Architecture sample
Initial configuration: indexing
• Where to look for data?
• How to process it?
• Where to store index?
Where to look for the data?
● MySQL
● PostgreSQL
● MSSQL
● ODBC source
● XML pipe
MySQL source
source data_source
{
…
sql_query = 
SELECT id, channel_id, ts, title,
content 
FROM mytable
sql_attr_uint = channel_id
sql_attr_timestamp = ts
…
}
A complete version
source data_source
{
type = mysql
sql_host = localhost
sql_user = my_user
sql_pass = my******
sql_db = test
sql_query_pre = SET NAMES utf8
sql_query = SELECT id, channel_id, ts, title, content 
FROM mytable 
WHERE id>=$start and id<=$end
sql_attr_uint = channel_id
sql_attr_timestamp = ts
sql_query_range = SELECT MIN(id), MAX(id) FROM mytable
sql_range_step = 1000
}
How to process. Index config.
index my_sphinx_index
{
source = data_source
path = /my/index/path/idx
html_strip = 1
morphology = stem_en
stopwords = stopwords.txt
charset_type = utf-8
}
Indexer configuration
indexer
{
mem_limit = 512M
max_iops = 40
max_iosize = 1048576
}
Running indexer
$ ./indexer my_sphinx_index
Sphinx 2.0.2-dev (r2824)
Copyright (c) 2001-2010, Andrew Aksyonoff
Copyright (c) 2008-2010, Sphinx Technologies Inc (http://sph...
using config file './sphinx.conf'...
indexing index 'my_sphinx_index'...
collected 999944 docs, 1318.1 MB
sorted 224.2 Mhits, 100.0% done
total 999944 docs, 1318101119 bytes
total 158.080 sec, 8338160 bytes/sec, 6325.53 docs/sec
total 33 reads, 4.671 sec, 17032.9 kb/call avg, 141.5 msec/call
total 361 writes, 20.889 sec, 3566.1 kb/call avg, 57.8 msec/call
Index files
$ ls -lah idx*
-rw-r--r-- 1 vlad vlad 12M 2010-12-22 09:01 idx.spa
-rw-r--r-- 1 vlad vlad 334M 2010-12-22 09:01 idx.spd
-rw-r--r-- 1 vlad vlad 438 2010-12-22 09:01 idx.sph
-rw-r--r-- 1 vlad vlad 13M 2010-12-22 09:01 idx.spi
-rw-r--r-- 1 vlad vlad 0 2010-12-22 09:01 idx.spk
-rw-r--r-- 1 vlad vlad 0 2011-05-13 09:25 idx.spl
-rw-r--r-- 1 vlad vlad 0 2010-12-22 09:01 idx.spm
-rw-r--r-- 1 vlad vlad 111M 2010-12-22 09:01 idx.spp
-rw-r--r-- 1 vlad vlad 1 2010-12-22 09:01 idx.sps
$
Next Steps
• Run the daemon
• Connect to daemon
• Run search query
Configuring searchd
searchd
{
listen = localhost:9312
listen = localhost:9306:mysql4
query_log = query.log
query_log_format = sphinxql
pid_file = searchd.pid
}
Running sphinx daemon!
$ ../bin/searchd -c sphinx.conf
Sphinx 2.0.2-dev (r2824)
Copyright (c) 2001-2010, Andrew Aksyonoff
Copyright (c) 2008-2010, Sphinx Technologies
Inc (http://sphinxsearch.com)
using config file 'sphinx.conf'...
listening on 127.0.0.1:9312
listening on 127.0.0.1:9306
precaching index ‘idx'
precached 1 indexes in 0.028 sec
Connecting to Sphinx
• Sphinx API
o PHP, Python, Java, Ruby, C is included in distro
o .NET, Rails (via Thinking Sphinx) via third party libs
• SphinxQL
o MySQL-compatible protocol
• SphinxSE
o Storage engine for MySQL
Sphinx applications
• Find relevant documents
o Items in store(s)
o Articles in blog/forum/news/etc website(s)
o Pictures or photos
 By text, description, GEO-data, publish time, etc
o Friends
 In social networks or dating websites
• Offload main database from heavy queries
• Build advanced search and search-based
services
Another way to speed up is scaling
• Combine diffrent indexes
o Main + Delta
o Ondisk + RT
o Distributed and local
 Don't forget about dist_threads!
• Use parallel indexing
OnDisk indexes
Bright side of scaling
• Faster search
• Better load control
• Hardware utilization
• High availability
Dark side
• Hardware faults
• Network issues
• Balancing issues
o Search time related to slowest search chunk
• Complicated operations
ToDo for attendees
• Please rate this talk!
• Submit your feedback to @vfedorkov
• Visit PalominoDB booth!
• Andrew Aksenoff’s talk about new Sphinx
features, don’t miss it.
o Tomorrow, 4:30pm - 5:20pm @ Ballroom E
• Questions!
Thank you!
Twitter @vfedorkov
Website: http://palominodb.com

Contenu connexe

Tendances

SearchHub - How to Spend Your Summer Keeping it Real: Presented by Grant Inge...
SearchHub - How to Spend Your Summer Keeping it Real: Presented by Grant Inge...SearchHub - How to Spend Your Summer Keeping it Real: Presented by Grant Inge...
SearchHub - How to Spend Your Summer Keeping it Real: Presented by Grant Inge...Lucidworks
 
Gizzard, DAL and more
Gizzard, DAL and moreGizzard, DAL and more
Gizzard, DAL and morefulin tang
 
Apache Solr - Enterprise search platform
Apache Solr - Enterprise search platformApache Solr - Enterprise search platform
Apache Solr - Enterprise search platformTommaso Teofili
 
Finite State Queries In Lucene
Finite State Queries In LuceneFinite State Queries In Lucene
Finite State Queries In Luceneotisg
 
Flexible search in Apache Jackrabbit Oak
Flexible search in Apache Jackrabbit OakFlexible search in Apache Jackrabbit Oak
Flexible search in Apache Jackrabbit OakTommaso Teofili
 
Not Just ORM: Powerful Hibernate ORM Features and Capabilities
Not Just ORM: Powerful Hibernate ORM Features and CapabilitiesNot Just ORM: Powerful Hibernate ORM Features and Capabilities
Not Just ORM: Powerful Hibernate ORM Features and CapabilitiesBrett Meyer
 
Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Colin Charles
 
Cassandra and Clojure
Cassandra and ClojureCassandra and Clojure
Cassandra and Clojurenickmbailey
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP LondonRicard Clau
 
Introduction to Apache solr
Introduction to Apache solrIntroduction to Apache solr
Introduction to Apache solrKnoldus Inc.
 
Rails 6 Multi-DB 実戦投入
Rails 6 Multi-DB 実戦投入Rails 6 Multi-DB 実戦投入
Rails 6 Multi-DB 実戦投入kiyots
 
Databases in the hosted cloud
Databases in the hosted cloudDatabases in the hosted cloud
Databases in the hosted cloudColin Charles
 
Cloudera - Using morphlines for on the-fly ETL by Wolfgang Hoschek
Cloudera - Using morphlines for on the-fly ETL by Wolfgang HoschekCloudera - Using morphlines for on the-fly ETL by Wolfgang Hoschek
Cloudera - Using morphlines for on the-fly ETL by Wolfgang HoschekHakka Labs
 
Solr Indexing and Analysis Tricks
Solr Indexing and Analysis TricksSolr Indexing and Analysis Tricks
Solr Indexing and Analysis TricksErik Hatcher
 
Day 2 - Intro to Rails
Day 2 - Intro to RailsDay 2 - Intro to Rails
Day 2 - Intro to RailsBarry Jones
 
Elastic search apache_solr
Elastic search apache_solrElastic search apache_solr
Elastic search apache_solrmacrochen
 
You know, for search. Querying 24 Billion Documents in 900ms
You know, for search. Querying 24 Billion Documents in 900msYou know, for search. Querying 24 Billion Documents in 900ms
You know, for search. Querying 24 Billion Documents in 900msJodok Batlogg
 
DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + ThymeleafDSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + ThymeleafTim Donohue
 
Apache Solr Workshop
Apache Solr WorkshopApache Solr Workshop
Apache Solr WorkshopJSGB
 

Tendances (20)

SearchHub - How to Spend Your Summer Keeping it Real: Presented by Grant Inge...
SearchHub - How to Spend Your Summer Keeping it Real: Presented by Grant Inge...SearchHub - How to Spend Your Summer Keeping it Real: Presented by Grant Inge...
SearchHub - How to Spend Your Summer Keeping it Real: Presented by Grant Inge...
 
Gizzard, DAL and more
Gizzard, DAL and moreGizzard, DAL and more
Gizzard, DAL and more
 
Apache Solr - Enterprise search platform
Apache Solr - Enterprise search platformApache Solr - Enterprise search platform
Apache Solr - Enterprise search platform
 
Finite State Queries In Lucene
Finite State Queries In LuceneFinite State Queries In Lucene
Finite State Queries In Lucene
 
Flexible search in Apache Jackrabbit Oak
Flexible search in Apache Jackrabbit OakFlexible search in Apache Jackrabbit Oak
Flexible search in Apache Jackrabbit Oak
 
Not Just ORM: Powerful Hibernate ORM Features and Capabilities
Not Just ORM: Powerful Hibernate ORM Features and CapabilitiesNot Just ORM: Powerful Hibernate ORM Features and Capabilities
Not Just ORM: Powerful Hibernate ORM Features and Capabilities
 
Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016Tuning Linux for your database FLOSSUK 2016
Tuning Linux for your database FLOSSUK 2016
 
Cassandra and Clojure
Cassandra and ClojureCassandra and Clojure
Cassandra and Clojure
 
Redis everywhere - PHP London
Redis everywhere - PHP LondonRedis everywhere - PHP London
Redis everywhere - PHP London
 
Introduction to Apache solr
Introduction to Apache solrIntroduction to Apache solr
Introduction to Apache solr
 
Rails 6 Multi-DB 実戦投入
Rails 6 Multi-DB 実戦投入Rails 6 Multi-DB 実戦投入
Rails 6 Multi-DB 実戦投入
 
Databases in the hosted cloud
Databases in the hosted cloudDatabases in the hosted cloud
Databases in the hosted cloud
 
Cloudera - Using morphlines for on the-fly ETL by Wolfgang Hoschek
Cloudera - Using morphlines for on the-fly ETL by Wolfgang HoschekCloudera - Using morphlines for on the-fly ETL by Wolfgang Hoschek
Cloudera - Using morphlines for on the-fly ETL by Wolfgang Hoschek
 
Solr Indexing and Analysis Tricks
Solr Indexing and Analysis TricksSolr Indexing and Analysis Tricks
Solr Indexing and Analysis Tricks
 
Day 2 - Intro to Rails
Day 2 - Intro to RailsDay 2 - Intro to Rails
Day 2 - Intro to Rails
 
Elastic search apache_solr
Elastic search apache_solrElastic search apache_solr
Elastic search apache_solr
 
You know, for search. Querying 24 Billion Documents in 900ms
You know, for search. Querying 24 Billion Documents in 900msYou know, for search. Querying 24 Billion Documents in 900ms
You know, for search. Querying 24 Billion Documents in 900ms
 
Day 4 - Models
Day 4 - ModelsDay 4 - Models
Day 4 - Models
 
DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + ThymeleafDSpace UI Prototype Challenge: Spring Boot + Thymeleaf
DSpace UI Prototype Challenge: Spring Boot + Thymeleaf
 
Apache Solr Workshop
Apache Solr WorkshopApache Solr Workshop
Apache Solr Workshop
 

En vedette

Advanced fulltext search with Sphinx
Advanced fulltext search with SphinxAdvanced fulltext search with Sphinx
Advanced fulltext search with SphinxAdrian Nuta
 
Real time fulltext search with sphinx
Real time fulltext search with sphinxReal time fulltext search with sphinx
Real time fulltext search with sphinxAdrian Nuta
 
Zurich2007 MySQL Query Optimization
Zurich2007 MySQL Query OptimizationZurich2007 MySQL Query Optimization
Zurich2007 MySQL Query OptimizationHiệp Lê Tuấn
 
Advanced MySQL Query Tuning
Advanced MySQL Query TuningAdvanced MySQL Query Tuning
Advanced MySQL Query TuningAlexander Rubin
 
Building High Performance MySql Query Systems And Analytic Applications
Building High Performance MySql Query Systems And Analytic ApplicationsBuilding High Performance MySql Query Systems And Analytic Applications
Building High Performance MySql Query Systems And Analytic Applicationsguest40cda0b
 
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014Dave Stokes
 
56 Query Optimization
56 Query Optimization56 Query Optimization
56 Query OptimizationMYXPLAIN
 
Mysql query optimization
Mysql query optimizationMysql query optimization
Mysql query optimizationBaohua Cai
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksMYXPLAIN
 
Tunning sql query
Tunning sql queryTunning sql query
Tunning sql queryvuhaininh88
 
MySQL Query tuning 101
MySQL Query tuning 101MySQL Query tuning 101
MySQL Query tuning 101Sveta Smirnova
 
Advanced MySQL Query and Schema Tuning
Advanced MySQL Query and Schema TuningAdvanced MySQL Query and Schema Tuning
Advanced MySQL Query and Schema TuningMYXPLAIN
 
MySQL Query Optimization
MySQL Query OptimizationMySQL Query Optimization
MySQL Query OptimizationMorgan Tocker
 
Webinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuningWebinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuning晓 周
 
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Jaime Crespo
 
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricksQuery Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricksJaime Crespo
 
MySQL Query Optimization (Basics)
MySQL Query Optimization (Basics)MySQL Query Optimization (Basics)
MySQL Query Optimization (Basics)Karthik .P.R
 

En vedette (20)

Advanced fulltext search with Sphinx
Advanced fulltext search with SphinxAdvanced fulltext search with Sphinx
Advanced fulltext search with Sphinx
 
Real time fulltext search with sphinx
Real time fulltext search with sphinxReal time fulltext search with sphinx
Real time fulltext search with sphinx
 
Zurich2007 MySQL Query Optimization
Zurich2007 MySQL Query OptimizationZurich2007 MySQL Query Optimization
Zurich2007 MySQL Query Optimization
 
Advanced MySQL Query Tuning
Advanced MySQL Query TuningAdvanced MySQL Query Tuning
Advanced MySQL Query Tuning
 
Building High Performance MySql Query Systems And Analytic Applications
Building High Performance MySql Query Systems And Analytic ApplicationsBuilding High Performance MySql Query Systems And Analytic Applications
Building High Performance MySql Query Systems And Analytic Applications
 
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
MySQL Query Tuning for the Squeemish -- Fossetcon Orlando Sep 2014
 
56 Query Optimization
56 Query Optimization56 Query Optimization
56 Query Optimization
 
Mysql query optimization
Mysql query optimizationMysql query optimization
Mysql query optimization
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New Tricks
 
Tunning sql query
Tunning sql queryTunning sql query
Tunning sql query
 
MySQL Query tuning 101
MySQL Query tuning 101MySQL Query tuning 101
MySQL Query tuning 101
 
Advanced MySQL Query and Schema Tuning
Advanced MySQL Query and Schema TuningAdvanced MySQL Query and Schema Tuning
Advanced MySQL Query and Schema Tuning
 
MySQL Query Optimization
MySQL Query OptimizationMySQL Query Optimization
MySQL Query Optimization
 
My sql optimization
My sql optimizationMy sql optimization
My sql optimization
 
Webinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuningWebinar 2013 advanced_query_tuning
Webinar 2013 advanced_query_tuning
 
MySQL Query Optimization.
MySQL Query Optimization.MySQL Query Optimization.
MySQL Query Optimization.
 
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
Query Optimization with MySQL 5.6: Old and New Tricks - Percona Live London 2013
 
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricksQuery Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
Query Optimization with MySQL 5.7 and MariaDB 10: Even newer tricks
 
MySQL Query Optimization (Basics)
MySQL Query Optimization (Basics)MySQL Query Optimization (Basics)
MySQL Query Optimization (Basics)
 
Sql query patterns, optimized
Sql query patterns, optimizedSql query patterns, optimized
Sql query patterns, optimized
 

Similaire à MYSQL Query Anti-Patterns That Can Be Moved to Sphinx

PostgreSQL - It's kind've a nifty database
PostgreSQL - It's kind've a nifty databasePostgreSQL - It's kind've a nifty database
PostgreSQL - It's kind've a nifty databaseBarry Jones
 
An Introduction to Elastic Search.
An Introduction to Elastic Search.An Introduction to Elastic Search.
An Introduction to Elastic Search.Jurriaan Persyn
 
SQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics
SQL Server 2014 Extreme Transaction Processing (Hekaton) - BasicsSQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics
SQL Server 2014 Extreme Transaction Processing (Hekaton) - BasicsTony Rogerson
 
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails AppSrijan Technologies
 
MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MYXPLAIN
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!Daniel Cousineau
 
My SQL Skills Killed the Server
My SQL Skills Killed the ServerMy SQL Skills Killed the Server
My SQL Skills Killed the ServerdevObjective
 
SQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - AdvancedSQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - AdvancedTony Rogerson
 
An overview of Amazon Athena
An overview of Amazon AthenaAn overview of Amazon Athena
An overview of Amazon AthenaJulien SIMON
 
Search and analyze your data with elasticsearch
Search and analyze your data with elasticsearchSearch and analyze your data with elasticsearch
Search and analyze your data with elasticsearchAnton Udovychenko
 
Alasql JavaScript SQL Database Library: User Manual
Alasql JavaScript SQL Database Library: User ManualAlasql JavaScript SQL Database Library: User Manual
Alasql JavaScript SQL Database Library: User ManualAndrey Gershun
 
MySQL Fulltext Search Tutorial
MySQL Fulltext Search TutorialMySQL Fulltext Search Tutorial
MySQL Fulltext Search TutorialZhaoyang Wang
 
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Michael Rys
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersJonathan Levin
 
Data Engineering with Solr and Spark
Data Engineering with Solr and SparkData Engineering with Solr and Spark
Data Engineering with Solr and SparkLucidworks
 
My Database Skills Killed the Server
My Database Skills Killed the ServerMy Database Skills Killed the Server
My Database Skills Killed the ServerColdFusionConference
 

Similaire à MYSQL Query Anti-Patterns That Can Be Moved to Sphinx (20)

PostgreSQL - It's kind've a nifty database
PostgreSQL - It's kind've a nifty databasePostgreSQL - It's kind've a nifty database
PostgreSQL - It's kind've a nifty database
 
An Introduction to Elastic Search.
An Introduction to Elastic Search.An Introduction to Elastic Search.
An Introduction to Elastic Search.
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 
SQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics
SQL Server 2014 Extreme Transaction Processing (Hekaton) - BasicsSQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics
SQL Server 2014 Extreme Transaction Processing (Hekaton) - Basics
 
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App
[Srijan Wednesday Webinar] Easy Performance Wins for Your Rails App
 
MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6MySQL Indexing - Best practices for MySQL 5.6
MySQL Indexing - Best practices for MySQL 5.6
 
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
NOSQL101, Or: How I Learned To Stop Worrying And Love The Mongo!
 
My SQL Skills Killed the Server
My SQL Skills Killed the ServerMy SQL Skills Killed the Server
My SQL Skills Killed the Server
 
Sql killedserver
Sql killedserverSql killedserver
Sql killedserver
 
SQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - AdvancedSQL Server 2014 Memory Optimised Tables - Advanced
SQL Server 2014 Memory Optimised Tables - Advanced
 
An overview of Amazon Athena
An overview of Amazon AthenaAn overview of Amazon Athena
An overview of Amazon Athena
 
Search and analyze your data with elasticsearch
Search and analyze your data with elasticsearchSearch and analyze your data with elasticsearch
Search and analyze your data with elasticsearch
 
MySQL for beginners
MySQL for beginnersMySQL for beginners
MySQL for beginners
 
Alasql JavaScript SQL Database Library: User Manual
Alasql JavaScript SQL Database Library: User ManualAlasql JavaScript SQL Database Library: User Manual
Alasql JavaScript SQL Database Library: User Manual
 
MySQL Fulltext Search Tutorial
MySQL Fulltext Search TutorialMySQL Fulltext Search Tutorial
MySQL Fulltext Search Tutorial
 
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
 
Scaling MySQL Strategies for Developers
Scaling MySQL Strategies for DevelopersScaling MySQL Strategies for Developers
Scaling MySQL Strategies for Developers
 
Data Engineering with Solr and Spark
Data Engineering with Solr and SparkData Engineering with Solr and Spark
Data Engineering with Solr and Spark
 
My Database Skills Killed the Server
My Database Skills Killed the ServerMy Database Skills Killed the Server
My Database Skills Killed the Server
 
Master tuning
Master   tuningMaster   tuning
Master tuning
 

Plus de Pythian

DB Engineering - From Antiquated to Engineer
DB Engineering - From Antiquated to EngineerDB Engineering - From Antiquated to Engineer
DB Engineering - From Antiquated to EngineerPythian
 
TechTalk v2.0 - Performance tuning Cassandra + AWS
TechTalk v2.0 - Performance tuning Cassandra + AWSTechTalk v2.0 - Performance tuning Cassandra + AWS
TechTalk v2.0 - Performance tuning Cassandra + AWSPythian
 
Percona Live 2014 - Scaling MySQL in AWS
Percona Live 2014 - Scaling MySQL in AWSPercona Live 2014 - Scaling MySQL in AWS
Percona Live 2014 - Scaling MySQL in AWSPythian
 
MySQL administration in Amazon RDS
MySQL administration in Amazon RDSMySQL administration in Amazon RDS
MySQL administration in Amazon RDSPythian
 
Maximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digestMaximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digestPythian
 
Online Schema Changes for Maximizing Uptime
 Online Schema Changes for Maximizing Uptime Online Schema Changes for Maximizing Uptime
Online Schema Changes for Maximizing UptimePythian
 
MYSQL Patterns in Amazon - Make the Cloud Work For You
MYSQL Patterns in Amazon - Make the Cloud Work For YouMYSQL Patterns in Amazon - Make the Cloud Work For You
MYSQL Patterns in Amazon - Make the Cloud Work For YouPythian
 
Ramp-Tutorial for MYSQL Cluster - Scaling with Continuous Availability
Ramp-Tutorial for MYSQL Cluster - Scaling with Continuous AvailabilityRamp-Tutorial for MYSQL Cluster - Scaling with Continuous Availability
Ramp-Tutorial for MYSQL Cluster - Scaling with Continuous AvailabilityPythian
 
Pdb my sql backup london percona live 2012
Pdb my sql backup   london percona live 2012Pdb my sql backup   london percona live 2012
Pdb my sql backup london percona live 2012Pythian
 

Plus de Pythian (9)

DB Engineering - From Antiquated to Engineer
DB Engineering - From Antiquated to EngineerDB Engineering - From Antiquated to Engineer
DB Engineering - From Antiquated to Engineer
 
TechTalk v2.0 - Performance tuning Cassandra + AWS
TechTalk v2.0 - Performance tuning Cassandra + AWSTechTalk v2.0 - Performance tuning Cassandra + AWS
TechTalk v2.0 - Performance tuning Cassandra + AWS
 
Percona Live 2014 - Scaling MySQL in AWS
Percona Live 2014 - Scaling MySQL in AWSPercona Live 2014 - Scaling MySQL in AWS
Percona Live 2014 - Scaling MySQL in AWS
 
MySQL administration in Amazon RDS
MySQL administration in Amazon RDSMySQL administration in Amazon RDS
MySQL administration in Amazon RDS
 
Maximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digestMaximizing SQL Reviews and Tuning with pt-query-digest
Maximizing SQL Reviews and Tuning with pt-query-digest
 
Online Schema Changes for Maximizing Uptime
 Online Schema Changes for Maximizing Uptime Online Schema Changes for Maximizing Uptime
Online Schema Changes for Maximizing Uptime
 
MYSQL Patterns in Amazon - Make the Cloud Work For You
MYSQL Patterns in Amazon - Make the Cloud Work For YouMYSQL Patterns in Amazon - Make the Cloud Work For You
MYSQL Patterns in Amazon - Make the Cloud Work For You
 
Ramp-Tutorial for MYSQL Cluster - Scaling with Continuous Availability
Ramp-Tutorial for MYSQL Cluster - Scaling with Continuous AvailabilityRamp-Tutorial for MYSQL Cluster - Scaling with Continuous Availability
Ramp-Tutorial for MYSQL Cluster - Scaling with Continuous Availability
 
Pdb my sql backup london percona live 2012
Pdb my sql backup   london percona live 2012Pdb my sql backup   london percona live 2012
Pdb my sql backup london percona live 2012
 

Dernier

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 

Dernier (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 

MYSQL Query Anti-Patterns That Can Be Moved to Sphinx

  • 1. MySQL Anti-Queries and Sphinx Search Percona Live, MySQL Users Conference Santa Clara, 2013 PALOMINODB OPERATIONAL EXCELLENCE FOR DATABASES Vlad Fedorkov www.palominodb.com
  • 2. Let’s meet each other • Performance geek • Working for PalominoDB o http://www.palominodb.com • Twitter @vfedorkov • Now fighting with clouds
  • 3. What is MySQL • Database we love • Database we use o So sometimes we hate it too o Depends on how much data you have • Most important o Database that improving  Thanks to Percona, Oracle and MariaDB!  Special thanks to MySQL community • Does it work in every case?
  • 4. MySQL today • Software o Can’t complain about concurrency anymore o Warm up is much-much better today o Optimizer doing much better now o Replication is now multi-threaded • Environment o Flash storage makes IO very fast and concurrent o Cheap and fast RAM o Awesome cloud services available o Galera, Tungsten, MySQL cluster
  • 5.
  • 6. What’s wrong with MySQL? • One-by-one: o ACID compliance is inconveniently slow o B-Tree index is not perfect for some queries o Query execution is single threaded o Full-text indexes are not that fast o Replication wants to keep data consistent o lot more inconvenient things just ask me! • So maybe some queries are bad, not MySQL itself?
  • 7. MySQL as a microscope • Excellent for specific operations o Very fast at primary key lookup o Fast enough on index lookups  some range scans too • Makes sure your data is safe • Optimized for transactional (InnoDB) workload
  • 8. Full-table scans • SELECT * FROM table WHERE myfunc(a) = 5 • SELECT * FROM table WHERE a NOT IN (1,2,3) o WHERE a <> 5 • SELECT * FROM table WHERE c LIKE ‘%ing’ • SELECT COUNT(*) FROM … • Reading the whole table is expensive • Buffer pool flooded with rarely used data • Indexes are not helpful
  • 9. Inefficient index usage • SELECT * FROM table WHERE enabled=0 o archived, deleted • SELECT * FROM table WHERE sex=1 o WHERE age_range=5 • SELECT * FROM table WHERE state=CA o WHERE city=‘New York’ • Better than full-table scan but still inefficient
  • 10. Some sorting operations • ORDER BY against non indexed field • ORDER BY a DESC, b ASC, c DESC • ORDER BY RAND() ASC o ORDER BY RAND() DESC works much better
  • 11. Temporary table operations • Some operations forces MySQL to create o In memory table o On disk table • Subqueries • GROUP BY • DISTINCT + ORDER BY o If you have TEXT or BLOB field MySQL will create on disk table at all times
  • 13. C’mon, you can do that!!!
  • 14. … or use something more convenient?
  • 15. What do we need? • Avoid full-scans as much as we can o Make them faster when we can’t get rid of them • Avoid slow IO operations o Put most data to memory  It is cheap now
  • 16. Let’s meet Sphinx • Stand alone daemon o Written in C++ and very fast • Works without MySQL o At all • Can be connected using mysql client o PHP/Ruby/JDBC/.NET/etc • Runs on lots of platforms o Linux/Windows/Mac/everywhere
  • 17. Sphinx Pros • Highly scalable • Keeps vital data in memory • Very fast in scans • Powerful full-text syntax • High availability support Cons (yet) • Don’t have B-tree indexes • No out-of-the-box replication from MySQL • Not completely ACID
  • 18. Full-table scans • Sphinx keeps attributes in memory at all times • It scale queries o Well actually you have to tell how  But only once • Limit amount of documents to walk though • You can utilize Full-Text search power o As a nice bonus 
  • 19. Full-Text functions • And, Or o hello | world, hello & world • Not o hello -world • Per-field search o @title hello @body world • Field combination o @(title, body) hello world • Search within first N o @body[50] hello • Phrase search o “hello world” • Per-field weights • Proximity search o “hello world”~10 • Distance support o hello NEAR/10 world • Quorum matching o "the world is a wonderful place"/3 • Exact form modifier o “raining =cats and =dogs” • Strict order • Sentence / Zone / Paragraph • Custom documents weighting & ranking
  • 20. SphinxQL. mysql> SELECT id, ... -> FROM myisam_table -> WHERE MATCH(title, content_ft) -> AGAINST ('I love sphinx') LIMIT 10; ... 10 rows in set (1.18 sec) mysql> SELECT * FROM sphinx_index -> WHERE MATCH('I love Sphinx') LIMIT 10; ... 10 rows in set (0.05 sec) MySQL Sphinx
  • 21. Just like MySQL $ mysql -h 0 -P 9306 Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 1 Server version: 2.1.0-id64-dev (r3028) Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql>
  • 22. What is SphinxQL? • SQL-based query language in Sphinx • Works without MySQL! o MySQL client library required  JDCB, .NET, PHP, Ruby • Required different port • Almost same syntax as in MySQL o But not exactly the same
  • 23. SQL & SphinxQL ● WITHIN GROUP ORDER BY ● OPTION support for fine tuning ● weights, matches and query time control ● SHOW META query information ● CALL SNIPPETS let you create snippets ● CALL KEYWORDS for statistics
  • 24. Extended syntax mysql> SELECT …, YEAR(ts) as yr -> FROM sphinx_index -> WHERE MATCH('I love Sphinx') -> GROUP BY yr -> WITHIN GROUP ORDER BY rating DESC -> ORDER BY yr DESC -> LIMIT 5 -> OPTION field_weights=(title=100, content=1); +---------+--------+------------+------------+------+----------+--------+ | id | weight | channel_id | ts | yr | @groupby | @count | +---------+--------+------------+------------+------+----------+--------+ | 7637682 | 101652 | 358842 | 1112905663 | 2005 | 2005 | 14 | | 6598265 | 101612 | 454928 | 1102858275 | 2004 | 2004 | 27 | | 7139960 | 1642 | 403287 | 1070220903 | 2003 | 2003 | 8 | | 5340114 | 1612 | 537694 | 1020213442 | 2002 | 2002 | 1 | | 5744405 | 1588 | 507895 | 995415111 | 2001 | 2001 | 1 | +---------+--------+------------+------------+------+----------+--------+ 5 rows in set (0.00 sec)
  • 25. GEO-Distance support • Bumping up local results o Requires coordinates for each document o Two pairs of float values (Latitude, Longitude) • GEODIST(Lat, Long, Lat2, Long2) in Sphinx SELECT *, GEODIST(docs_lat, doc_long, %d1, %d2) as dist, FROM sphinx_index ORDER BY dist DESC LIMIT 0, 20
  • 26. Range support • Price ranges (items, offers) • Date range (blog posts and news articles) • Ratings, review points • INTERVAL(field, x0, x1, …, xN) SELECT INTERVAL(item_price, 0, 20, 50, 90) as range, @count FROM my_sphinx_products GROUP BY range ORDER BY range ASC;
  • 27. Extended services • Drill-down (narrow search, faceted search) • Typos correction • Search string autocompletion • Related documents
  • 28. Misspells correction service • Provides correct search phrase o “Did you mean” service • Allows to replace user’s search on the fly o if we’re sure it’s a typo  “ophone”, “uphone”, etc o Saves time and makes website look smart • Based on your actual database o Effective if you DO have correct words in index
  • 29. Autocompletion service • Suggest search queries as user types o Show most popular queries o Promote searches that leads to desired pages o Might include misspells correction
  • 30. Related search • Improving visitor experience o Providing easier access to useful pages o Keep customer on the website o Increasing sales and server’s load average • Based on documents similarity o Different for shopping items and texts o Ends up in data mining
  • 31. Excerpts (snippets) • BuildExcerpts() or CALL SNIPPETS • Options o before_match (<b>) o after_match (</b>) o chunk_separator (…) o limit o around o force_all_words
  • 32. Installation: How? ● From binary packages ● http://sphinxsearch.com/downloads/ ● From source ● http://sphinxsearch.googlecode.com/svn/ ● configure && make && make install – Make sure to use --enable-id64 – for huge document collection – already included in pre-compiled packages
  • 34. Initial configuration: indexing • Where to look for data? • How to process it? • Where to store index?
  • 35. Where to look for the data? ● MySQL ● PostgreSQL ● MSSQL ● ODBC source ● XML pipe
  • 36. MySQL source source data_source { … sql_query = SELECT id, channel_id, ts, title, content FROM mytable sql_attr_uint = channel_id sql_attr_timestamp = ts … }
  • 37. A complete version source data_source { type = mysql sql_host = localhost sql_user = my_user sql_pass = my****** sql_db = test sql_query_pre = SET NAMES utf8 sql_query = SELECT id, channel_id, ts, title, content FROM mytable WHERE id>=$start and id<=$end sql_attr_uint = channel_id sql_attr_timestamp = ts sql_query_range = SELECT MIN(id), MAX(id) FROM mytable sql_range_step = 1000 }
  • 38. How to process. Index config. index my_sphinx_index { source = data_source path = /my/index/path/idx html_strip = 1 morphology = stem_en stopwords = stopwords.txt charset_type = utf-8 }
  • 39. Indexer configuration indexer { mem_limit = 512M max_iops = 40 max_iosize = 1048576 }
  • 40. Running indexer $ ./indexer my_sphinx_index Sphinx 2.0.2-dev (r2824) Copyright (c) 2001-2010, Andrew Aksyonoff Copyright (c) 2008-2010, Sphinx Technologies Inc (http://sph... using config file './sphinx.conf'... indexing index 'my_sphinx_index'... collected 999944 docs, 1318.1 MB sorted 224.2 Mhits, 100.0% done total 999944 docs, 1318101119 bytes total 158.080 sec, 8338160 bytes/sec, 6325.53 docs/sec total 33 reads, 4.671 sec, 17032.9 kb/call avg, 141.5 msec/call total 361 writes, 20.889 sec, 3566.1 kb/call avg, 57.8 msec/call
  • 41. Index files $ ls -lah idx* -rw-r--r-- 1 vlad vlad 12M 2010-12-22 09:01 idx.spa -rw-r--r-- 1 vlad vlad 334M 2010-12-22 09:01 idx.spd -rw-r--r-- 1 vlad vlad 438 2010-12-22 09:01 idx.sph -rw-r--r-- 1 vlad vlad 13M 2010-12-22 09:01 idx.spi -rw-r--r-- 1 vlad vlad 0 2010-12-22 09:01 idx.spk -rw-r--r-- 1 vlad vlad 0 2011-05-13 09:25 idx.spl -rw-r--r-- 1 vlad vlad 0 2010-12-22 09:01 idx.spm -rw-r--r-- 1 vlad vlad 111M 2010-12-22 09:01 idx.spp -rw-r--r-- 1 vlad vlad 1 2010-12-22 09:01 idx.sps $
  • 42. Next Steps • Run the daemon • Connect to daemon • Run search query
  • 43. Configuring searchd searchd { listen = localhost:9312 listen = localhost:9306:mysql4 query_log = query.log query_log_format = sphinxql pid_file = searchd.pid }
  • 44. Running sphinx daemon! $ ../bin/searchd -c sphinx.conf Sphinx 2.0.2-dev (r2824) Copyright (c) 2001-2010, Andrew Aksyonoff Copyright (c) 2008-2010, Sphinx Technologies Inc (http://sphinxsearch.com) using config file 'sphinx.conf'... listening on 127.0.0.1:9312 listening on 127.0.0.1:9306 precaching index ‘idx' precached 1 indexes in 0.028 sec
  • 45. Connecting to Sphinx • Sphinx API o PHP, Python, Java, Ruby, C is included in distro o .NET, Rails (via Thinking Sphinx) via third party libs • SphinxQL o MySQL-compatible protocol • SphinxSE o Storage engine for MySQL
  • 46. Sphinx applications • Find relevant documents o Items in store(s) o Articles in blog/forum/news/etc website(s) o Pictures or photos  By text, description, GEO-data, publish time, etc o Friends  In social networks or dating websites • Offload main database from heavy queries • Build advanced search and search-based services
  • 47. Another way to speed up is scaling • Combine diffrent indexes o Main + Delta o Ondisk + RT o Distributed and local  Don't forget about dist_threads! • Use parallel indexing
  • 49. Bright side of scaling • Faster search • Better load control • Hardware utilization • High availability
  • 50. Dark side • Hardware faults • Network issues • Balancing issues o Search time related to slowest search chunk • Complicated operations
  • 51. ToDo for attendees • Please rate this talk! • Submit your feedback to @vfedorkov • Visit PalominoDB booth! • Andrew Aksenoff’s talk about new Sphinx features, don’t miss it. o Tomorrow, 4:30pm - 5:20pm @ Ballroom E • Questions!
  • 52. Thank you! Twitter @vfedorkov Website: http://palominodb.com