How to optimize this??
hello,
i wrote this for extracting 9th highest salary from emp table.
SQL> select min(sal) from
2 (select distinct sal from emp
3 where sal is not null
4 order by sal desc)
5 where rownum<=9;
MIN(SAL)
1250
But It has limitation. when we enter rownum more than existing rows then it gives minimum sal which is at the last position. rather than giving error or any different sense.
following is the query which has not satisfied its use in proper.
SQL> select min(sal) from
2 (select distinct sal from emp
3 where sal is not null
4 order by sal desc)
5 where rownum<=40
6 /
MIN(SAL)
800
where 800 is on last positon in 14 rows table.
please optimize and solve my problem.
user8710598 wrote:
only optimize or edit posted query...i knw the rank is given correct ans.That's a little demanding and rude of you. People are trying to help by understanding what you are actually trying to achieve.
Anyway...
SQL> ed
Wrote file afiedt.buf
1 select sal
2 from (
3 select sal, rownum as rn
4 from (
5 select distinct sal
6 from emp
7 order by sal desc
8 )
9 )
10* where rn = 9
SQL> /
SAL
1250
SQL> ed
Wrote file afiedt.buf
1 select sal
2 from (
3 select sal, rownum as rn
4 from (
5 select distinct sal
6 from emp
7 order by sal desc
8 )
9 )
10* where rn = 40
SQL> /
no rows selected
SQL>
Similar Messages
-
How to optimize this select statement its a simple select....
how to optimize this select statement as the records in earlier table is abt i million
and this simplet select statement is not executing and taking lot of time
SELECT guid
stcts
INTO table gt_corcts
FROM corcts
FOR all entries in gt_mege
WHERE /sapsll/corcts~stcts = gt_mege-ctsex
and /sapsll/corcts~guid_pobj = gt_Sagmeld-guid_pobj.
regards
AroraHi Arora,
Using Package size is very simple and you can avoid the time out and as well as the problem because of memory. Some time if you have too many records in the internal table, then you will get a short dump called TSV_TNEW_PAGE_ALLOC_FAILED.
Below is the sample code.
DATA p_size = 50000
SELECT field1 field2 field3
INTO TABLE itab1 PACKAGE SIZE p_size
FROM dtab
WHERE <condition>
Other logic or process on the internal table itab1
FREE itab1.
ENDSELECT.
Here the only problem is you have to put the ENDSELECT.
How it works
In the first select it will select 50000 records ( or the p_size you gave). That will be in the internal table itab1.
In the second select it will clear the 50000 records already there and append next 50000 records from the database table.
So care should be taken to do all the logic or process with in select and endselect.
Some ABAP standards may not allow you to use select-endselect. But this is the best way to handle huge data without short dumps and memory related problems.
I am using this approach. My data is much more huge than yours. At an average of atleast 5 millions records per select.
Good luck and hope this help you.
Regards,
Kasthuri Rangan Srinivasan -
How to optimize this sql by writing MINUS function.
Hi all,
how to optimize the sql by writing MINUS function.
these are my tables
1. CREATE TABLE POSTPAID
RECORD VARCHAR2(2000 BYTE),
FLAG NUMBER
Record format:
Mobile no in 1:10 of that length
2. CREATE TABLE SUBSCRIBER
PHONE_NO VARCHAR2(10 BYTE)
My requirement is following sql need write using ‘minus’ as this one is very slow
select record record from POSTPAID where substr(record,9,10) NOT in (select PHONE_NO from SUBSCRIBER)
ThanksWhy are you very particular about using "MINUS". You can optimize the sql by using "NOT EXISTS" instead of "NOT IN" as below:
SELECT RECORD FROM POSTPAID A WHERE NOT EXISTS (SELECT 1 FROM SUBSCRIBER B WHERE SUBSTR(A.RECORD,9,10) = B.PHONE_NO) -
Performance Tuning Issues ( How to Optimize this Code)
_How to Optimize this Code_
FORM MATL_CODE_DESC.
SELECT * FROM VBAK WHERE VKORG EQ SAL_ORG AND
VBELN IN VBELN AND
VTWEG IN DIS_CHN AND
SPART IN DIVISION AND
VKBUR IN SAL_OFF AND
VBTYP EQ 'C' AND
KUNNR IN KUNNR AND
ERDAT BETWEEN DAT_FROM AND DAT_TO.
SELECT * FROM VBAP WHERE VBELN EQ VBAK-VBELN AND
MATNR IN MATNR.
SELECT SINGLE * FROM MAKT WHERE MATNR EQ VBAP-MATNR.
IF SY-SUBRC EQ 0.
IF ( VBAP-NETWR EQ 0 AND VBAP-UEPOS NE 0 ).
IF ( VBAP-UEPVW NE 'B' AND VBAP-UEPVW NE 'C' ).
MOVE VBAP-VBELN TO ITAB1-SAL_ORD_NUM.
MOVE VBAP-POSNR TO ITAB1-POSNR.
MOVE VBAP-MATNR TO ITAB1-FREE_MATL.
MOVE VBAP-KWMENG TO ITAB1-FREE_QTY.
MOVE VBAP-KLMENG TO ITAB1-KLMENG.
MOVE VBAP-VRKME TO ITAB1-FREE_UNIT.
MOVE VBAP-WAVWR TO ITAB1-FREE_VALUE.
MOVE VBAK-VTWEG TO ITAB1-VTWEG.
MOVE VBAP-UEPOS TO ITAB1-UEPOS.
ENDIF.
ELSE.
MOVE VBAK-VBELN TO ITAB1-SAL_ORD_NUM.
MOVE VBAK-VTWEG TO ITAB1-VTWEG.
MOVE VBAK-ERDAT TO ITAB1-SAL_ORD_DATE.
MOVE VBAK-KUNNR TO ITAB1-CUST_NUM.
MOVE VBAK-KNUMV TO ITAB1-KNUMV.
SELECT SINGLE * FROM KONV WHERE KNUMV EQ VBAK-KNUMV AND
KSTEU = 'C' AND
KHERK EQ 'A' AND
KMPRS = 'X'.
IF SY-SUBRC EQ 0.
ITAB1-REMARKS = 'Manual Price Change'.
ENDIF.
SELECT SINGLE * FROM KONV WHERE KNUMV EQ VBAK-KNUMV AND
KSTEU = 'C' AND
KHERK IN ('C','D') AND
KMPRS = 'X' AND
KRECH IN ('A','B').
IF SY-SUBRC EQ 0.
IF KONV-KRECH EQ 'A'.
MOVE : KONV-KSCHL TO G_KSCHL.
G_KBETR = ( KONV-KBETR / 10 ).
MOVE G_KBETR TO G_KBETR1.
CONCATENATE G_KSCHL G_KBETR1 '%'
INTO ITAB1-REMARKS SEPARATED BY SPACE.
ELSEIF KONV-KRECH EQ 'B'.
MOVE : KONV-KSCHL TO G_KSCHL.
G_KBETR = KONV-KBETR.
MOVE G_KBETR TO G_KBETR1.
CONCATENATE G_KSCHL G_KBETR1
INTO ITAB1-REMARKS SEPARATED BY SPACE.
ENDIF.
ELSE.
ITAB1-REMARKS = 'Manual Price Change'.
ENDIF.
CLEAR : G_KBETR, G_KSCHL,G_KBETR1.
MOVE VBAP-KWMENG TO ITAB1-QTY.
MOVE VBAP-VRKME TO ITAB1-QTY_UNIT.
IF VBAP-UMVKN NE 0.
ITAB1-KLMENG = ( VBAP-UMVKZ / VBAP-UMVKN ) * VBAP-KWMENG.
ENDIF.
IF ITAB1-KLMENG NE 0.
VBAP-NETWR = ( VBAP-NETWR / VBAP-KWMENG ).
MOVE VBAP-NETWR TO ITAB1-INV_PRICE.
ENDIF.
MOVE VBAP-POSNR TO ITAB1-POSNR.
MOVE VBAP-MATNR TO ITAB1-MATNR.
MOVE MAKT-MAKTX TO ITAB1-MAKTX.
ENDIF.
SELECT SINGLE * FROM VBKD WHERE VBELN EQ VBAK-VBELN AND
BSARK NE 'DFUE'.
IF SY-SUBRC EQ 0.
ITAB1-INV_PRICE = ITAB1-INV_PRICE * VBKD-KURSK.
APPEND ITAB1.
CLEAR ITAB1.
ELSE.
CLEAR ITAB1.
ENDIF.
ENDIF.
ENDSELECT.
ENDSELECT.
ENDFORM. " MATL_CODE_DESCHi Vijay,
You could start by using INNER JOINS:
SELECT ......
FROM ( VBAK
INNER JOIN VBAP
ON VBAPVBELN = VBAKVBELN
INNER JOIN MAKT
ON MAKTMATNR = VBAPMATNR AND
MAKT~SPRAS = SYST-LANGU )
INTO TABLE itab
WHERE VBAK~VBELN IN VBELN
AND VBAK~VTWEG IN DIS_CHN
AND VBAK~SPART IN DIVISION
AND VBAK~VKBUR IN SAL_OFF
AND VBAK~VBTYP EQ 'C'
AND VBAK~KUNNR IN KUNNR
AND VBAK~ERDAT BETWEEN DAT_FROM AND DAT_TO
AND VBAP~NETWR EQ 0
AND VBAP~UEPOS NE 0
Regards,
John. -
How to optimize this SQL. Help needed.
Hi All,
Can you please help with this SQL:
SELECT /*+ INDEX(zl1 zipcode_lat1) */
zl2.zipcode as zipcode,l.location_id as location_id,
sqrt(POWER((69.1 * ((zl2.latitude*57.295779513082320876798154814105) - (zl1.latitude*57.295779513082320876798154814105))),2) + POWER((69.1 * ((zl2.longitude*57.295779513082320876798154814105) - (zl1.longitude*57.295779513082320876798154814105)) * cos((zl1.latitude*57.295779513082320876798154814105)/57.3)),2)) as distance
FROM location_atao l, zipcode_atao zl1, client c, zipcode_atao zl2
WHERE zl1.zipcode = l.zipcode
AND l.client_id = c.client_id
AND c.client_id = 306363
And l.appType = 'HOURLY'
and c.milessearchzipcode >= sqrt(POWER((69.1 * ((zl2.latitude*57.295779513082320876798154814105) - (zl1.latitude*57.295779513082320876798154814105))),2) + POWER((69.1 * ((zl2.longitude*57.295779513082320876798154814105) - (zl1.longitude*57.295779513082320876798154814105)) * cos((zl1.latitude*57.295779513082320876798154814105)/57.3)),2))
I tried to optimize it by adding country column in zipcode_atao table. So that we can limit the search in zipcode_atao table based on country.
Any other suggestions.
ThanksWelcome to the forum.
Please follow the instructions given in this thread:
How to post a SQL statement tuning request
HOW TO: Post a SQL statement tuning request - template posting
and add the nessecary details we need to your thread.
Depending on your database version (the result of: select * from v$version; ):
Have you tried running the query without the index-hint?
Are your table (and index) statatistics up-to-date? -
How to optimize this code + is design proper
Well I have to implement tree programming here , what i mean by tree
programming is i have data stored in tree format i,e I have parent
object which will have child objects of same type the level of depth can
go any long:
I am able to store objects in tree format and also able to display properly Here
is code but I am facing problems when i have to filter some child nodes based on some conditions:
I have two question is this code fine is there anything wrong with desin Plus how to handle removing child node in tree scenation where child can be in any place.Below is code
package menu;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.chartis.gp.support.util.BrokerSupportUtil;
import com.chartis.gp.support.vo.Links;
import com.chartis.kernel.user.UserVO;
import com.chartis.kernel.utils.Utils;
public class Utility{
/* IN this class NavModel,CModel,CNode are some dummy classes
* which help us read contents form some resources which are stored in dummy format
* as Example of tree format stored data below is the example
* tree
* child1
* child2
* child3
* child3-1
* child:q
* child:r
* child:a
* child3-2
* child4
private static void populateChildLinks(NavModel navModel, Object objectNode, Links parent ){
try{
List<Links> childLinks = new ArrayList<Links>();
Iterator it = navModel.getChildren( objectNode );
while( it.hasNext() ){
NavNode node = (NavNode) it.next();
CNode contentNode = node.getContentNode();
Links links = new Links();
links.setNodeName( contentNode.getNodeName() );
childLinks.add( links );
if( navModel.hasChildren( node ) ){
populateChildLinks( node, links );
parent.setChildren( childLinks );
catch( Exception e ){
private static Links createCategoryLinks(String categoryLinkName){
Links categoryLinks = new Links();
categoryLinks.setNodeName( categoryLinkName );
return categoryLinks;
public static Links setupLinks(String categoryLinkName,String name) {
Links categoryLinks=null;
CModel contentModel = new CModel();
NavModel navModel = new NavModel();
categoryLinks = Utility.createCategoryLinks( categoryLinkName);
Object objectNode = contentModel.getLocator().findByUniqueName(name);
if( objectNode != null ){
if( navModel.hasChildren( objectNode ) ){
populateChildLinks( navModel,objectNode, categoryLinks );
// This is where i am facing issue once i get list of links of childs
// i have to delete how can i find that particular child in the list
// do i have to iterate through all the links and delete or which
// way is better
private static void filterLinks( Links parentNode,
List<Links> childNodeList ){
List<Links> filteredResourceList = new ArrayList<Links>();
if( childNodeList!=null ){
Iterator<Links> childNodeIt = childNodeList.iterator();
while( childNodeIt.hasNext() ){
Links childNode = (Links) childNodeIt.next();
if(childNode.getChildren().size() >0 ){
filterLinks( childNode, childNode.getChildren() );
boolean removeNode = filterContents( childNode);
if(! removeNode ){
filteredResourceList.add( childNode );
Iterator<Links> filteredResourceIt = filteredResourceList.iterator();
while( filteredResourceIt.hasNext() ){
Links childNode = (Links) filteredResourceIt.next();
parentNode.getChildren().remove( childNode );
// Let us consider this as some dummy method which returns true or false based on some conditions
private static boolean filterContents( menu.Links childNode ){
return false;
package menu;
import java.util.List;
public class Links{
private String nodeName;
private List<Links> children;
public List<Links> getChildren(){
return children;
public void setChildren( List<Links> children ){
this.children = children;
public String getNodeName(){
return nodeName;
public void setNodeName( String nodeName ){
this.nodeName = nodeName;
package menu;
public class TreeDisplay{
public static void main( String[] args ){
Links link = Utility.setupLinks( "SomeName", "ResiyrbceBane");
Utility.filterLinks( link, link.getChildren() );
}Is the utility class with so many static class is ok?Vicky wrote:
Thanks TPD
If you could write more on it , it will be great i rarely find ocasations of using interfaces , however i don't think creating a new tree with valid node could be better solution as you have to create a new tree keeping the same hierarchy .The advantage is that all other components do not need to know that they work with a filtered tree.
Certainly you can do it the other way around bye passing the tree and the filter to eg. the <tt>NotePrinter</tt> Object, but than all components working with the tree meight neet to know that ther are Node filters.
I just came up with the Idea to give the nodes themselfes knowlege of the Filter via <tt>setFilter(Filter<Links> myFilter)</tt>. You would call this on the root node and in the <tt>getChildren()</tt> method you would check if the child apllies to the filter and pass that filter to the eliable childs before putting them into a new collection which is returned to the caller. Ofcause you should initialise the <tt>this.filter</tt> property in <tt>Links</tt> with a <tt>ALL_NODES</tt> constant.
Also you should resist the tamptation to make the <tt>this.filter</tt> property in <tt>Links</tt> static. This would save you one line of code in the <tt>getCildren()</tt> method by the cost that you cannot have different trees with different filters in the same JVM.
This kind of interference between threads is pretty hard to find later in production environments...
bye
TPD -
How to optimize this query?
Hi,
I have this query:
UPDATE t1
SET update_date = SYSDATE
WHERE (col1, col2, col3, col4, col5, col6)
IN (Some SELECT statement that uses GROUP BY)
My issue is that table t1 has a full scan on it. It is big and does not have index on update_date column. Is there anyway to accelerate this query?
Thanks!It is 10g and I am not concerned what is happening in the IN clause..
Plan
UPDATE STATEMENT ALL_ROWSCost: 15,604 Bytes: 216 Cardinality: 1
8 UPDATE t1
7 HASH JOIN RIGHT SEMI Cost: 15,604 Bytes: 216 Cardinality: 1
5 VIEW VIEW SYS.VW_NSO_1 Cost: 4,940 Bytes: 167 Cardinality: 1
4 SORT GROUP BY Cost: 4,940 Bytes: 212 Cardinality: 1
3 HASH JOIN Cost: 4,939 Bytes: 212 Cardinality: 1
1 TABLE ACCESS FULL TABLE t2 Cost: 3 Bytes: 171 Cardinality: 1
2 INDEX FAST FULL SCAN INDEX (UNIQUE) XPKt1 Cost: 4,918 Bytes: 118,869,250 Cardinality: 2,899,250
6 TABLE ACCESS FULL TABLE t1 Cost: 10,646 Bytes: 142,063,250 Cardinality: 2,899,250 -
How to Optimize this code?
Hi All
I have a procedure which runs fine,but since the data in table XYZ,ABC runs into millions it becomes too slow..Can any one guide me in optimising the code.I have already created indexes on these columns.
CREATE OR REPLACE PROCEDURE test AS
CURSOR c1 IS
SELECT
t.cutGrp,
t.cutGrpCode,
t.modelDesc,
t.startdate,
t.enddate,
avg(t.price) price,
avg(t.netprice) netprice,
sum(t.awdQTY) awardqty,
sum(t.planQTY) revplanqty,
FROM
ABC t
GROUP BY
t.cutGrp,
t.cutGrpCode,
t.modelDesc,
t.startdate,
t.enddate;
counter NUMBER := 0;
l_aggregate NUMBER;
BEGIN
FOR rec IN c1
LOOP
counter := counter + 1;
SELECT
sum(t.anotherQTY) INTO l_aggregate
FROM
XYZ t
WHERE
t.cutstomer_Grp = rec.cutGrp
AND t.cutGrp_Code = rec.cutGrpCode
AND t.product_model = rec.modelDesc;
UPDATE XYZ t
SET
t.testQTY = l_aggregate,
t.testprice = rec.price,
t.testnetprice = rec.netprice,
t.testawardQTY = rec.awardqty,
t.testplanQTY = rec.revplanqty,
t.fcstartdate = rec.startdate,
t.fcenddate = rec.enddate
WHERE
t.cutstomer_Grp = rec.cutGrp
AND t.cutGrp_Code = rec.cutGrpCode
AND t.cutGrp_Code = rec.modelDesc;
END LOOP;
COMMIT WORK;
END test;
SHOW ERRORS;Hi All
This the only query i could come up with...But this gives me error
ORA-30926 unable to get a stable set of rows in the source tables.Also this code does not address
SELECT
sum(t.anotherQTY) INTO l_aggregate
FROM
XYZ t
WHERE
t.cutstomer_Grp = rec.cutGrp
AND t.cutGrp_Code = rec.cutGrpCode
AND t.product_model = rec.modelDesc;<b>This is what i came up with </b> so any code help is appreciated
MERGE INTO sgforecastrecord b
USING (
SELECT
cutGrp
cutGrpCode ,
modelDesc,
startdate,
enddate,
avg(price) price,
avg(netprice) netprice,
sum(awdQTY) awardqty,
sum(planQTY) revplanqty
FROM
ABC
GROUP BY
cutGrp,
cutGrp,
modelDesc,
startdate,
enddate
) t
on (
t.cutstomer_Grp = b.cutGrp
AND t.cutGrp_Code = b.cutGrpCode
AND t.product_model = b.modelDesc;
WHEN MATCHED THEN
UPDATE set
b.testprice = t.price,
b.testnetprice = t.netprice,
b.testawardQTY = t.awardqty,
b.testplanQTY = t.revplanqty,
b.fcstartdate = t.startdate,
b.fcenddate = t.enddate
-
How to optimize this SQL?
Hi All!
For example I have to records from a table:
Value1 Value2 Day_ID
000001 000002 20031211
000001 000002 20031219
You can see, that value 1 and 2 are the same in both records. Only Day_IDs are different. So I need to find a record with max(Day_ID). This is my SQL:
select *
from MyTable
where day_id = (select max(day_id) from MyTable)
Is there any way to get the same result without sub select?
Any help will be appreciate.
With best regards,
Andrej Litowka.ORA-00937: not a single-group group functionThen you must have a non-aggregated column in your SELECT clause that is not in your GROUP BY clause.
Let's be careful out there!
APC -
How to optimize this RW code? (full version)
Hello: (Sorry for the wrong previous post, hope the moderator delete it)
I have this code:
import java.io.*;
class Number
private byte val=0;
public void Read(DataInputStream ar) throws Exception {val=ar.readByte();}
public void Read(RandomAccessFile ar) throws Exception {val=ar.readByte();}
public void Write(RandomAccessFile ar) throws Exception {ar.writeByte(val);}
public void Write(DataOutputStream ar) throws Exception {ar.writeByte(val);}
}As you can see, I have methods for storing and writing into RandomAccessFiles and DataStreams. The code for RW is the same for both media. Is there any way to use the same code for Read(DataInputStream ar) and Read(RandomAccessFile ar)? Note that actually my class is more complex and can contain many data for RW: integers, doubles, objects, so that's why I want to simplify it. I thought about this possibility:
public void Read(Object ar) throws Exception
if(ar instanceof RandomAccessFile) val= ((RandomAccessFile)ar).readByte();
if(ar instanceof DataInputStream ) val= ((DataInputStream )ar).readByte();
public void Write(Object ar) throws Exception
if(ar instanceof RandomAccessFile) val= ((RandomAccessFile)ar).writeByte(val);
if(ar instanceof DataOutputStream ) val= ((DataOutputStream )ar).writeByte(val);
}But as you can see I have to make casts and repeat the code, I only got the advantage of having one single method.
Any suggestion?
Thanks!Both DataOutputStream and RandomAccessFile implement the interfaces DataOutput, so you could do:
public void write(DataOutput out) throws Exception
out.writeByte(value);
}(the other case, RandomAccessFile and DataInputStream, use DataInput) -
HELP~~ how to optimize this?!?
hello...
Been cracking my head over this set of 'if...else' statements
is there anyway to further optimise the codes to make it more efficient?
if ( (a == u && b == v && c == w && d == x && e == y && f == z )){ bExist = true; break;}
else if ( (a == u && b == v && c == w && d == x && e == z && f == y )){ bExist = true; break;}
else if ( (a == u && b == v && c == w && d == y && e == x && f == z )){ bExist = true; break;}
else if ( (a == u && b == v && c == w && d == y && e == z && f == x )){ bExist = true; break;}
else if ( (a == u && b == v && c == w && d == z && e == x && f == y )){ bExist = true; break;}
else if ( (a == u && b == v && c == w && d == z && e == y && f == x )){ bExist = true; break;}
else if ( (a == u && b == v && c == x && d == w && e == y && f == z )){ bExist = true; break;}
else if ( (a == u && b == v && c == x && d == w && e == z && f == y )){ bExist = true; break;}
else if ( (a == u && b == v && c == x && d == y && e == w && f == z )){ bExist = true; break;}
else if ( (a == u && b == v && c == x && d == y && e == z && f == w )){ bExist = true; break;}
else if ( (a == u && b == v && c == x && d == z && e == w && f == y )){ bExist = true; break;}
else if ( (a == u && b == v && c == x && d == z && e == y && f == w )){ bExist = true; break;}
else if ( (a == u && b == v && c == y && d == w && e == x && f == z )){ bExist = true; break;}
else if ( (a == u && b == v && c == y && d == w && e == z && f == x )){ bExist = true; break;}
else if ( (a == u && b == v && c == y && d == x && e == w && f == z )){ bExist = true; break;}
else if ( (a == u && b == v && c == y && d == x && e == z && f == w )){ bExist = true; break;}
else if ( (a == u && b == v && c == y && d == z && e == w && f == x )){ bExist = true; break;}
else if ( (a == u && b == v && c == y && d == z && e == x && f == w )){ bExist = true; break;}
else if ( (a == u && b == v && c == z && d == w && e == x && f == y )){ bExist = true; break;}
else if ( (a == u && b == v && c == z && d == w && e == y && f == x )){ bExist = true; break;}
else if ( (a == u && b == v && c == z && d == x && e == w && f == y )){ bExist = true; break;}
else if ( (a == u && b == v && c == z && d == x && e == y && f == w )){ bExist = true; break;}
else if ( (a == u && b == v && c == z && d == y && e == w && f == x )){ bExist = true; break;}
else if ( (a == u && b == v && c == z && d == y && e == x && f == w )){ bExist = true; break;}
else if ( (a == u && b == w && c == v && d == x && e == y && f == z )){ bExist = true; break;}
else if ( (a == u && b == w && c == v && d == x && e == z && f == y )){ bExist = true; break;}
else if ( (a == u && b == w && c == v && d == y && e == x && f == z )){ bExist = true; break;}
else if ( (a == u && b == w && c == v && d == y && e == z && f == x )){ bExist = true; break;}
else if ( (a == u && b == w && c == v && d == z && e == x && f == y )){ bExist = true; break;}
else if ( (a == u && b == w && c == v && d == z && e == y && f == x )){ bExist = true; break;}
else if ( (a == u && b == w && c == x && d == v && e == y && f == z )){ bExist = true; break;}
else if ( (a == u && b == w && c == x && d == v && e == z && f == y )){ bExist = true; break;}
else if ( (a == u && b == w && c == x && d == y && e == v && f == z )){ bExist = true; break;}
else if ( (a == u && b == w && c == x && d == y && e == z && f == v )){ bExist = true; break;}
else if ( (a == u && b == w && c == x && d == z && e == v && f == y )){ bExist = true; break;}
else if ( (a == u && b == w && c == x && d == z && e == y && f == v )){ bExist = true; break;}
else if ( (a == u && b == w && c == y && d == v && e == x && f == z )){ bExist = true; break;}
else if ( (a == u && b == w && c == y && d == v && e == z && f == x )){ bExist = true; break;}
else if ( (a == u && b == w && c == y && d == x && e == v && f == z )){ bExist = true; break;}
else if ( (a == u && b == w && c == y && d == x && e == z && f == v )){ bExist = true; break;}
else if ( (a == u && b == w && c == y && d == z && e == v && f == x )){ bExist = true; break;}
else if ( (a == u && b == w && c == y && d == z && e == x && f == v )){ bExist = true; break;}
else if ( (a == u && b == w && c == z && d == v && e == x && f == y )){ bExist = true; break;}
else if ( (a == u && b == w && c == z && d == v && e == y && f == x )){ bExist = true; break;}
else if ( (a == u && b == w && c == z && d == x && e == v && f == y )){ bExist = true; break;}
else if ( (a == u && b == w && c == z && d == x && e == y && f == v )){ bExist = true; break;}
else if ( (a == u && b == w && c == z && d == y && e == v && f == x )){ bExist = true; break;}
else if ( (a == u && b == w && c == z && d == y && e == x && f == v )){ bExist = true; break;}
else if ( (a == u && b == x && c == v && d == w && e == y && f == z )){ bExist = true; break;}
else if ( (a == u && b == x && c == v && d == w && e == z && f == y )){ bExist = true; break;}
else if ( (a == u && b == x && c == v && d == y && e == w && f == z )){ bExist = true; break;}
else if ( (a == u && b == x && c == v && d == y && e == z && f == w )){ bExist = true; break;}
else if ( (a == u && b == x && c == v && d == z && e == w && f == y )){ bExist = true; break;}
else if ( (a == u && b == x && c == v && d == z && e == y && f == w )){ bExist = true; break;}
else if ( (a == u && b == x && c == w && d == v && e == y && f == z )){ bExist = true; break;}
else if ( (a == u && b == x && c == w && d == v && e == z && f == y )){ bExist = true; break;}
else if ( (a == u && b == x && c == w && d == y && e == v && f == z )){ bExist = true; break;}
else if ( (a == u && b == x && c == w && d == y && e == z && f == v )){ bExist = true; break;}
else if ( (a == u && b == x && c == w && d == z && e == v && f == y )){ bExist = true; break;}
else if ( (a == u && b == x && c == w && d == z && e == y && f == v )){ bExist = true; break;}
else if ( (a == u && b == x && c == y && d == v && e == w && f == z )){ bExist = true; break;}
else if ( (a == u && b == x && c == y && d == v && e == z && f == w )){ bExist = true; break;}
else if ( (a == u && b == x && c == y && d == w && e == v && f == z )){ bExist = true; break;}
else if ( (a == u && b == x && c == y && d == w && e == z && f == v )){ bExist = true; break;}
else if ( (a == u && b == x && c == y && d == z && e == v && f == w )){ bExist = true; break;}
else if ( (a == u && b == x && c == y && d == z && e == w && f == v )){ bExist = true; break;}
else if ( (a == u && b == x && c == z && d == v && e == w && f == y )){ bExist = true; break;}
else if ( (a == u && b == x && c == z && d == v && e == y && f == w )){ bExist = true; break;}
else if ( (a == u && b == x && c == z && d == w && e == v && f == y )){ bExist = true; break;}
else if ( (a == u && b == x && c == z && d == w && e == y && f == v )){ bExist = true; break;}
else if ( (a == u && b == x && c == z && d == y && e == v && f == w )){ bExist = true; break;}
else if ( (a == u && b == x && c == z && d == y && e == w && f == v )){ bExist = true; break;}
else if ( (a == u && b == y && c == v && d == w && e == x && f == z )){ bExist = true; break;}
else if ( (a == u && b == y && c == v && d == w && e == z && f == x )){ bExist = true; break;}
else if ( (a == u && b == y && c == v && d == x && e == w && f == z )){ bExist = true; break;}
else if ( (a == u && b == y && c == v && d == x && e == z && f == w )){ bExist = true; break;}
else if ( (a == u && b == y && c == v && d == z && e == w && f == x )){ bExist = true; break;}
else if ( (a == u && b == y && c == v && d == z && e == x && f == w )){ bExist = true; break;}
else if ( (a == u && b == y && c == w && d == v && e == x && f == z )){ bExist = true; break;}
else if ( (a == u && b == y && c == w && d == v && e == z && f == x )){ bExist = true; break;}
else if ( (a == u && b == y && c == w && d == x && e == v && f == z )){ bExist = true; break;}
else if ( (a == u && b == y && c == w && d == x && e == z && f == v )){ bExist = true; break;}
else if ( (a == u && b == y && c == w && d == z && e == v && f == x )){ bExist = true; break;}
else if ( (a == u && b == y && c == w && d == z && e == x && f == v )){ bExist = true; break;}
else if ( (a == u && b == y && c == x && d == v && e == w && f == z )){ bExist = true; break;}
else if ( (a == u && b == y && c == x && d == v && e == z && f == w )){ bExist = true; break;}
else if ( (a == u && b == y && c == x && d == w && e == v && f == z )){ bExist = true; break;}
else if ( (a == u && b == y && c == x && d == w && e == z && f == v )){ bExist = true; break;}
else if ( (a == u && b == y && c == x && d == z && e == v && f == w )){ bExist = true; break;}
else if ( (a == u && b == y && c == x && d == z && e == w && f == v )){ bExist = true; break;}
else if ( (a == u && b == y && c == z && d == v && e == w && f == x )){ bExist = true; break;}
else if ( (a == u && b == y && c == z && d == v && e == x && f == w )){ bExist = true; break;}
else if ( (a == u && b == y && c == z && d == w && e == v && f == x )){ bExist = true; break;}
else if ( (a == u && b == y && c == z && d == w && e == x && f == v )){ bExist = true; break;}
else if ( (a == u && b == y && c == z && d == x && e == v && f == w )){ bExist = true; break;}
else if ( (a == u && b == y && c == z && d == x && e == w && f == v )){ bExist = true; break;}
else if ( (a == u && b == z && c == v && d == w && e == x && f == y )){ bExist = true; break;}
else if ( (a == u && b == z && c == v && d == w && e == y && f == x )){ bExist = true; break;}
else if ( (a == u && b == z && c == v && d == x && e == w && f == y )){ bExist = true; break;}
else if ( (a == u && b == z && c == v && d == x && e == y && f == w )){ bExist = true; break;}
else if ( (a == u && b == z && c == v && d == y && e == w && f == x )){ bExist = true; break;}
else if ( (a == u && b == z && c == v && d == y && e == x && f == w )){ bExist = true; break;}
else if ( (a == u && b == z && c == w && d == v && e == x && f == y )){ bExist = true; break;}
else if ( (a == u && b == z && c == w && d == v && e == y && f == x )){ bExist = true; break;}
else if ( (a == u && b == z && c == w && d == x && e == v && f == y )){ bExist = true; break;}
else if ( (a == u && b == z && c == w && d == x && e == y && f == v )){ bExist = true; break;}
else if ( (a == u && b == z && c == w && d == y && e == v && f == x )){ bExist = true; break;}
else if ( (a == u && b == z && c == w && d == y && e == x && f == v )){ bExist = true; break;}
else if ( (a == u && b == z && c == x && d == v && e == w && f == y )){ bExist = true; break;}
else if ( (a == u && b == z && c == x && d == v && e == y && f == w )){ bExist = true; break;}
else if ( (a == u && b == z && c == x && d == w && e == v && f == y )){ bExist = true; break;}
else if ( (a == u && b == z && c == x && d == w && e == y && f == v )){ bExist = true; break;}
else if ( (a == u && b == z && c == x && d == y && e == v && f == w )){ bExist = true; break;}
else if ( (a == u && b == z && c == x && d == y && e == w && f == v )){ bExist = true; break;}
else if ( (a == u && b == z && c == y && d == v && e == w && f == x )){ bExist = true; break;}
else if ( (a == u && b == z && c == y && d == v && e == x && f == w )){ bExist = true; break;}
else if ( (a == u && b == z && c == y && d == w && e == v && f == x )){ bExist = true; break;}
else if ( (a == u && b == z && c == y && d == w && e == x && f == v )){ bExist = true; break;}
else if ( (a == u && b == z && c == y && d == x && e == v && f == w )){ bExist = true; break;}
else if ( (a == u && b == z && c == y && d == x && e == w && f == v )){ bExist = true; break;}
else if ( (a == v && b == u && c == w && d == x && e == y && f == z )){ bExist = true; break;}
else if ( (a == v && b == u && c == w && d == x && e == z && f == y )){ bExist = true; break;}
else if ( (a == v && b == u && c == w && d == y && e == x && f == z )){ bExist = true; break;}
else if ( (a == v && b == u && c == w && d == y && e == z && f == x )){ bExist = true; break;}
else if ( (a == v && b == u && c == w && d == z && e == x && f == y )){ bExist = true; break;}
else if ( (a == v && b == u && c == w && d == z && e == y && f == x )){ bExist = true; break;}
else if ( (a == v && b == u && c == x && d == w && e == y && f == z )){ bExist = true; break;}
else if ( (a == v && b == u && c == x && d == w && e == z && f == y )){ bExist = true; break;}
else if ( (a == v && b == u && c == x && d == y && e == w && f == z )){ bExist = true; break;}
else if ( (a == v && b == u && c == x && d == y && e == z && f == w )){ bExist = true; break;}
else if ( (a == v && b == u && c == x && d == z && e == w && f == y )){ bExist = true; break;}
else if ( (a == v && b == u && c == x && d == z && e == y && f == w )){ bExist = true; break;}
else if ( (a == v && b == u && c == y && d == w && e == x && f == z )){ bExist = true; break;}
else if ( (a == v && b == u && c == y && d == w && e == z && f == x )){ bExist = true; break;}
else if ( (a == v && b == u && c == y && d == x && e == w && f == z )){ bExist = true; break;}
else if ( (a == v && b == u && c == y && d == x && e == z && f == w )){ bExist = true; break;}
else if ( (a == v && b == u && c == y && d == z && e == w && f == x )){ bExist = true; break;}
else if ( (a == v && b == u && c == y && d == z && e == x && f == w )){ bExist = true; break;}
else if ( (a == v && b == u && c == z && d == w && e == x && f == y )){ bExist = true; break;}
else if ( (a == v && b == u && c == z && d == w && e == y && f == x )){ bExist = true; break;}
else if ( (a == v && b == u && c == z && d == x && e == w && f == y )){ bExist = true; break;}
else if ( (a == v && b == u && c == z && d == x && e == y && f == w )){ bExist = true; break;}
else if ( (a == v && b == u && c == z && d == y && e == w && f == x )){ bExist = true; break;}
else if ( (a == v && b == u && c == z && d == y && e == x && f == w )){ bExist = true; break;}
else if ( (a == v && b == w && c == u && d == x && e == y && f == z )){ bExist = true; break;}
else if ( (a == v && b == w && c == u && d == x && e == z && f == y )){ bExist = true; break;}
else if ( (a == v && b == w && c == u && d == y && e == x && f == z )){ bExist = true; break;}
else if ( (a == v && b == w && c == u && d == y && e == z && f == x )){ bExist = true; break;}
else if ( (a == v && b == w && c == u && d == z && e == x && f == y )){ bExist = true; break;}
else if ( (a == v && b == w && c == u && d == z && e == y && f == x )){ bExist = true; break;}
else if ( (a == v && b == w && c == x && d == u && e == y && f == z )){ bExist = true; break;}
else if ( (a == v && b == w && c == x && d == u && e == z && f == y )){ bExist = true; break;}
else if ( (a == v && b == w && c == x && d == y && e == u && f == z )){ bExist = true; break;}
else if ( (a == v && b == w && c == x && d == y && e == z && f == u )){ bExist = true; break;}
else if ( (a == v && b == w && c == x && d == z && e == u && f == y )){ bExist = true; break;}
else if ( (a == v && b == w && c == x && d == z && e == y && f == u )){ bExist = true; break;}
else if ( (a == v && b == w && c == y && d == u && e == x && f == z )){ bExist = true; break;}
else if ( (a == v && b == w && c == y && d == u && e == z && f == x )){ bExist = true; break;}
else if ( (a == v && b == w && c == y && d == x && e == u && f == z )){ bExist = true; break;}
else if ( (a == v && b == w && c == y && d == x && e == z && f == u )){ bExist = true; break;}
else if ( (a == v && b == w && c == y && d == z && e == u && f == x )){ bExist = true; break;}
else if ( (a == v && b == w && c == y && d == z && e == x && f == u )){ bExist = true; break;}
else if ( (a == v && b == w && c == z && d == u && e == x && f == y )){ bExist = true; break;}
else if ( (a == v && b == w && c == z && d == u && e == y && f == x )){ bExist = true; break;}
else if ( (a == v && b == w && c == z && d == x && e == u && f == y )){ bExist = true; break;}
else if ( (a == v && b == w && c == z && d == x && e == y && f == u )){ bExist = true; break;}
else if ( (a == v && b == w && c == z && d == y && e == u && f == x )){ bExist = true; break;}
else if ( (a == v && b == w && c == z && d == y && e == x && f == u )){ bExist = true; break;}
else if ( (a == v && b == x && c == u && d == w && e == y && f == z )){ bExist = true; break;}
else if ( (a == v && b == x && c == u && d == w && e == z && f == y )){ bExist = true; break;}
else if ( (a == v && b == x && c == u && d == y && e == w && f == z )){ bExist = true; break;}
else if ( (a == v && b == x && c == u && d == y && e == z && f == w )){ bExist = true; break;}
else if ( (a == v && b == x && c == u && d == z && e == w && f == y )){ bExist = true; break;}
else if ( (a == v && b == x && c == u && d == z && e == y && f == w )){ bExist = true; break;}
else if ( (a == v && b == x && c == w && d == u && e == y && f == z )){ bExist = true; break;}
else if ( (a == v && b == x && c == w && d == u && e == z && f == y )){ bExist = true; break;}
else if ( (a == v && b == x && c == w && d == y && e == u && f == z )){ bExist = true; break;}
else if ( (a == v && b == x && c == w && d == y && e == z && f == u )){ bExist = true; break;}
else if ( (a == v && b == x && c == w && d == z && e == u && f == y )){ bExist = true; break;}
else if ( (a == v && b == x && c == w && d == z && e == y && f == u )){ bExist = true; break;}
else if ( (a == v && b == x && c == y && d == u && e == w && f == z )){ bExist = true; break;}
else if ( (a == v && b == x && c == y && d == u && e == z && f == w )){ bExist = true; break;}
else if ( (a == v && b == x && c == y && d == w && e == u && f == z )){ bExist = true; break;}
else if ( (a == v && b == x && c == y && d == w && e == z && f == u )){ bExist = true; break;}
else if ( (a == v && b == x && c == y && d == z && e == u && f == w )){ bExist = true; break;}
else if ( (a == v && b == x && c == y && d == z && e == w && f == u )){ bExist = true; break;}
else if ( (a == v && b == x && c == z && d == u && e == w && f == y )){ bExist = true; break;}
else if ( (a == v && b == x && c == z && d == u && e == y && f == w )){ bExist = true; break;}
else if ( (a == v && b == x && c == z && d == w && e == u && f == y )){ bExist = true; break;}
else if ( (a == v && b == x && c == z && d == w && e == y && f == u )){ bExist = true; break;}
else if ( (a == v && b == x && c == z && d == y && e == u && f == w )){ bExist = true; break;}
else if ( (a == v && b == x && c == z && d == y && e == w && f == u )){ bExist = true; break;}
else if ( (a == v && b == y && c == u && d == w && e == x && f == z )){ bExist = true; break;}
else if ( (a == v && b == y && c == u && d == w && e == z && f == x )){ bExist = true; break;}
else if ( (a == v && b == y && c == u && d == x && e == w && f == z )){ bExist = true; break;}
else if ( (a == v && b == y && c == u && d == x && e == z && f == w )){ bExist = true; break;}
else if ( (a == v && b == y && c == u && d == z && e == w && f == x )){ bExist = true; break;}
else if ( (a == v && b == y && c == u && d == z && e == x && f == w )){ bExist = true; break;}
else if ( (a == v && b == y && c == w && d == u && e == x && f == z )){ bExist = true; break;}
else if ( (a == v && b == y && c == w && d == u && e == z && f == x )){ bExist = true; break;}
else if ( (a == v && b == y && c == w && d == x && e == u && f == z )){ bExist = true; break;}
else if ( (a == v && b == y && c == w && d == x && e == z && f == u )){ bExist = true; break;}
else if ( (a == v && b == y && c == w && d == z && e == u && f == x )){ bExist = true; break;}
else if ( (a == v && b == y && c == w && d == z && e == x && f == u )){ bExist = true; break;}
else if ( (a == v && b == y && c == x && d == u && e == w && f == z )){ bExist = true; break;}
else if ( (a == v && b == y && c == x && d == u && e == z && f == w )){ bExist = true; break;}
else if ( (a == v && b == y && c == x && d == w && e == u && f == z )){ bExist = true; break;}
else if ( (a == v && b == y && c == x && d == w && e == z && f == u )){ bExist = true; break;}
else if ( (a == v && b == y && c == x && d == z && e == u && f == w )){ bExist = true; break;}
else if ( (a == v && b == y && c == x && d == z && e == w && f == u )){ bExist = true; break;}
else if ( (a == v && b == y && c == z && d == u && e == w && f == x )){ bExist = true; break;}
else if ( (a == v && b == y && c == z && d == u && e == x && f == w )){ bExist = true; break;}
else if ( (a == v && b == y && c == z && d == w && e == u && f == x )){ bExist = true; break;}
else if ( (a == v && b == y && c == z && d == w && e == x && f == u )){ bExist = true; break;}
else if ( (a == v && b == y && c == z && d == x && e == u && f == w )){ bExist = true; break;}
else if ( (a == v && b == y && c == z && d == x && e == w && f == u )){ bExist = true; break;}
else if ( (a == v && b == z && c == u && d == w && e == x && f == y )){ bExist = true; break;}
else if ( (a == v && b == z && c == u && d == w && e == y && f == x )){ bExist = true; break;}
else if ( (a == v && b == z && c == u && d == x && e == w && f == y )){ bExist = true; break;}
else if ( (a == v && b == z && c == u && d == x && e == y && f == w )){ bExist = true; break;}
else if ( (a == v && b == z && c == u && d == y && e == w && f == x )){ bExist = true; break;}
else if ( (a == v && b == z && c == u && d == y && e == x && f == w )){ bExist = true; break;}
else if ( (a == v && b == z && c == w && d == u && e == x && f == y )){ bExist = true; break;}
else if ( (a == v && b == z && c == w && d == u && e == y && f == x )){ bExist = true; break;}
else if ( (a == v && b == z && c == w && d == x && e == u && f == y )){ bExist = true; break;}
else if ( (a == v && b == z && c == w && d == x && e == y && f == u )){ bExist = true; break;}
else if ( (a == v && b == z && c == w && d == y && e == u && f == x )){ bExist = true; break;}
else if ( (a == v && b == z && c == w && d == y && e == x && f == u )){ bExist = true; break;}
else if ( (a == v && b == z && c == x && d == u && e == w && f == y )){ bExist = true; break;}
else if ( (a == v && b == z && c == x && d == u && e == y && f == w )){ bExist = true; break;}
else if ( (a == v && b == z && c == x && d == w && e == u && f == y )){ bExist = true; break;}
else if ( (a == v && b == z && c == x && d == w && e == y && f == u )){ bExist = true; break;}
else if ( (a == v && b == z && c == x && d == y && e == u && f == w )){ bExist = true; break;}
else if ( (a == v && b == z && c == x && d == y && e == w && f == u )){ bExist = true; break;}
else if ( (a == v && b == z && c == y && d == u && e == w && f == x )){ bExist = true; break;}
else if ( (a == v && b == z && c == y && d == u && e == x && f == w )){ bExist = true; break;}
else if ( (a == v && b == z && c == y && d == w && e == u && f == x )){ bExist = true; break;}
else if ( (a == v && b == z && c == y && d == w && e == x && f == u )){ bExist = true; break;}
else if ( (a == v && b == z && c == y && d == x && e == u && f == w )){ bExist = true; break;}
else if ( (a == v && b == z && c == y && d == x && e == w && f == u )){ bExist = true; break;}
else if ( (a == w && b == u && c == v && d == x && e == y && f == z )){ bExist = true; break;}
else if ( (a == w && b == u && c == v && d == x && e == z && f == y )){ bExist = true; break;}
else if ( (a == w && b == u && c == v && d == y && e == x && f == z )){ bExist = true; break;}
else if ( (a == w && b == u && c == v && d == y && e == z && f == x )){ bExist = true; break;}
else if ( (a == w && b == u && c == v && d == z && e == x && f == y )){ bExist = true; break;}
else if ( (a == w && b == u && c == v && d == z && e == y && f == x )){ bExist = true; break;}
else if ( (a == w && b == u && c == x && d == v && e == y && f == z )){ bExist = true; break;}
else if ( (a == w && b == u && c == x && d == v && e == z && f == y )){ bExist = true; break;}
else if ( (a == w && b == u && c == x && d == y && e == v && f == z )){ bExist = true; break;}
else if ( (a == w && b == u && c == x && d == y && e == z && f == v )){ bExist = true; break;}
else if ( (a == w && b == u && c == x && d == z && e == v && f == y )){ bExist = true; break;}
else if ( (a == w && b == u && c == x && d == z && e == y && f == v )){ bExist = true; break;}
else if ( (a == w && b == u && c == y && d == v && e == x && f == z )){ bExist = true; break;}
else if ( (a == w && b == u && c == y && d == v && e == z && f == x )){ bExist = true; break;}
else if ( (a == w && b == u && c == y && d == x && e == v && f == z )){ bExist = true; break;}
else if ( (a == w && b == u && c == y && d == x && e == z && f == v )){ bExist = true; break;}
else if ( (a == w && b == u && c == y && d == z && e == v && f == x )){ bExist = true; break;}
else if ( (a == w && b == u && c == y && d == z && e == x && f == v )){ bExist = true; break;}
else if ( (a == w && b == u && c == z && d == v && e == x && f == y )){ bExist = true; break;}
else if ( (a == w && b == u && c == z && d == v && e == y && f == x )){ bExist = true; break;}
else if ( (a == w && b == u && c == z && d == x && e == v && f == y )){ bExist = true; break;}
else if ( (a == w && b == u && c == z && d == x && e == y && f == v )){ bExist = true; break;}
else if ( (a == w && b == u && c == z && d == y && e == v && f == x )){ bExist = true; break;}
else if ( (a == w && b == u && c == z && d == y && e == x && f == v )){ bExist = true; break;}
else if ( (a == w && b == v && c == u && d == x && e == y && f == z )){ bExist = true; break;}
else if ( (a == w && b == v && c == u && d == x && e == z && f == y )){ bExist = true; break;}
else if ( (a == w && b == v && c == u && d == y && e == x && f == z )){ bExist = true; break;}
else if ( (a == w && b == v && c == u && d == y && e == z && f == x )){ bExist = true; break;}
else if ( (a == w && b == v && c == u && d == z && e == x && f == y )){ bExist = true; break;}
else if ( (a == w && b == v && c == u && d == z && e == y && f == x )){ bExist = true; break;}
else if ( (a == w && b == v && c == x && d == u && e == y && f == z )){ bExist = true; break;}
else if ( (a == w && b == v && c == x && d == u && e == z && f == y )){ bExist = true; break;}
else if ( (a == w && b == v && c == x && d == y && e == u && f == z )){ bExist = true; break;}
else if ( (a == w && b == v && c == x && d == y && e == z && f == u )){ bExist = true; break;}
else if ( (a == w && b == v && c == x && d == z && e == u && f == y )){ bExist = true; break;}
else if ( (a == w && b == v && c == x && d == z && e == y && f == u )){ bExist = true; break;}
else if ( (a == w && b == v && c == y && d == u && e == x && f == z )){ bExist = true; break;}
else if ( (a == w && b == v && c == y && d == u && e == z && f == x )){ bExist = true; break;}
else if ( (a == w && b == v && c == y && d == x && e == u && f == z )){ bExist = true; break;}
else if ( (a == w && b == v && c == y && d == x && e == z && f == u )){ bExist = true; break;}
else if ( (a == w && b == v && c == y && d == z && e == u && f == x )){ bExist = true; break;}
else if ( (a == w && b == v && c == y && d == z && e == x && f == u )){ bExist = true; break;}
else if ( (a == w && b == v && c == z && d == u && e == x && f == y )){ bExist = true; break;}
else if ( (a == w && b == v && c == z && d == u && e == y && f == x )){ bExist = true; break;}
else if ( (a == w && b == v && c == z && d == x && e == u && f == y )){ bExist = true; break;}
else if ( (a == w && b == v && c == z && d == x && e == y && f == u )){ bExist = true; break;}
else if ( (a == w && b == v && c == z && d == y && e == u && f == x )){ bExist = true; break;}
else if ( (a == w && b == v && c == z && d == y && e == x && f == u )){ bExist = true; break;}
else if ( (a == w && b == x && c == u && d == v && e == y && f == z )){ bExist = true; break;}
else if ( (a == w && b == x && c == u && d == v && e == z && f == y )){ bExist = true; break;}
else if ( (a == w && b == x && c == u && d == y && e == v && f == z )){ bExist = true; break;}
else if ( (a == w && b == x && c == u && d == y && e == z && f == v )){ bExist = true; break;}
else if ( (a == w && b == x && c == u && d == z && e == v && f == y )){ bExist = true; break;}
else if ( (a == w && b == x && c == u && d == z && e == y && f == v )){ bExist = true; break;}
else if ( (a == w && b == x && c == v && d == u && e == y && f == z )){ bExist = true; break;}
else if ( (a == w && b == x && c == v && d == u && e == z && f == y )){ bExist = true; break;}
else if ( (a == w && b == x && c == v && d == y && e == u && f == z )){ bExist = true; break;}
else if ( (a == w && b == x && c == v && d == y && e == z && f == u )){ bExist = true; break;}
else if ( (a == w && b == x && c == v && d == z && e == u && f == y )){ bExist = true; break;}
else if ( (a == w && b == x && c == v && d == z && e == y && f == u )){ bExist = true; break;}
else if ( (a == w && b == x && c == y && d == u && e == v && f == z )){ bExist = true; break;}
else if ( (a == w && b == x && c == y && d == u && e == z && f == v )){ bExist = true; break;}
else if ( (a == w && b == x && c == y && d == v && e == u && f == z )){ bExist = true; break;}
else if ( (a == w && b == x && c == y && d == v && e == z && f == u )){ bExist = true; break;}
else if ( (a == w && b == x && c == y && d == z && e == u && f == v )){ bExist = true; break;}
else if ( (a == w && b == x && c == y && d == z && e == v && f == u )){ bExist = true; break;}
else if ( (a == w && b == x && c == z && d == u && e == v && f == y )){ bExist = true; break;}
else if ( (a == w && b == x && c == z && d == u && e == y && f == v )){ bExist = true; break;}
else if ( (a == w && b == x && c == z && d == v && e == u && f == y )){ bExist = true; break;}
else if ( (a == w && b == x && c == z && d == v && e == y && f == u )){ bExist = true; break;}
else if ( (Looks like there are two sets of six variables (a, b, c, d, e, f) and (u, v, w, x, y, x). This code attempts to check if the same six values are included in each set, but not necessarily in the same order so it explicitly checks for every combination. This could be done more efficiently by placing the values in arrays, sorting the arrays, and then comparing. You could also get the same result without sorting by searching the second array for each value of the first.
Here's some code using sorting. It assumes the variables are of type int, but should work for other types.
public static boolean compareValues(int a, int b, int c, int d, int e, int f,
int u, int v, int w, int x, int y, int z) {
int[] array1 = new int[6];
int[] array2 = new int[6];
// load array 1
array1[0] = a;
array1[1] = b;
array1[2] = c;
array1[3] = d;
array1[4] = e;
array1[5] = f;
// load array 2
array2[0] = u;
array2[1] = v;
array2[2] = w;
array2[3] = x;
array2[4] = y;
array2[5] = z;
java.util.Arrays.sort(array1);
java.util.Arrays.sort(array2);
for (int i = 0; i < array1.length; i++) {
if (array1[i] != array2) {
return false;
return true; -
How to optimize this query? Please help
i have one table(argus) having 80,000 rows and another table (p0f) having 30,000 rows and i have to join both table on the basis of time field. the query is as follows
select distinct(start_time),res.port, res.dst_port from (select * from argus where argus.start_time between '2007-06-13 19:00:00' and '2007-06-22 20:00:00') res left outer join p0f on res.start_time=p0f.p0f_timestamp ;
the query is taking very large time . i have created index on the start_time and p0f_timestamp ,it increased the performance but not so much. My date comparisons would vary every time i have to execute a new query.
Plz tell me is there another way to execute such a query to output same results?
plz help me as my records are increasing day by day
Thanks
ShavetaFrom my small testcase it seems that both queries are absolute identical and don't actually take too much time:
SQL> create table argus as (select created start_time, object_id port, object_id dst_port from all_objects union all
2 select created start_time, object_id port, object_id dst_port from all_objects)
3 /
Table created.
SQL> create table p0f as select created p0f_timestamp, object_id p0f_port, object_id p0f_dst_port from all_objects
2 /
Table created.
SQL> create index argus_idx on argus (start_time)
2 /
Index created.
SQL> create index p0f_idx on p0f (p0f_timestamp)
2 /
Index created.
SQL>
SQL> begin
2 dbms_stats.gather_table_stats(user,'argus',cascade=>true);
3 dbms_stats.gather_table_stats(user,'p0f',cascade=>true);
4 end;
5 /
PL/SQL procedure successfully completed.
SQL>
SQL> select count(*) from argus
2 /
COUNT(*)
94880
SQL> select count(*) from p0f
2 /
COUNT(*)
47441
SQL>
SQL> set timing on
SQL> set autotrace traceonly explain statistics
SQL>
SQL> select distinct (start_time), res.port, res.dst_port
2 from (select *
3 from argus
4 where argus.start_time between to_date('2007-06-13 19:00:00','RRRR-MM-DD HH24:MI:SS')
5 and to_date('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS')) res
6 left outer join
7 p0f on res.start_time = p0f.p0f_timestamp
8 ;
246 rows selected.
Elapsed: 00:00:02.51
Execution Plan
Plan hash value: 1442901002
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 21313 | 520K| | 250 (6)| 00:00:04 |
| 1 | HASH UNIQUE | | 21313 | 520K| 1352K| 250 (6)| 00:00:04 |
|* 2 | FILTER | | | | | | |
|* 3 | HASH JOIN RIGHT OUTER| | 21313 | 520K| | 91 (11)| 00:00:02 |
|* 4 | INDEX RANGE SCAN | P0F_IDX | 3661 | 29288 | | 11 (0)| 00:00:01 |
|* 5 | TABLE ACCESS FULL | ARGUS | 7325 | 121K| | 79 (12)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter(TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
HH24:MI:SS')<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS'))
3 - access("ARGUS"."START_TIME"="P0F"."P0F_TIMESTAMP"(+))
4 - access("P0F"."P0F_TIMESTAMP"(+)>=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
HH24:MI:SS') AND "P0F"."P0F_TIMESTAMP"(+)<=TO_DATE('2007-06-22
20:00:00','RRRR-MM-DD HH24:MI:SS'))
5 - filter("ARGUS"."START_TIME">=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
HH24:MI:SS') AND "ARGUS"."START_TIME"<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD
HH24:MI:SS'))
Statistics
1 recursive calls
0 db block gets
304 consistent gets
0 physical reads
0 redo size
7354 bytes sent via SQL*Net to client
557 bytes received via SQL*Net from client
18 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
246 rows processed
SQL>
SQL> select distinct start_time, port, dst_port
2 from argus left outer join p0f on start_time = p0f_timestamp
3 where start_time between to_date ('2007-06-13 19:00:00','RRRR-MM-DD HH24:MI:SS')
4 and to_date ('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS')
5 /
246 rows selected.
Elapsed: 00:00:02.47
Execution Plan
Plan hash value: 1442901002
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 21313 | 520K| | 250 (6)| 00:00:04 |
| 1 | HASH UNIQUE | | 21313 | 520K| 1352K| 250 (6)| 00:00:04 |
|* 2 | FILTER | | | | | | |
|* 3 | HASH JOIN RIGHT OUTER| | 21313 | 520K| | 91 (11)| 00:00:02 |
|* 4 | INDEX RANGE SCAN | P0F_IDX | 3661 | 29288 | | 11 (0)| 00:00:01 |
|* 5 | TABLE ACCESS FULL | ARGUS | 7325 | 121K| | 79 (12)| 00:00:01 |
Predicate Information (identified by operation id):
2 - filter(TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
HH24:MI:SS')<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD HH24:MI:SS'))
3 - access("START_TIME"="P0F_TIMESTAMP"(+))
4 - access("P0F_TIMESTAMP"(+)>=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
HH24:MI:SS') AND "P0F_TIMESTAMP"(+)<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD
HH24:MI:SS'))
5 - filter("ARGUS"."START_TIME">=TO_DATE('2007-06-13 19:00:00','RRRR-MM-DD
HH24:MI:SS') AND "ARGUS"."START_TIME"<=TO_DATE('2007-06-22 20:00:00','RRRR-MM-DD
HH24:MI:SS'))
Statistics
1 recursive calls
0 db block gets
304 consistent gets
0 physical reads
0 redo size
7354 bytes sent via SQL*Net to client
557 bytes received via SQL*Net from client
18 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
246 rows processedCan you show us a similar testcase with explain plan and statistics? -
I don't know how I can optimize this SQL
Dear ALL:
I don't know how I can optimize this SQL.
Is it possible to make a better SQL or PL/SQL?
Please let me know your good thought.
Thank you.
Sincerely,
===========================================================
(SELECT A, B, C, SUM(D) as D, AVG(E) as E
FROM T1, T2
WHERE T1.timestamp BETWEEN TO_DATE('00:00:00','HH24:MI:SS')
AND TO_DATE('01:00:00','HH24:MI:SS')
GROUP BY A, B, C
UNION ALL
(SELECT A, B, C, SUM(D) as D, AVG(E) as E
FROM T1, T2
WHERE T1.timestamp BETWEEN TO_DATE('01:00:01','HH24:MI:SS')
AND TO_DATE('02:00:00','HH24:MI:SS')
GROUP BY A, B, C
UNION ALL
(SELECT A, B, C, SUM(D) as D, AVG(E) as E
FROM T1, T2
WHERE T1.timestamp BETWEEN TO_DATE('02:00:01','HH24:MI:SS')
AND TO_DATE('03:00:00','HH24:MI:SS')
GROUP BY A, B, C
UNION ALL
(SELECT A, B, C, SUM(D) as D, AVG(E) as E
FROM T1, T2
WHERE T1.timestamp BETWEEN TO_DATE('03:00:01','HH24:MI:SS')
AND TO_DATE('04:00:00','HH24:MI:SS')
GROUP BY A, B, C
ORDER BY A ASC, B ASC, C ASC
===========================================================Dear Warren:
Actually, for this query, it takes a few second to complete the query.
But, I have to create several time period and I have to optimize the SQL.
Time period is 1 hour, 30 min, 15 min, 5 min.
That is,
===========================================================
WHERE T1.timstamp BETWEEN TO_DATE('00:00:00','HH24:MI:SS')
AND TO_DATE('01:00:00','HH24:MI:SS')
UNION ALL
WHERE T1.timestamp BETWEEN TO_DATE('23:00:01','HH24:MI:SS')
AND TO_DATE('24:00:00','HH24:MI:SS')
===========================================================
WHERE T1.timstamp BETWEEN TO_DATE('00:00:00','HH24:MI:SS')
AND TO_DATE('00:30:00','HH24:MI:SS')
UNION ALL
WHERE T1.timestamp BETWEEN TO_DATE('23:30:01','HH24:MI:SS')
AND TO_DATE('24:00:00','HH24:MI:SS')
===========================================================
WHERE T1.timstamp BETWEEN TO_DATE('00:00:00','HH24:MI:SS')
AND TO_DATE('00:15:00','HH24:MI:SS')
UNION ALL
WHERE T1.timestamp BETWEEN TO_DATE('23:45:01','HH24:MI:SS')
AND TO_DATE('24:00:00','HH24:MI:SS')
===========================================================
WHERE T1.timstamp BETWEEN TO_DATE('00:00:00','HH24:MI:SS')
AND TO_DATE('00:05:00','HH24:MI:SS')
UNION ALL
WHERE T1.timestamp BETWEEN TO_DATE('23:55:01','HH24:MI:SS')
AND TO_DATE('24:00:00','HH24:MI:SS')
===========================================================
Do you know how this SQL is optimized?
Thank you, -
While syncing my I phone it gets to step six "optimizing " and gets almost to the end and I get a message that itunes has stopped working and has to close. It get to like 1074 of 1138 items to optimize when iTunes quits. Any suggestions on how to fix this?
Same problem here! Moreover, for some reason, the pictures in my iPhone 3GS somehow have been divided into 2 folders, Photos and Medialibrary. And when I open iPhone as a folder through the explorer I can see only the Photos folder, but cannot see the Medialibrary folder which stores the photos taken before updating/upgrading the iPhone and getting separated folders!!! What the hack with all of this?!!! When I connect iPhone to PC it automatically opens iTunes and starts syncronizing it, but at the process of OPTIMIZING the photos (and according to the number of photos it shows, I see that it tries to syncronize that invisible Medialibrary folder) the process suddenly stops and error message pops out Tried the sync test, tried the button DEBUG in that pop out message, but NOTHING HELPS!!! Also, when I open the Medialibrary in my iPhone, the screen get sblack all through scrolling it down, only the video clips are shown there... >.<
So, could you, apple developers, please, explain WHAT THIS PROBLEM IS ABOUT?!!!!!! FIX IT! I am getting ****** of to spend hours at the computer and reading those lame advises which do not help at all! I have my own things to do except reading your support websites. And I payed for the product ready to use, but not a halfproduct which problems should further be solved somehow by users.. -
How I can optimize this SQL query
I require your help, I want to know how I can optimize this query
SELECT
"F42119". "SDLITM" as "Code1"
"F42119". "SDAITM" as "Code2"
"F42119". "SDDSC1" as "Product"
"F42119". "SDMCU" as "Bodega"
Sum ("F42119". "SDSOQS" / 10000) as "Number",
Sum ("F42119". "SDUPRC" / 10000) as "preciou"
Sum ("F42119". "SDAEXP" / 100) as "Value",
Sum ("F42119". "SDUNCS" / 10000) as "CostoU"
Sum ("F42119". "SDECST" / 100) as "Cost"
"F4101". "IMSRP1" as "Division"
"F4101". "IMSRP2" as "classification",
"F4101". "IMSRP8" as "Brand"
"F4101". "IMSRP9" as "Aroma"
"F4101". "IMSRP0" as "Presentation"
"F42119". "SDDOC" as "Type",
"F42119". "SDDCT" as "Document",
"F42119". "SDUOM" as "Unit"
"F42119". "SDCRCD" as "currency"
"F0101". "ABAN8" as "ABAN8"
"F0101". "ABALPH" as "Customer"
"F0006". "MCRP22" as "Establishment"
from "PRODDTA". "F0101" "F0101"
"PRODDTA". "F42119" "F42119"
"PRODDTA". "F4101" "F4101"
"PRODDTA". "F0006" "F0006"
where "F42119". "SDAN8" = "F0101". "ABAN8"
and "F0006". "MCMCU" = "F42119". "SDMCU"
and "F4101". "IMITM" = "F42119". "SDITM"
and "F42119". "SDDCT" in ('RI', 'RM', 'RN')
and CAST (EXTRACT (MONTH FROM TO_DATE (substr ((to_date ('01-01-'| | to_char (round (1900 + (CAST ("F42119". "SDDGL" as int) / 1000))),' DD- MM- YYYY ') + substr (to_char (CAST ("F42119". "SDDGL" as int)), 4,3) -1), 1,10))) AS INT) in : Month
and CAST (EXTRACT (YEAR FROM TO_DATE (substr ((to_date ('01-01-'| | to_char (round (1900 + (CAST ("F42119". "SDDGL" as int) / 1000))),' DD- MM- YYYY ')+ Substr (to_char (CAST ("F42119". "SDDGL" as int)), 4,3) -1), 1,10))) AS INT) in: Year
and trim ("F0006". "MCRP22") =: Establishment
and trim ("F4101". "IMSRP1") =: Division
Group By "F42119". "SDLITM"
"F42119". "SDAITM"
"F42119". "SDDSC1"
"F4101". "IMSRP1"
"F42119". "SDDOC"
"F42119". "SDDCT"
"F42119". "SDUOM"
"F42119". "SDCRCD"
"F0101". "ABAN8"
"F0101". "ABALPH"
"F4101". "IMSRP2"
"F4101". "IMSRP8"
"F4101". "IMSRP9"
"F4101". "IMSRP0"
"F42119". "SDMCU"
"F0006". "MCRP22"
I appreciate the help you can give meIt seems to me that part of fixing it could be how you join the tables.
Instead of the humongous where clause, put the applicable conditions on the join.
You have
from "PRODDTA". "F0101" "F0101"
"PRODDTA". "F42119" "F42119"
"PRODDTA". "F4101" "F4101"
"PRODDTA". "F0006" "F0006"
where "F42119". "SDAN8" = "F0101". "ABAN8"
and "F0006". "MCMCU" = "F42119". "SDMCU"
and "F4101". "IMITM" = "F42119". "SDITM"
and "F42119". "SDDCT" in ('RI', 'RM', 'RN')
and CAST (EXTRACT (MONTH FROM TO_DATE (substr ((to_date ('01-01-'| | to_char (round (1900 + (CAST ("F42119". "SDDGL" as int) / 1000))),' DD- MM- YYYY ') + substr (to_char (CAST ("F42119". "SDDGL" as int)), 4,3) -1), 1,10))) AS INT) in : Month
and CAST (EXTRACT (YEAR FROM TO_DATE (substr ((to_date ('01-01-'| | to_char (round (1900 + (CAST ("F42119". "SDDGL" as int) / 1000))),' DD- MM- YYYY ')+ Substr (to_char (CAST ("F42119". "SDDGL" as int)), 4,3) -1), 1,10))) AS INT) in: Year
and trim ("F0006". "MCRP22") =: Establishment
and trim ("F4101". "IMSRP1") =: Division
INSTEAD try something like
from JOIN "PRODDTA". "F0101" "F0101" ON "F42119". "SDAN8" = "F0101". "ABAN8"
JOIN "PRODDTA". "F42119" "F42119" ON "F0006". "MCMCU" = "F42119". "SDMCU"
JOIN "PRODDTA". "F4101" "F4101" ON join condition
JOIN "PRODDTA". "F0006" "F0006" ON join condition.
Not sure exactly how you need things joined, but above is the basic idea. Remove criteria for joining the tables from the WHERE clause and put them
in the join statements. That might clean things up and make it more efficient.
Maybe you are looking for
-
Customizing MYSITE in SharePoint 2013
In SharePoint 2013 we want our Intranet Home page to be the user's MYSITE. Is it possible to apply the corporate branding to MYSITE and also allow our Corporate Marketing and Communications team to publish corporate news / information, polls, links
-
Rumour has it that Oracle is no longer going to suppor the linux platform for 11i. Is this true?
-
Removing the GENRE window pane in the Browser Window
Does anyone know how (if possible) to *remove the GENRE window* pane in the Browser Window in iTunes 8.x??? This was a check mark ON/OFF in iTunes 7.x Prefs but I can't find it in the 8 version = very annoying indeed since I don't select my music bas
-
Outline a calligraphic stroke doesnt work
I created a swoosh with the pen tool and used a calligraphy brush on the line. When I "create outlines" it only outlines the original stroke, not the calligraphy brush...how do I get the calligraphic brush to be an object (I think Im stating that rig
-
Field Exit for Sales Document Type in VA01
hi i want to do field exit for Sales Document Type in VA01. but i dont know to find the correct exit. pls tell the exit name and the steps to find it. thank u