SQL tuning commonly involves finding more efficient ways to process the same workload. It is possible to change the execution plan of the statement without altering the functionality to reduce the resource consumption.
Questions tagged [sql-tuning]
328 questions
0
votes
1 answer
Tuning Oracle SQL having NOT EXIST clause
I want to tune below query eliminating NOT EXIST clause specified in it. Can you please help.
GLT_temp_upload is temporary table where as DA_DUEDATE is partitioned table having huge data in it.
Please help
SELECT DISTINCT
batchid,
…

Shriraj
- 133
- 4
- 11
0
votes
1 answer
How to replace user defined function into SELECT clause?
I have a performance issue in my query which takes more than 2 minutes to execute. Currently the main table f_trans has 3 million records.
I have indexed columns in where clause and join condition.
Query :
SELECT f.no AS refno,
…

saran
- 45
- 5
0
votes
1 answer
Setting index in MySql on a Varchar Column
In MySql, I have a UNION query which takes long for execution.
The query looks like
(SELECT id, X, Y , date FROM TABLE WHERE date in (SELECT MIN(date) FROM TABLE WHERE flag = 0 AND id = ? AND date BETWEEN ? AND ?) and id = ? and flag=0 ORDER BY id…

AdityaKapreShrewsburyBoston
- 1,143
- 2
- 16
- 37
0
votes
1 answer
Self Join is making my task run slow in Oracle 11g
I have a table named as event_extra and on that to find duplicates based on some conditions I'd written the following self-join query, but when the records are more(1million) it is taking lot of time.
Table Fields are…

Naveenraja Subramaniam
- 367
- 2
- 6
- 17
0
votes
1 answer
Need to optimize slow query in DB2 using group by on timestamp
Requirement: Number of billing records created Year and provincewise.
Database: DB2 9.5
Below is the query which is used to fetch the details, Its taking huge time, more then 1 hour and getting timedout.
Number of records are as follows in each…

Vinayak Dornala
- 1,609
- 1
- 21
- 27
0
votes
2 answers
SQL Query Performance Tuning
UPDATE nas_backup
SET fiber_serviceability_class = '0',
last_updated_ts = CURRENT_TIMESTAMP
WHERE location_id IN (
SELECT location_id
FROM (
WITH distinct_locs AS (
SELECT location_id, boundary_type
FROM (
SELECT location_id,…

Wamglind Carmasaic
- 163
- 2
- 8
0
votes
1 answer
Improve select statement performance
I'm with an Select performance issue, how can I make this SQL more efficient?
SELECT
O.DT_OCORRENCIA,
S.NU_SMP,
CLI.NM_APELIDO CLI,
TRANS.NM_ENTIDADE TRANS,
TPO.DS_TIPO_OCORRENCIA,
O.DS_OCORRENCIA,
REPLACE(FNC_RETORNA_MOTORISTAS(S.CD_SMP),…

guisantogui
- 4,017
- 9
- 49
- 93
0
votes
0 answers
MySQL read-heavy having problems with inserts and updates on MyISAM
I have a database most tables are in MyISAM and have checked MySQLTuner and tuning-primer to optimize MySQL server variables such as key_buffer_size, max_connections, open_tables limit,etc. Reads are 80% and writes 20%.
I have been having problems…

user1361389
- 55
- 5
0
votes
0 answers
SELECT (MIN) vs ORDER BY ASC WITH FOR UPDATE
I have table test1 (TXID primary key, STATE, NEXTRUN, TARGET) and want to get a row with minimum NEXTRUN for state (passed as input).
Table Data:
-----------
TXID STATE NEXTRUN TARGET
2 KA 2 ANY
1 TN 1 ANY
3 KA 2 ANY
4 TN 3 …

user3544223
- 21
- 3
0
votes
1 answer
Sql performance analysis after migration
I migrate many Oracle DBs to new virtual machines on ESX environment (exactly the same system, DB version etc). My concern is disk IO performance as there is different storage used. I need to perform sql load check before the migration and after to…

Przemek Piechota
- 1,513
- 2
- 12
- 19
0
votes
2 answers
Convert NOT IN query to better performance
I'm using MySQL 5.0, and I need to fine tune this query. Can anyone please tell me what tuning I can do in this?
SELECT DISTINCT(alert_master_id) FROM alert_appln_header
WHERE created_date < DATE_SUB(CURDATE(), INTERVAL (SELECT parameters FROM…

Atanu Pal
- 135
- 2
- 11
0
votes
1 answer
how to improve the performance of query based on view?
I am new to tuning and I am trying hard learn things as Oracle is like an ocean.
I have a query built on views that is running longer. I have query like:
select t2.col1,t2.col2
from vw_tab1 t1,vw_tab1 t2,tab3 t3
where t1.col3=123
and…

user3225011
- 161
- 1
- 2
- 12
0
votes
2 answers
Tuning up a SQL query, (query optimization)
I am trying to tune a SQL query which have IN clause in the query.
I tried replacing IN with Join and looked at the query plans.Both are looking similar in execution times, but the result is different.Can someone help me regarding this?
I am using…

S. N
- 3,456
- 12
- 42
- 65
0
votes
1 answer
How to select id, first_not_null(value1), first_not_null(value2).. on Postgresql
I have a table like this:
+--+---------+---------+
|id|str_value|int_value|
+--+---------+---------+
| 1| 'abc' | |
| 1| | 1 |
| 2| 'abcd' | |
| 2| | 2 |
+--+---------+---------+
I need to get…

Alex
- 1,186
- 10
- 12
0
votes
1 answer
will MySQL highly frequently scheduled query affect database performance?
I have a couple of queries executing every 10 seconds, and both tables are using 'text' data type. I wonder if this will affect database performance? One table is full scan, another one has 'order by' and 'limit' clauses.
Thanks.

user1342336
- 967
- 2
- 16
- 28