Questions tagged [query-tuning]
123 questions
0
votes
2 answers
Slow performing query, looking for ideas for solution
I'm using SQL Server 2008.
I have a view called testView
In the view one of the columns is using another query taken from this page - http://www.simple-talk.com/sql/t-sql-programming/concatenating-row-values-in-transact-sql/
ie along this…

gotsp
- 285
- 1
- 3
- 8
0
votes
2 answers
Indexing for complex predicates
I'm struggling to identify effective indexes (or rewrite the query) to improve a query with the following confounding predicates:
JOIN on a date from one table being in range - between two date fields on second table (one is nullable, one is not…

Joe Shark
- 688
- 4
- 9
0
votes
2 answers
NVL function not using index rather FTS, is it possible to modify the query
MY query like below
select nvl(a.value1,nvl(b.value1,nvl(c.value1,''))
from table1 a, table2 b table3 c
where a.value2=b.value2 and b.value3=c.value3
As this query contains a nvl function which tables the value1 from three of my tables it is…
0
votes
1 answer
Low cardinality index with uneven distribution of possible values
I have a table that's used as a queue:
create table items
(
itemId int, -- PK, identity
status int, -- Possible values: 0 = Pending, 1 = Processing, 2 = Processed
createdAt datetime2,
updatedAt datetime2,
content …

ubi
- 4,041
- 3
- 33
- 50
0
votes
1 answer
Query rewrite and Tuning
I have the below query that is the cause of performance degradation, can someone help to rewrite this query so that it could perform…

Dothertechie
- 27
- 6
0
votes
0 answers
optimizing a really long code with a lot of JOINS on Redshift
I need help with a really long existing code that runs on Amazon Redshift. It is returning a WLM timeout therefore I need to optimize or improve it somehow so it won't get the WLM anymore.
Here is the…
0
votes
0 answers
Oracle tune query by using of temp table
I want to remove redundant call for count in the below mentioned stored procedure and rather want to use a temp table and use the temp table to return in cursor
procedure status(p_order_id in varchar2, p_stat out sys_refcursor) is
l_count…

Sudipto Sarkar
- 346
- 2
- 11
0
votes
1 answer
need help in re-writing this query, which uses same data set multiple times, as per explain plan
We have a query run by our development team that's heavy in resources and looking at the explain plan, it looks like its uses the same data set multiple times. Is there anyway we can re-write this query.
Now, i tried to replace the co-related query…

Kumar
- 119
- 10
0
votes
1 answer
SQL Query takes a long time when filtering recent rows
I have this SQL query, but I've found that it can take up to 11 seconds to run. I'm really confused because when I change the date selection to a 2018 date, it returns instantly.
Here's the query:
select
cv.table3ID, dm.Column1 ,dm.Column2,…

Sathya
- 155
- 1
- 5
- 18
0
votes
1 answer
User session stuck in killed\rollback state
One of the session that is executing a stored proc from an application is stuck in the killed\rollback phase. Arguably, it shouldn't be this long for the sproc to rollback and it has been stuck there for an eternity. Basically, the sproc is a bunch…

Feivel
- 111
- 4
0
votes
1 answer
Is it safe to run explain on production database
We have many hive queries that take lot of time on production
most of them are insert queries.
want to check the execution plan and table related data so we are thinking of checking the plan of this query
is it safe to run "explain insert into…

Kumar
- 119
- 10
0
votes
1 answer
Most efficient way to filter a table with 1 to many parent and child mappings
I have a client table which with a foreign key to itself where each client has a specific id in each department but one master id. I am trying to find the most efficient way to restrict my query to just the master entry.
Here are the two…

bab245
- 11
- 1
0
votes
0 answers
Oracle Subquery Factoring Not Working For Function Call
I'm using Oracle 11g. I have a query that takes 6 seconds to execute
select *
from tab1
where exists (select 1
from tab2
where tab2.col1 = tab1.col1
and tab2.col2 = pkg1.fn1('STRING'));
The highlighted…

Nikhil
- 163
- 2
- 14
0
votes
3 answers
how to tune this view?fetching time takes 9.968 but i want in .5. so how to give better performance
SELECT
/*+ INDEX(ID_BL_REF_NO REF_number_BL_idx*/ DECODE(BL_TYPE,'E',BL_ORIGIN_NAME,'I',BL_FINAL_NAME) FROM_PORT,
DECODE(BL_TYPE,'I',BL_ORIGIN_NAME,'E',BL_FINAL_NAME) TO_PORT,
(BL_VESSEL_CONNECT||'/'||BL_VOYAGE_CONNECT||'/'||BL_PORT_CONNECT)…

Ranjith Kumar
- 51
- 2
- 5
0
votes
1 answer
Key Lookup using columns outside of the index in SQL Query
I have a query as follows
SELECT ActivityId,
AnotherId,
PersonId,
StartTime AS MyAlias
FROM Activity
WHERE DeletedStatus='Active' AND
StartTime>='2018-02-01'AND StartTime<='2018-02-08'
The execution plan being used is…

SE1986
- 2,534
- 1
- 10
- 29