Forum

SQL Optimization an...
 
Share:
Notifications
Clear all

SQL Optimization and Performance Tuning Questions — Asked in Wipro & Accenture (2025 Edition)

1 Posts
1 Users
0 Reactions
128 Views
Posts: 134
Admin
Topic starter
(@sql-admin)
Reputable Member
Joined: 6 years ago

Interviewers at Wipro and Accenture often go beyond basic SQL queries — they test your ability to optimize and tune query performance in real-world data environments.

This post lists top performance tuning interview questions and practical answers that cover indexes, query plans, statistics, joins, and optimization techniques — crucial for data engineer and SQL developer roles in 2025.


🔹 Top SQL Optimization & Performance Tuning Interview Questions (2025 Edition)

1️⃣ What is SQL query optimization?

Answer:
SQL optimization is the process of rewriting queries and improving database structure to achieve faster execution and reduced resource usage without changing results.
It includes indexing, partitioning, rewriting subqueries, and analyzing execution plans.


2️⃣ How do indexes improve query performance?

Indexes speed up data retrieval by allowing the database to find records faster — similar to a book’s index.
However, too many indexes can slow down inserts and updates due to maintenance overhead.
Common follow-up in Accenture technical rounds.


3️⃣ How do you identify slow-running SQL queries?

  • Use EXPLAIN PLAN or Query Analyzer to view execution steps.

  • Check I/O operations, CPU time, and index usage.

  • Use database system views:

    • Oracle → V$SQL, DBA_HIST_SQLSTAT

    • SQL Server → sys.dm_exec_query_stats


4️⃣ What are the main causes of poor SQL performance?

  • Missing or unused indexes

  • Outdated statistics

  • Non-sargable queries (e.g., functions on indexed columns)

  • Excessive joins or subqueries

  • High network latency

Example of a non-sargable condition:

 
WHERE YEAR(order_date) = 2024

Better version:

 
WHERE order_date BETWEEN '2024-01-01' AND '2024-12-31'

5️⃣ How can you tune a query using joins?

  • Prefer INNER JOIN over subqueries for filtering.

  • Ensure join keys are indexed.

  • Join smaller tables first in nested loops.

  • Avoid unnecessary DISTINCT or GROUP BY operations.

Frequently discussed in Wipro data team interviews.


6️⃣ What is the difference between clustered and non-clustered indexes?

TypeDescriptionExample Use
ClusteredSorts and stores data physicallyPrimary key columns
Non-clusteredStores pointers to data rowsSearch or filter columns

7️⃣ How do you use the EXPLAIN PLAN in SQL?

It helps analyze query execution paths.

 
EXPLAIN PLAN FOR SELECT * FROM Employees WHERE Department='Sales';
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);

Review cost, index scans, and table access types to identify optimization opportunities.


8️⃣ What are SQL hints and when should they be used?

Hints override the default optimizer behavior.
Example:

 
SELECT /*+ INDEX(emp emp_idx_dept) */ * FROM Employees emp;

⚠️ Use cautiously — they can make queries less portable and hard to maintain.


9️⃣ How do you handle large table performance issues?

  • Implement table partitioning (range or hash).

  • Use materialized views for heavy aggregations.

  • Apply batch processing instead of single large transactions.

  • Use parallel query execution when supported.


🔟 What are statistics in SQL optimization?

Statistics help the optimizer decide the most efficient query plan.
Regularly update them using:

 
EXEC DBMS_STATS.GATHER_SCHEMA_STATS('HR');

Outdated stats often lead to poor query plans — a top concern in Accenture production support rounds.


💡 Pro Tip:

Always explain how you identified and fixed a performance issue in a project.
For example:

“We noticed high read I/O on a customer orders table; after creating a composite index on (region, order_date), query time dropped from 12s to 0.9s.”

This real-world example makes your answer stand out in interviews.


🧩 Conclusion

These SQL performance tuning questions from Wipro & Accenture (2025) focus on query analysis, indexing strategy, and optimizer behavior — key skills for any advanced SQL role.
Practice using EXPLAIN PLAN and query profiling tools, and always measure performance impact after optimization.


Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: