473,805 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2187

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

Similar topics

11
2278
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 length. The sending page allows the user to choose which search criteria he wants, so this (and many other) pieces of the select statement may or may not be present. The statement always starts with SELECT * from logdata where driver =...
2
4896
by: Brent | last post by:
The database has four tables (-> = fields): Account -> AccountID, ClientID, (others) Security -> SecurityID, AccountID, (others) SecurityTransactions -> SecurityID, Shares, (others) SecurityPrices -> SecurityID, PriceDate, Price, (others) Account and Security are connected by the AccountID key. Security, SecurityTransactions, and SecurityPrices are connected by the SecurityID key.
5
1885
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 if i take the last line out. So the query looks like: select *
3
4857
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 or MFC C++) it takes around 1 second to get the recordset and then around 10-15 seconds to iterate through the recordset. This speed remains the same even if I incorporate an ORDER BY clause: SELECT * FROM myTable ORDER BY customer_id,...
17
5033
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 cust_no, ded_type_cd, chk_no)
6
26557
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 regards
8
4725
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", "krbtgt", "quality7" ' don't show
2
3251
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 neccessary). question 1) The selects can use anything : views, stored procedures, analytic functions, etc...
4
2282
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 value="2">2</option>
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10361
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9179
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5676
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.