473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Select statement return result very slow

Hi Uthuras,

it would be helpful to see the access path. However sometimes it makes
sense to rewrite a "not in" to gain better access paths:

I tried the following - hopefully similar - statements in my
environment. Watch the timerons of the different ways to get the same
result set:

Your Original:
61328199680 Timerons
NOT IN to NOT EXISTS:
113382 Timerons

select count(*)
from dss.fncsvcar a
where not exists (select 1 from dss.ar b where b.ar_id=a.ar_id)
NOT IN to 0=(count(*):
52955704 Timerons

select count(*)
from dss.fncsvcar a
where 0=(select count(*) from dss.ar b where b.ar_id=a.ar_id)
NOT IN flattened (my favorite one):
87563 Timerons

select count(*) from dss.fncsvcar a left outer join dss.ar b
on a.ar_id=b.ar_id
where b.ar_id IS NULL
Please check the result if you want to use one of the above
statements, i haven't doublechecked them :)

cheers
Florian

(mybe this post opens a new thread, i got a problem with the google
news-function,sorry for that)

hi all,

One of my customer having warehouse database running on DB2. Recently
when they execute the following query at db2 command line
the exepected result take ages before return result

select count(*) from dss.fncsvcar where ar_id no in (select ar_id fromdss.ar)

Both tables ar_id is not a key field. However, indexes are created
the following order

fncsvcar
--------
create index dss.fncsvcaridx on dss.fncsvcar(ar_id asc);

ar
---
create unique index dss.aridx on dss.ar(ar_id asc);
The fncsvcar table has 3 million records and ar table has 7 million
records. Is there any other way to improve this query?

Nov 12 '05 #1
0 2159

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Jeff Sandler | last post by:
I need a MySQL select statement as part of a PHP script. I want to find rows where a certain column either starts with or equals a user-supplied string. The string will be 1 or more characters in...
2
by: Brent | last post by:
The database has four tables (-> = fields): Account -> AccountID, ClientID, (others) Security -> SecurityID, AccountID, (others) SecurityTransactions -> SecurityID, Shares, (others)...
5
by: eddie wang | last post by:
hello, I have the following query. it returns result in less than 1 second. select * from employee e, address a where e.id=a.emp_id and e.id=1234 The problem is that it becomes extremely slow...
3
by: dror | last post by:
Hello, I have a problem that actually doesn't even make sense. I have 4 million rows in my database. I want to get all records into a DataReader and then read. So if I do it in DAO (either in VB...
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
6
by: Terentius Neo | last post by:
Is it possible to combine (in DB2 UDB 8.1) a stored procedure and a select statement? I mean something like this: Select c.number, call procedure( c.number ) as list from table c With best...
8
by: | last post by:
Hello, This is gonna sound real daft, but how do I test a Select Case statement for variants of a theme? Here's a snippet of my code... Select Case sUsr Case "Guest", "TsInternetUser",...
2
by: Eitan | last post by:
Hello, I want a solutions for a compicateds sql select statments. The selects can use anything : views, stored procedures, analytic functions, etc... (not use materialized view, unless it is...
4
by: Ian Richardson | last post by:
Hi, The function I've put together below is a rough idea to extend a SELECT list, starting from: <body> <form name="bambam"> <select id="fred"> <option value="1">1</option> <option...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.