Skip to main content

21 posts tagged with "optimize"

View All Tags

2024/PawSQL4VSCode

· 2 min read
PawSQL Team
Optimize your SQL Queries by Clicks!


PawSQL , Optimize your SQL Queries by Clicks!

Version Ratings



Optimize a SQL Query

  1. Optimize in Default Workspace:

    • Click the "Optimize" button in the SQL statement prompt
  2. Optimize in Specific Workspace:

    • Click the "Optimize..." button in the SQL statement prompt
    • Select a workspace from the dropdown menu

Features

  • Index Advise: Recommend optimal indexes based on input SQL syntax, database objects and statistics information
  • Query Rewrite: Recommend semantically equivalent, but more efficient SQLs
  • Performance Validation: Ensure better performance after SQL rewrite and index recommendation

Supported Databases

MySQL, PostgreSQL, MariaDB, Oracle, openGauss, KingbaseES, GaussDB, Dameng, RDS for MySQL and etc.


Resources


🌐 About PawSQL

PawSQL is dedicated to automatic and intelligent database performance optimization. The products provided by PawSQL include:

  • PawSQL Cloud, an online automated SQL optimization tool that supports SQL auditing, intelligent query rewriting, cost-based index recommendations, suitable for database administrators and data application developers.
  • PawSQL Advisor, an IntelliJ plugin that is suitable for data application developers and can be installed via the IDEA/DataGrip marketplace by searching for "PawSQL Advisor" by name.

Contact Us

Email: service@pawsql.com

Website: https://www.pawsql.com

SAT-TC Rewrite

· 4 min read
PawSQL Team
Optimize your SQL Queries by Clicks!

Copyright © 2024 PawSQL

Definition

SAT-TC(Satisfiability-Transitive Closure) rewrite rule analyzes a set of predicates and try to determine if

  1. there is a contradiction (e.g., c_custkey=1 AND c_custkey=0), or
  2. new predicates can be inferred from the set (e.g., c_custkey=1 AND c_custkey=o_custkey implies o_custkey=1.
  3. predicates can simplified (e.g. c_custkey <> c_custkey or c_name = 'b' can be simplified to c_name = 'b')

SAT and TC optimizations are two closely related and interacting optimization techniques, often used together.

NPE Rewrite

· 2 min read
PawSQL Team
Optimize your SQL Queries by Clicks!

Copyright © 2024 PawSQL

Problem Definition

NPE (Null Pointer Exception) issues in SQL refer to cases where aggregate functions like SUM, AVG return NULL when the aggregated column is all NULL, which can then cause null pointer exceptions in subsequent program logic.

select sum(t.b) from (values row(1,null)) as t(a,b);

This can be avoided by using:

SELECT IFNULL(SUM(t.b), 0) from (values row(1,null)) as t(a,b);

Explicitly Disable Sorting of Result Set

· 2 min read
PawSQL Team
Optimize your SQL Queries by Clicks!

Copyright © 2024 PawSQL

Problem Definition

In earlier versions of MySQL, GROUP BY would default to sorting by the grouping fields even without an ORDER BY clause. This could cause unnecessary file sorting which impacts SQL query performance. Adding ORDER BY NULL forces disabling sorting on the result set.

For example in the following:

SELECT l_orderkey, sum(l_quantity) 
FROM lineitem
GROUP BY l_orderkey;

Query Folding

· 5 min read
PawSQL Team
Optimize your SQL Queries by Clicks!

Copyright © 2024 PawSQL

Definition

By enabling Query Folding rule, PawSQL merges view references, derived tables and common table expressions to outer query blocks to:

  • avoid materializing intermediate result-set
  • enable more join order planning
  • enable more opportunities for index recommendation

We will use view in following paragraph, but all the descriptions also apply to derived tables and common table expressions.