SlideShare a Scribd company logo
1 of 7
MySQL in 24th
chanel
Jet Profiler
Tips & Tricks
● my.ini: buffer_pool_size
● Analize tool
● "Named" queries: where 'A'='A'
● FORCE INDEX
● distinct vs limit*distinctSize
● "limited" count
FORCE INDEX
select n.id as nId
from news n, tags_in_news tin
where 'getRelativeNews' = 'getRelativeNews' AND
n.deleted = false and n.id = tin.news_id and
tin.deleted = false and n.football24_news_id is null and
n.news_status_lid = 19 and n.id not in (0, 530120) and
n.language_id = 1 and n.id != 530120 and
tin.tag_id in (0, 1119, 2228, 4031, 1792, 1117, 3954, 2150,
3919, 4087) and
n.has_video = true and n.modified_date <= '2015-01-13
15:24:00'
order by n.modified_date desc
limit 45
select n.id as nId
from news n FORCE INDEX (ix_modified_date), tags_in_news
tin
where 'getRelativeNews' = 'getRelativeNews' AND
n.deleted = false and n.id = tin.news_id and
tin.deleted = false and n.football24_news_id is null and
n.news_status_lid = 19 and n.id not in (0, 530120) and
n.language_id = 1 and n.id != 530120 and
tin.tag_id in (0, 1119, 2228, 4031, 1792, 1117, 3954, 2150,
3919, 4087) and
n.has_video = true and n.modified_date <= '2015-01-13
15:24:00'
order by n.modified_date desc
limit 45
distinct vs limit*distinctSize
select distinct n.id as nId
from news n, tags_in_news tin
where 'getRelativeNews' = 'getRelativeNews' AND
n.deleted = false and n.id = tin.news_id and
tin.deleted = false and n.news_status_lid = 19 and
n.language_id = 1 and tin.tag_id in (0, 1119, 1117) and
n.has_video = true and n.modified_date <= Now()
order by n.modified_date desc
limit 4
select n.id as nId
from news n, tags_in_news tin
where 'getRelativeNews' = 'getRelativeNews' AND
n.deleted = false and n.id = tin.news_id and
tin.deleted = false and n.news_status_lid = 19 and
n.language_id = 1 and tin.tag_id in (0, 1119, 1117) and
n.has_video = true and n.modified_date <= Now()
order by n.modified_date desc
limit 8
select n.id from news n
where n.id in (530740, 530740, 530739, 530739, 530735,
530735, 530734, 530734)
order by n.modified_date desc
"limited" count
SELECT COUNT(*)
FROM (SELECT 1 FROM a_table
WHERE some_conditions LIMIT x) t;
"limited" count
SELECT COUNT(*)
FROM (SELECT 1 FROM a_table
WHERE some_conditions LIMIT x) t;

More Related Content

More from Romexsoft

What influences employees' motivation
What influences employees' motivationWhat influences employees' motivation
What influences employees' motivationRomexsoft
 
Burnout. Causes and teatment
Burnout. Causes and teatmentBurnout. Causes and teatment
Burnout. Causes and teatmentRomexsoft
 
Business communication by Yevgen Kryvun
Business communication by Yevgen KryvunBusiness communication by Yevgen Kryvun
Business communication by Yevgen KryvunRomexsoft
 
Bluetooth by Ostap Demkovych
Bluetooth by Ostap DemkovychBluetooth by Ostap Demkovych
Bluetooth by Ostap DemkovychRomexsoft
 
Continuous integration by Halyna Levko
Continuous integration by Halyna LevkoContinuous integration by Halyna Levko
Continuous integration by Halyna LevkoRomexsoft
 
Architecture analysis by Maxym Shabatura
Architecture analysis by Maxym ShabaturaArchitecture analysis by Maxym Shabatura
Architecture analysis by Maxym ShabaturaRomexsoft
 

More from Romexsoft (7)

Solid
SolidSolid
Solid
 
What influences employees' motivation
What influences employees' motivationWhat influences employees' motivation
What influences employees' motivation
 
Burnout. Causes and teatment
Burnout. Causes and teatmentBurnout. Causes and teatment
Burnout. Causes and teatment
 
Business communication by Yevgen Kryvun
Business communication by Yevgen KryvunBusiness communication by Yevgen Kryvun
Business communication by Yevgen Kryvun
 
Bluetooth by Ostap Demkovych
Bluetooth by Ostap DemkovychBluetooth by Ostap Demkovych
Bluetooth by Ostap Demkovych
 
Continuous integration by Halyna Levko
Continuous integration by Halyna LevkoContinuous integration by Halyna Levko
Continuous integration by Halyna Levko
 
Architecture analysis by Maxym Shabatura
Architecture analysis by Maxym ShabaturaArchitecture analysis by Maxym Shabatura
Architecture analysis by Maxym Shabatura
 

Recently uploaded

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
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
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 

Recently uploaded (20)

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
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
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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 Tips for Optimizing Queries with FORCE INDEX, DISTINCT, and "LIMITED

  • 3. Tips & Tricks ● my.ini: buffer_pool_size ● Analize tool ● "Named" queries: where 'A'='A' ● FORCE INDEX ● distinct vs limit*distinctSize ● "limited" count
  • 4. FORCE INDEX select n.id as nId from news n, tags_in_news tin where 'getRelativeNews' = 'getRelativeNews' AND n.deleted = false and n.id = tin.news_id and tin.deleted = false and n.football24_news_id is null and n.news_status_lid = 19 and n.id not in (0, 530120) and n.language_id = 1 and n.id != 530120 and tin.tag_id in (0, 1119, 2228, 4031, 1792, 1117, 3954, 2150, 3919, 4087) and n.has_video = true and n.modified_date <= '2015-01-13 15:24:00' order by n.modified_date desc limit 45 select n.id as nId from news n FORCE INDEX (ix_modified_date), tags_in_news tin where 'getRelativeNews' = 'getRelativeNews' AND n.deleted = false and n.id = tin.news_id and tin.deleted = false and n.football24_news_id is null and n.news_status_lid = 19 and n.id not in (0, 530120) and n.language_id = 1 and n.id != 530120 and tin.tag_id in (0, 1119, 2228, 4031, 1792, 1117, 3954, 2150, 3919, 4087) and n.has_video = true and n.modified_date <= '2015-01-13 15:24:00' order by n.modified_date desc limit 45
  • 5. distinct vs limit*distinctSize select distinct n.id as nId from news n, tags_in_news tin where 'getRelativeNews' = 'getRelativeNews' AND n.deleted = false and n.id = tin.news_id and tin.deleted = false and n.news_status_lid = 19 and n.language_id = 1 and tin.tag_id in (0, 1119, 1117) and n.has_video = true and n.modified_date <= Now() order by n.modified_date desc limit 4 select n.id as nId from news n, tags_in_news tin where 'getRelativeNews' = 'getRelativeNews' AND n.deleted = false and n.id = tin.news_id and tin.deleted = false and n.news_status_lid = 19 and n.language_id = 1 and tin.tag_id in (0, 1119, 1117) and n.has_video = true and n.modified_date <= Now() order by n.modified_date desc limit 8 select n.id from news n where n.id in (530740, 530740, 530739, 530739, 530735, 530735, 530734, 530734) order by n.modified_date desc
  • 6. "limited" count SELECT COUNT(*) FROM (SELECT 1 FROM a_table WHERE some_conditions LIMIT x) t;
  • 7. "limited" count SELECT COUNT(*) FROM (SELECT 1 FROM a_table WHERE some_conditions LIMIT x) t;