ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Performance benefit between CARDINALITY and EXISTS

Post new topic  Reply to topic
 Performance benefit between CARDINALITY and EXISTS « View previous topic :: View next topic » 
Author Message
ghoshly
PostPosted: Mon Aug 12, 2013 7:33 am    Post subject: Performance benefit between CARDINALITY and EXISTS Reply with quote

Partisan

Joined: 10 Jan 2008
Posts: 333

Hello,

We say that cardinality function does not has good performance. What about EXISTS ?

Option a. IF CARDINALITY(RF_Temp.GetInfo[]) > 0 THEN


Option b. IF EXISTS(RF_Temp.GetInfo[]) THEN

Is Option b is much faster, or both are similar ??

WMB 8.0.0.2
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Mon Aug 12, 2013 7:36 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

When you time each, what are your results?

Why post a question when you can measure your own performance and draw your own conclusions in about ten minutes?

We don't have access to the rest of your code, so we cannot run these tests.

Only you can.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
McueMart
PostPosted: Mon Aug 12, 2013 7:59 am    Post subject: Reply with quote

Chevalier

Joined: 29 Nov 2011
Posts: 490
Location: UK...somewhere

I would guess the performance of CARDINALITY would vary based on the number of elements in the GetInfo[], whereas I would guess the EXISTS wouldn't. If there is only 1 or 2 elements in your array you would probably barely notice a difference.

Best practice is to go with EXISTS though.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Aug 12, 2013 8:02 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

I'd guess that there's never a reason to count all of the children of a tree just to find out if there's at least one child of the tree.
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Aug 12, 2013 1:52 pm    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

mqjeff is correct. The info center explicitly says that EXISTS is faster than CARDINALITY : http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ak05535_.htm

There is one non-obvious detail, though. Suppose that you want to efficiently test whether the (large) complex element 'elementWithManyChildren' exists. The obvious test is
Code:
IF EXISTS(InputRoot.XMLNSC.rootElement.elementWithManyChildren) ...

but actually this can be much faster:
Code:
IF EXISTS(InputRoot.XMLNSC.rootElement.elementWithManyChildren.*[1]) ...

The first parses all of the large, complex tag. The second only parses its first child. This behaviour is technically correct - 'elementWithManyChildren' cannot really be said to 'exist' unless all of it can be parsed successfully. But if Parse Timing is 'On Demand' then testing for the existence of the first child might be much faster.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
ghoshly
PostPosted: Mon Aug 12, 2013 5:51 pm    Post subject: Thank you.... Reply with quote

Partisan

Joined: 10 Jan 2008
Posts: 333

Thank you Kimbert and all for the detailed explanation. It really helps.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Performance benefit between CARDINALITY and EXISTS
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.