SlideShare a Scribd company logo
MySQL Cookbook 4e Journey
and Beyond
FOSSASIA Summit April 2023
@ask_dba
Let’s get connected with Alkin first
● Alkin Tezuysal - EVP - Global Services @chistadata
○ Linkedin : https://www.linkedin.com/in/askdba/
○ Twitter: https://twitter.com/ask_dba
● Open Source Database Evangelist
○ Previously PlanetScale, Percona and Pythian as Technical Manager, SRE, DBA
○ Previously Enterprise DBA , Informix, Oracle, DB2 , SQL Server
● Author, Speaker, Mentor, and Coach
@ChistaDATA Inc. 2022
@ask_dba
Also…
Born to Sail, Forced to Work
@ChistaDATA Inc. 2022
@ask_dba
About ChistaDATA Inc.
● Founded in 2021 by Shiv Iyer - CEO and Principal
● Has received 3M USD seed investment
● Focusing on ClickHouse infrastructure operations
○ What’s ClickHouse anyway?
● Services around dedicated DBaaS, Managed Services,
Support and Consulting
● We’re hiring globally DBAs, SREs and DevOps Engineers
@ChistaDATA Inc. 2022
@ask_dba
About ClickHouse
● Columnar Storage
● SQL Compatible
● Open Source (Apache 2.0)
● Shared Nothing Architecture
● Parallel Execution
● Rich in Aggregate Functions
● Super fast for Analytics workload
@ChistaDATA Inc. 2022
@ask_dba
About MySQL Cookbook 4th Edition
● O’reilly Book previously authored by Paul Dubois 3 editions
● Solutions for Database Developers and Administrators
● More than 950 pages of recipes for specific database challenges
● It took two years of authoring, rewriting, reviewing, editing and
learning.
● Co-authored with Sveta Smirnova - MySQL Expert / Author , Percona
@ChistaDATA Inc. 2022
@ask_dba
How did I end up there?
10,000 hours?
@ChistaDATA Inc. 2022
@ask_dba
How did I end up there?
● It wasn’t by luck maybe co-incidental
● Wanted to author one before
● Failed attempts
● Recognition
● Pandemic
@ChistaDATA Inc. 2022
@ask_dba
Stages ?
● Preparations
○ Agreement on the book (pages, percentile of content if new release)
○ Contracts signed
○ Authoring platform discussions
■ Docbook over XML / Asciidoc
■ This is important piece of decision
○ Editor(s) assigned by O’reilly
○ Supervisor assigned by O’reilly
@ChistaDATA Inc. 2022
@ask_dba
Stages ?
● Authoring
○ Start with difficult chapters
○ Allow research time
○ Use of editor (Grammarly) and available resources
○ Getting inside (co-author) and outside help
○ Review process
○ Final edits before many final reviews and approvals
@ChistaDATA Inc. 2022
@ask_dba
Stages ?
● Putting all together
1. Authoring is confirmed by the author (if co-authoring) if not this will be done by
technical reviewers
2. Reviewed by immediate editor
3. Chapters passes quality assurance by marking them complete and ready for pre-release.
4. While pre-releases published by chapters other chapters ongoing and technical reviews
starts.
5. They all randomly come back with feedback
@ChistaDATA Inc. 2022
@ask_dba
Builds ?
● Every version is a complete book repo in GitLab.
1. Use gitlab to pull changes. If two authors working together make sure to be up
to date.
2. Edit changes in a chapter
3. Push changes to repo
4. Push all updates, instructions to code repo (GitHub)
5. Make a compile request as pdf
6. Review (again)
@ChistaDATA Inc. 2022
@ask_dba
Production Schedule ?
1. Cover of the book (illustrations)
2. Pre-copyedit cleanup (Code blocks, Wording, Grammar and Spelling)
3. Copyedit review
4. Quality Control #1
5. Praise quotes for back cover
6. Index review
7. Quality Control #2
@ChistaDATA Inc. 2022
@ask_dba
Became an O'reilly Author
● Authored blogs
● Attempted to author booklet
○ Invited many co-authors
○ Talked to other editors
● Given talks online and offline
○ Mentored others to give talks
● On the field and always focused on same subject (Open Source, MySQL, Databases)
● Got an invitation by long time friend and colleague Sveta Smirnova
@ChistaDATA Inc. 2022
@ask_dba
Key Takeaways
● Talk to other authors
● Platform research
● Keep close track of agreements and details
● Organize your time in advance (allow extra time)
● Do not overcommit (work / life / book) balance
● More on this in another blog - MySQL Cookbook 4th Edition
● Details about the book in Percona University Nov 5 10:00 - 18:00
@ChistaDATA Inc. 2022
@ask_dba
A new book? Maybe
● I’m going to be co-authoring :
○ Database Design and Modeling for MySQL and PostgreSQL
Details coming soon…
@ChistaDATA Inc. 2022
@ask_dba
What’s in it?
Problem & Solution Recipes
Problem
You want to store and query geographic coordinates effectively.
Solution
Use MySQL’s improved Spatial Reference System.
MySQL’s improved Spatial Reference System
Creating geometries in various formats
Converting geometries between formats
Accessing qualitative and quantitative properties of geometry
Describing relations between two geometries
Creating new geometries from existing ones
Different variations of geographic data references
mysql> SELECT * FROM INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMS
-> WHERE SRS_ID=4326 OR SRS_ID=3857 ORDER BY SRS_ID DESC G
*************************** 1. row ***************************
SRS_NAME: WGS 84
SRS_ID: 4326
ORGANIZATION: EPSG
ORGANIZATION_COORDSYS_ID: 4326
DEFINITION: GEOGCS["WGS 84",DATUM["World Geodetic System 1984",
SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],
UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],
AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]]
DESCRIPTION: NULL
…
SRS_ID 4326 represents map projections used in Google
Maps
mysql> CREATE TABLE poi
-> ( poi_id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
-> position POINT NOT NULL SRID 4326, name VARCHAR(200));
Query OK, 0 rows affected (0.02 sec)
Insert GeoSpatial data with ST_GeomFromText()
mysql> INSERT INTO poi VALUES (1, ST_GeomFromText('POINT(41.0211 29.0041)', 4326),
-> 'Maiden's Tower');
Query OK, 1 row affected (0.00 sec)
msyql> INSERT INTO poi VALUES (2, ST_GeomFromText('POINT(41.0256 28.9742)', 4326),
-> 'Galata Tower');
Query OK, 1 row affected (0.00 sec)
Create SPATIAL index
mysql> CREATE SPATIAL INDEX position ON poi (position);
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
Measure the distance between coordinates ST_Distance()
mysql> SELECT ST_AsText(position) FROM poi WHERE poi_id = 1 INTO @tower1;
Query OK, 1 row affected (0.00 sec)
mysql> SELECT ST_AsText(position) FROM poi WHERE poi_id = 2 INTO @tower2;
Query OK, 1 row affected (0.00 sec)
mysql> SELECT ST_Distance(ST_GeomFromText(@tower1, 4326),
-> ST_GeomFromText(@tower2, 4326)) AS distance;
+--------------------+
| distance |
+--------------------+
| 2563.9276036976544 |
+--------------------+
1 row in set (0.00 sec)
Improved Earth’s spherical shape with
ST_Distance_Sphere ()
mysql> SELECT ST_Distance_Sphere(ST_GeomFromText(@tower1, 4326),
-> ST_GeomFromText(@tower2, 4326)) AS dist;
+--------------------+
| dist |
+--------------------+
| 2557.7412439442496 |
+--------------------+
1 row in set (0.00 sec)
Set a polygon with coordinates
mysql> SET @poly := ST_GeomFromText ( 'POLYGON(( 41.104897239651905 28.876082545638166,
-> 41.05727989444261 29.183699733138166,
-> 40.90384226781947 29.137007838606916,
-> 40.94119778455447 28.865096217513166,
-> 41.104897239651905 28.876082545638166))', 4326);
Find two towers from Istanbul using SPATIAL index
ST_Within()
mysql> SELECT poi_id, name, ST_AsText(`position`)
-> AS `towers` FROM poi WHERE ST_Within( `position`, @poly) ;
+--------+----------------+------------------------+
| poi_id | name | towers |
+--------+----------------+------------------------+
| 1 | Maiden's Tower | POINT(41.0211 29.0041) |
| 2 | Galata Tower | POINT(41.0256 28.9742) |
+--------+----------------+------------------------+
2 rows in set (0.00 sec)
@ChistaDATA Inc. 2022
@ChistaDATA Inc. 2022
THANK YOU
@ChistaDATA Inc. 2022
@ask_dba

More Related Content

PDF
Using S3 Select to Deliver 100X Performance Improvements Versus the Public Cloud
PDF
2021.02 new in Ceph Pacific Dashboard
PDF
Ceph Object Storage Performance Secrets and Ceph Data Lake Solution
PPTX
Maria DB Galera Cluster for High Availability
PDF
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
PDF
Percona Live 2022 - MySQL Architectures
PDF
MySQL Timeout Variables Explained
PDF
MongoDB Oplog入門
Using S3 Select to Deliver 100X Performance Improvements Versus the Public Cloud
2021.02 new in Ceph Pacific Dashboard
Ceph Object Storage Performance Secrets and Ceph Data Lake Solution
Maria DB Galera Cluster for High Availability
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
Percona Live 2022 - MySQL Architectures
MySQL Timeout Variables Explained
MongoDB Oplog入門

What's hot (20)

PDF
NVMe overview
PPTX
Apache BigtopによるHadoopエコシステムのパッケージング(Open Source Conference 2021 Online/Osaka...
PPT
Taking Full Advantage of Galera Multi Master Cluster
PDF
Ceph Block Devices: A Deep Dive
PPTX
Ceph Performance and Sizing Guide
PDF
Storage tiering and erasure coding in Ceph (SCaLE13x)
PPTX
High Performance Object Storage in 30 Minutes with Supermicro and MinIO
PPTX
Five common customer use cases for Virtual SAN - VMworld US / 2015
PDF
BlueStore, A New Storage Backend for Ceph, One Year In
PDF
Introduction to Hadoop
PPTX
What is Object storage ?
PDF
Ceph Tech Talk: Ceph at DigitalOcean
PDF
5ステップで始めるPostgreSQLレプリケーション@hbstudy#13
PDF
今、改めて考えるPostgreSQLプラットフォーム - マルチクラウドとポータビリティ -(PostgreSQL Conference Japan 20...
PDF
vSphere 7 へのアップグレードについて
PDF
Everything you always wanted to know about Redis but were afraid to ask
PDF
Hitachi content-platform-architecture-fundamentals
PDF
Dd and atomic ddl pl17 dublin
PPTX
Introduction to snowflake
PDF
High Availability for OpenStack
NVMe overview
Apache BigtopによるHadoopエコシステムのパッケージング(Open Source Conference 2021 Online/Osaka...
Taking Full Advantage of Galera Multi Master Cluster
Ceph Block Devices: A Deep Dive
Ceph Performance and Sizing Guide
Storage tiering and erasure coding in Ceph (SCaLE13x)
High Performance Object Storage in 30 Minutes with Supermicro and MinIO
Five common customer use cases for Virtual SAN - VMworld US / 2015
BlueStore, A New Storage Backend for Ceph, One Year In
Introduction to Hadoop
What is Object storage ?
Ceph Tech Talk: Ceph at DigitalOcean
5ステップで始めるPostgreSQLレプリケーション@hbstudy#13
今、改めて考えるPostgreSQLプラットフォーム - マルチクラウドとポータビリティ -(PostgreSQL Conference Japan 20...
vSphere 7 へのアップグレードについて
Everything you always wanted to know about Redis but were afraid to ask
Hitachi content-platform-architecture-fundamentals
Dd and atomic ddl pl17 dublin
Introduction to snowflake
High Availability for OpenStack
Ad

Similar to FOSSASIA - MySQL Cookbook 4e Journey APR 2023.pdf (20)

PPTX
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
PDF
How OLTP to OLAP Archival Demystified
PDF
Spatial query on vanilla databases
PDF
Comparing Geospatial Implementation in MongoDB, Postgres, and Elastic
PPTX
FOSS4G 2017 Spatial Sql for Rookies
PDF
Building Location Aware Apps - Get Started with PostGIS, PART I
PDF
Pg intro part1-theory_slides
PPTX
PostGIS and Spatial SQL
PDF
Pi Day 2022 - from IoT to MySQL HeatWave Database Service
PPT
Building a Spatial Database in PostgreSQL
PPT
Designing Scalable Data Warehouse Using MySQL
PDF
2017 RM-URISA Track: Spatial SQL - The Best Kept Secret in the Geospatial World
PDF
On Beyond (PostgreSQL) Data Types
PPTX
MySQL 5.7 GIS
PDF
Geographical Data Management for Web Applications
PDF
My first 90 days with ClickHouse.pdf
PDF
Dok Talks #133 - My First 90 days with Clickhouse
PDF
Building A Spatial Database In Postgresql (Ppt).pdf
PDF
Mysql Cookbook Solutions For Database Developers And Administrators 4th Editi...
Design and Modeling for MySQL SCALE 21X Pasadena, CA Mar 2024
How OLTP to OLAP Archival Demystified
Spatial query on vanilla databases
Comparing Geospatial Implementation in MongoDB, Postgres, and Elastic
FOSS4G 2017 Spatial Sql for Rookies
Building Location Aware Apps - Get Started with PostGIS, PART I
Pg intro part1-theory_slides
PostGIS and Spatial SQL
Pi Day 2022 - from IoT to MySQL HeatWave Database Service
Building a Spatial Database in PostgreSQL
Designing Scalable Data Warehouse Using MySQL
2017 RM-URISA Track: Spatial SQL - The Best Kept Secret in the Geospatial World
On Beyond (PostgreSQL) Data Types
MySQL 5.7 GIS
Geographical Data Management for Web Applications
My first 90 days with ClickHouse.pdf
Dok Talks #133 - My First 90 days with Clickhouse
Building A Spatial Database In Postgresql (Ppt).pdf
Mysql Cookbook Solutions For Database Developers And Administrators 4th Editi...
Ad

More from Alkin Tezuysal (20)

PDF
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
PDF
Unified Observability - Alkin Tezuysal - FOSSASIA Summit March 2025 .pdf
PDF
Boosting MySQL with Vector Search Scale22X 2025.pdf
PDF
Boosting MySQL with Vector Search Fosdem 2025.pdf
PDF
London MySQL Day - Lightning Talk Dec 2024.pdf
PDF
Design and Modeling with MySQL and PostgreSQL - Percona University Istanbul S...
PDF
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
PDF
MySQL Cookbook: Recipes for Developers, Alkin Tezuysal and Sveta Smirnova - P...
PDF
KubeCon_NA_2021
PDF
Integrating best of breed open source tools to vitess orchestrator pleu21
PDF
Vitess: Scalable Database Architecture - Kubernetes Community Days Africa Ap...
PDF
How to shard MariaDB like a pro - FOSDEM 2021
PDF
Vitess - Data on Kubernetes
PDF
MySQL Ecosystem in 2020
PDF
Introduction to Vitess on Kubernetes for MySQL - Webinar
PDF
When is Myrocks good? 2020 Webinar Series
PPTX
Mysql 8 vs Mariadb 10.4 Webinar 2020 Feb
PPTX
Myrocks in the wild wild west! FOSDEM 2020
PPTX
Mysql 8 vs Mariadb 10.4 Highload++ 2019
PPTX
When is MyRocks good?
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Unified Observability - Alkin Tezuysal - FOSSASIA Summit March 2025 .pdf
Boosting MySQL with Vector Search Scale22X 2025.pdf
Boosting MySQL with Vector Search Fosdem 2025.pdf
London MySQL Day - Lightning Talk Dec 2024.pdf
Design and Modeling with MySQL and PostgreSQL - Percona University Istanbul S...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
MySQL Cookbook: Recipes for Developers, Alkin Tezuysal and Sveta Smirnova - P...
KubeCon_NA_2021
Integrating best of breed open source tools to vitess orchestrator pleu21
Vitess: Scalable Database Architecture - Kubernetes Community Days Africa Ap...
How to shard MariaDB like a pro - FOSDEM 2021
Vitess - Data on Kubernetes
MySQL Ecosystem in 2020
Introduction to Vitess on Kubernetes for MySQL - Webinar
When is Myrocks good? 2020 Webinar Series
Mysql 8 vs Mariadb 10.4 Webinar 2020 Feb
Myrocks in the wild wild west! FOSDEM 2020
Mysql 8 vs Mariadb 10.4 Highload++ 2019
When is MyRocks good?

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
cuic standard and advanced reporting.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Review of recent advances in non-invasive hemoglobin estimation
Chapter 3 Spatial Domain Image Processing.pdf
Electronic commerce courselecture one. Pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Unlocking AI with Model Context Protocol (MCP)
Spectroscopy.pptx food analysis technology
Understanding_Digital_Forensics_Presentation.pptx
Spectral efficient network and resource selection model in 5G networks
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Digital-Transformation-Roadmap-for-Companies.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
cuic standard and advanced reporting.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Approach and Philosophy of On baking technology
Programs and apps: productivity, graphics, security and other tools
NewMind AI Weekly Chronicles - August'25 Week I
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx

FOSSASIA - MySQL Cookbook 4e Journey APR 2023.pdf

  • 1. MySQL Cookbook 4e Journey and Beyond FOSSASIA Summit April 2023 @ask_dba
  • 2. Let’s get connected with Alkin first ● Alkin Tezuysal - EVP - Global Services @chistadata ○ Linkedin : https://www.linkedin.com/in/askdba/ ○ Twitter: https://twitter.com/ask_dba ● Open Source Database Evangelist ○ Previously PlanetScale, Percona and Pythian as Technical Manager, SRE, DBA ○ Previously Enterprise DBA , Informix, Oracle, DB2 , SQL Server ● Author, Speaker, Mentor, and Coach @ChistaDATA Inc. 2022 @ask_dba
  • 3. Also… Born to Sail, Forced to Work @ChistaDATA Inc. 2022 @ask_dba
  • 4. About ChistaDATA Inc. ● Founded in 2021 by Shiv Iyer - CEO and Principal ● Has received 3M USD seed investment ● Focusing on ClickHouse infrastructure operations ○ What’s ClickHouse anyway? ● Services around dedicated DBaaS, Managed Services, Support and Consulting ● We’re hiring globally DBAs, SREs and DevOps Engineers @ChistaDATA Inc. 2022 @ask_dba
  • 5. About ClickHouse ● Columnar Storage ● SQL Compatible ● Open Source (Apache 2.0) ● Shared Nothing Architecture ● Parallel Execution ● Rich in Aggregate Functions ● Super fast for Analytics workload @ChistaDATA Inc. 2022 @ask_dba
  • 6. About MySQL Cookbook 4th Edition ● O’reilly Book previously authored by Paul Dubois 3 editions ● Solutions for Database Developers and Administrators ● More than 950 pages of recipes for specific database challenges ● It took two years of authoring, rewriting, reviewing, editing and learning. ● Co-authored with Sveta Smirnova - MySQL Expert / Author , Percona @ChistaDATA Inc. 2022 @ask_dba
  • 7. How did I end up there? 10,000 hours? @ChistaDATA Inc. 2022 @ask_dba
  • 8. How did I end up there? ● It wasn’t by luck maybe co-incidental ● Wanted to author one before ● Failed attempts ● Recognition ● Pandemic @ChistaDATA Inc. 2022 @ask_dba
  • 9. Stages ? ● Preparations ○ Agreement on the book (pages, percentile of content if new release) ○ Contracts signed ○ Authoring platform discussions ■ Docbook over XML / Asciidoc ■ This is important piece of decision ○ Editor(s) assigned by O’reilly ○ Supervisor assigned by O’reilly @ChistaDATA Inc. 2022 @ask_dba
  • 10. Stages ? ● Authoring ○ Start with difficult chapters ○ Allow research time ○ Use of editor (Grammarly) and available resources ○ Getting inside (co-author) and outside help ○ Review process ○ Final edits before many final reviews and approvals @ChistaDATA Inc. 2022 @ask_dba
  • 11. Stages ? ● Putting all together 1. Authoring is confirmed by the author (if co-authoring) if not this will be done by technical reviewers 2. Reviewed by immediate editor 3. Chapters passes quality assurance by marking them complete and ready for pre-release. 4. While pre-releases published by chapters other chapters ongoing and technical reviews starts. 5. They all randomly come back with feedback @ChistaDATA Inc. 2022 @ask_dba
  • 12. Builds ? ● Every version is a complete book repo in GitLab. 1. Use gitlab to pull changes. If two authors working together make sure to be up to date. 2. Edit changes in a chapter 3. Push changes to repo 4. Push all updates, instructions to code repo (GitHub) 5. Make a compile request as pdf 6. Review (again) @ChistaDATA Inc. 2022 @ask_dba
  • 13. Production Schedule ? 1. Cover of the book (illustrations) 2. Pre-copyedit cleanup (Code blocks, Wording, Grammar and Spelling) 3. Copyedit review 4. Quality Control #1 5. Praise quotes for back cover 6. Index review 7. Quality Control #2 @ChistaDATA Inc. 2022 @ask_dba
  • 14. Became an O'reilly Author ● Authored blogs ● Attempted to author booklet ○ Invited many co-authors ○ Talked to other editors ● Given talks online and offline ○ Mentored others to give talks ● On the field and always focused on same subject (Open Source, MySQL, Databases) ● Got an invitation by long time friend and colleague Sveta Smirnova @ChistaDATA Inc. 2022 @ask_dba
  • 15. Key Takeaways ● Talk to other authors ● Platform research ● Keep close track of agreements and details ● Organize your time in advance (allow extra time) ● Do not overcommit (work / life / book) balance ● More on this in another blog - MySQL Cookbook 4th Edition ● Details about the book in Percona University Nov 5 10:00 - 18:00 @ChistaDATA Inc. 2022 @ask_dba
  • 16. A new book? Maybe ● I’m going to be co-authoring : ○ Database Design and Modeling for MySQL and PostgreSQL Details coming soon… @ChistaDATA Inc. 2022 @ask_dba
  • 17. What’s in it? Problem & Solution Recipes Problem You want to store and query geographic coordinates effectively. Solution Use MySQL’s improved Spatial Reference System.
  • 18. MySQL’s improved Spatial Reference System Creating geometries in various formats Converting geometries between formats Accessing qualitative and quantitative properties of geometry Describing relations between two geometries Creating new geometries from existing ones
  • 19. Different variations of geographic data references mysql> SELECT * FROM INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMS -> WHERE SRS_ID=4326 OR SRS_ID=3857 ORDER BY SRS_ID DESC G *************************** 1. row *************************** SRS_NAME: WGS 84 SRS_ID: 4326 ORGANIZATION: EPSG ORGANIZATION_COORDSYS_ID: 4326 DEFINITION: GEOGCS["WGS 84",DATUM["World Geodetic System 1984", SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]], UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]], AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]] DESCRIPTION: NULL …
  • 20. SRS_ID 4326 represents map projections used in Google Maps mysql> CREATE TABLE poi -> ( poi_id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, -> position POINT NOT NULL SRID 4326, name VARCHAR(200)); Query OK, 0 rows affected (0.02 sec)
  • 21. Insert GeoSpatial data with ST_GeomFromText() mysql> INSERT INTO poi VALUES (1, ST_GeomFromText('POINT(41.0211 29.0041)', 4326), -> 'Maiden's Tower'); Query OK, 1 row affected (0.00 sec) msyql> INSERT INTO poi VALUES (2, ST_GeomFromText('POINT(41.0256 28.9742)', 4326), -> 'Galata Tower'); Query OK, 1 row affected (0.00 sec)
  • 22. Create SPATIAL index mysql> CREATE SPATIAL INDEX position ON poi (position); Query OK, 0 rows affected (0.01 sec) Records: 0 Duplicates: 0 Warnings: 0
  • 23. Measure the distance between coordinates ST_Distance() mysql> SELECT ST_AsText(position) FROM poi WHERE poi_id = 1 INTO @tower1; Query OK, 1 row affected (0.00 sec) mysql> SELECT ST_AsText(position) FROM poi WHERE poi_id = 2 INTO @tower2; Query OK, 1 row affected (0.00 sec) mysql> SELECT ST_Distance(ST_GeomFromText(@tower1, 4326), -> ST_GeomFromText(@tower2, 4326)) AS distance; +--------------------+ | distance | +--------------------+ | 2563.9276036976544 | +--------------------+ 1 row in set (0.00 sec)
  • 24. Improved Earth’s spherical shape with ST_Distance_Sphere () mysql> SELECT ST_Distance_Sphere(ST_GeomFromText(@tower1, 4326), -> ST_GeomFromText(@tower2, 4326)) AS dist; +--------------------+ | dist | +--------------------+ | 2557.7412439442496 | +--------------------+ 1 row in set (0.00 sec)
  • 25. Set a polygon with coordinates mysql> SET @poly := ST_GeomFromText ( 'POLYGON(( 41.104897239651905 28.876082545638166, -> 41.05727989444261 29.183699733138166, -> 40.90384226781947 29.137007838606916, -> 40.94119778455447 28.865096217513166, -> 41.104897239651905 28.876082545638166))', 4326);
  • 26. Find two towers from Istanbul using SPATIAL index ST_Within() mysql> SELECT poi_id, name, ST_AsText(`position`) -> AS `towers` FROM poi WHERE ST_Within( `position`, @poly) ; +--------+----------------+------------------------+ | poi_id | name | towers | +--------+----------------+------------------------+ | 1 | Maiden's Tower | POINT(41.0211 29.0041) | | 2 | Galata Tower | POINT(41.0256 28.9742) | +--------+----------------+------------------------+ 2 rows in set (0.00 sec)
  • 29. THANK YOU @ChistaDATA Inc. 2022 @ask_dba