How to debug database query for performance

I am completely new in databases and SQL queries.

Q1. What are the common problems commonly encountered in database queries? Probably extremely large queries, performance problems, timeout and connection errors, import and recovery errors.

Q2. What approach and tools do you need to be aware of debugging SQL query performance?

It will be great if you can share some of the problems and how you have moved forward to solve it.

+5
source share
7 answers

Try using EXPLAIN before your queries, which will give you an excellent overview of what is happening under the hood.

.: SQL

+5

, , , - . , , . , , , , (), .

, , SQL Server , SQL Profiler. SQL Management Studio, , .

+5

, , .

, , , 3-4 . , , :

SELECT max(now() - xact_start) FROM pg_stat_activity
                               WHERE state IN ('idle in transaction', 'active');

, . .

+2

, . . , , , , , , . , , .

-

- ,

- . , - (, EAV), , , , , , , , .

, , - - ( , , ) . SOmetimes , , datbase. concurrency .

- ( , , , ..)

- SQl , , , .

+1

, SQL- , :

+1

, , , , , - ( ), , , - .

, , , , , , , , .

- - , .

For queries, use explanation plans that let you determine how the database engine will run your queries. (This will determine how the unions will be performed, and in what order and in the strength of your unions - if you can reduce the attitude of many to many in your unions, your request will work faster)

0
source

All Articles