nw-query-optimization

Optimize SQL and NoSQL database queries to reduce latency and improve execution plans.

Updated Apr 15, 2026
One-click install
npx skills add https://github.com/StudentCristian/nWave-github --skill nw-query-optimization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nw-query-optimization
Source: https://github.com/StudentCristian/nWave-github/tree/main/.github/skills/nw-query-optimization
Command: npx skills add https://github.com/StudentCristian/nWave-github --skill nw-query-optimization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

SQL and NoSQL databases often run into performance bottlenecks due to suboptimal queries, missing indexes, or underperforming execution plans.

Core Features & Use Cases

  • Cost-Based Optimization: Understand how optimizers choose plans using statistics and how stale data can degrade performance.
  • Indexing Strategies: Guidance on B-Tree, Hash, covering indexes, compound indexes, and database-specific indexes.
  • Execution Plan Analysis: Techniques to read and compare EXPLAIN outputs and identify bottlenecks.
  • Join Algorithm Guidance: Rules of thumb for Nested Loop, Hash Join, and Merge Join based on data and indexes.
  • Cardinality Estimation: Approaches using histograms and density vectors, plus stat maintenance.

Quick Start

Analyze a slow query plan and propose an indexing change to improve performance.

Frequently Asked Questions about nw-query-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I analyze an execution plan to fix slow SQL queries?

Cardinality estimation uses histograms and density vectors to help cost-based optimizers choose efficient execution plans. Maintaining accurate statistics prevents stale data from degrading query performance.

What is the best indexing strategy for NoSQL query optimization?

NoSQL query optimization indexing strategies include B-Tree, Hash, compound, and covering indexes. Selecting the right index type based on query patterns reduces latency and improves data retrieval performance.

When should I use a Hash Join instead of a Nested Loop join algorithm?

Join algorithm selection depends on data size and available indexes. Hash Joins suit large unindexed datasets, Nested Loops work best for small indexed datasets, and Merge Joins require sorted inputs.

How does cost-based optimization handle stale database statistics?

Cost-based optimization chooses execution plans using database statistics. Stale data degrades performance by causing the optimizer to select inefficient join strategies and indexing paths based on outdated cardinality estimates.

Can I apply covering indexes to reduce query latency in both SQL and NoSQL?

Covering indexes apply to both SQL and NoSQL environments to reduce query latency. By including all required columns in the index, the database engine avoids accessing the underlying table data entirely.