472,978 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

"NOT IN" performance

HI all
I have the following problem
Table SOURCE has columns <char COL1, integar COL2> and has rows

{A,1},
{A,2,},
{,A,3},
{B,1},
{B,2},,
{C,1},
{C,2},
{C,3},
{D.1}
And table TARGET is empty
Lets the rows have the same COL1i s a group
for example {A,1},{A,2},{A,3} is a group

I want to insert into TARGET all rows in SOURCE which haven't minimum COL2 in its group
These rows are
{A,2,},
{,A,3},
{B,1},
{B,1},,
{C,2},
{C,3},

My solution is
INSERT INTO TARGET {COL1,COL2..)
FROM
SELECT {COL1,COL2)
FROM SOURCE
WHERE ROWID NOT IN
(
SELECT MIN(COL2),ROWID
FROM SOURCE
GROUP BY COL1
);


I want to know if the “NO INT” statement will require full table access every ROWID or ORCALE is smart enough to execute the select statement into NOT IN once and sort it by ROWID and then every time check if ROWID in it or not using binary search
That's just an example but in the real case I have many columns instead of COL1 and many columns instead of COL2 and also I have additional columns in SOURCE table.
The SOURCE table has about 84000 rows and TARGET is empty initially
Do you have any better solution (fastest)?

Thanks and Regards
Yours Mohamed Saleh
C++ Developer
www.itsoft.com.eg
Jul 9 '07 #1
2 2005
debasisdas
8,127 Expert 4TB
ORCALE is smart enough to execute the select statement into NOT IN once and sort it by ROWID .
Jul 9 '07 #2
debasisdas
8,127 Expert 4TB
performance wise using IN might be slow,try to use EXIST instead.
Jul 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: petermichaux | last post by:
Hi, On my computer apache will see php in .php documents but not in .html documents. Can I configure apache to see php in .html documents? Or is this something that cannot be done at all? ...
5
by: Chad Richardson | last post by:
Is there a way in SQL Server 2000 to extract data from a table, such that the result is a text file in the format of "Insert Into..." statements, i.e. if the table has 5 rows, the result would be 5...
13
by: gary | last post by:
Hi, We all know the below codes are dangerous: { int *p = new int; delete p; delete p; } And we also know the compilers do not delete p if p==NULL. So why compilers do not "p = NULL"...
4
by: Jacinle Young | last post by:
Hi all, I have written the SQL but it doesn't work db2 "select acode from t1 where (acode) not in (select eid from t2 where iid ='0') and iid ='0'" select nothing but the following works
59
by: Rico | last post by:
Hello, I have an application that I'm converting to Access 2003 and SQL Server 2005 Express. The application uses extensive use of DAO and the SEEK method on indexes. I'm having an issue when...
5
by: yeoj13 | last post by:
Hello, I have a db2load script I'm using to populate a large table. Ideally, my target table is required to have "Not Null" constraints on a number of different columns. I've noticed a ...
1
by: aiyaonline | last post by:
I like to know if the following makes any performance issue. select field_1 from table_1 where country ='USA'; (or) select field_1 from table_1 where country in ('USA'); The reason behind is:...
6
by: =?Utf-8?B?SmVmZg==?= | last post by:
I thought this would already be covered here, but my search turned up nothing. In VS2005, if I use "String" to define a new variable/class, it colors it in the Aqua color as it does other...
4
by: fran7 | last post by:
Hi, from help in the javascript forum I found the error in some code but need help. This bit of code works perfectly, trouble is I am writing it to a javascript function so the height needs to be in...
350
by: Lloyd Bonafide | last post by:
I followed a link to James Kanze's web site in another thread and was surprised to read this comment by a link to a GC: "I can't imagine writing C++ without it" How many of you c.l.c++'ers use...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.