Which is faster [message #353758] |
Wed, 15 October 2008 00:48 |
maheshmhs
Messages: 93 Registered: October 2008 Location: Nepal
|
Member |
|
|
i have to perform copmarision in a very large database.
I would like to know if it is faster to compare individual fields
eg
a.name = b.name and
a.roll = b.roll
Or concatenate them and compare
eg
a.name||a.roll = b.name||b.roll
please respond.
thank you
|
|
|
|
Re: Which is faster [message #353784 is a reply to message #353770] |
Wed, 15 October 2008 01:59 |
maheshmhs
Messages: 93 Registered: October 2008 Location: Nepal
|
Member |
|
|
thanx. but i think i should clarify the situation...
i have two tables say a and c
i have to insert rows from c into a if certain fielddata is not present in a.(say name and roll)
here i create a table b that contains both name and roll from table c.
so,
when i insert , i first compare fields from b and a. if the data is not present in a, i insert the data.
so when inserting, i use
insert into a
(name,roll,...)
from
select
(name, roll,.....)
from c
where
not
exists
(
select * from b
where
a.name = b.name and
a.roll = b.roll
)
---
last two lines is of concern to me.
which one is faster..
a.name = b.name and
a.roll = b.roll
--
or
--
a.name||a.roll = b.name||b.roll
--
|
|
|
|
Re: Which is faster [message #354085 is a reply to message #353801] |
Thu, 16 October 2008 06:45 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
Michel is saying that:
('ABC','DEF') and ('AB','CDEF') are not equal, but
('ABC' || 'DEF') and ('AB' || 'CDEF') ARE equal.
Forget the concatenation. Theoretically, the concatenation is another operator for the engine to perform, and it must also write the result to a new memory location.
Just use the two conditions and try not to over-think it.
Ross Leishman
|
|
|