stockton Posted November 16, 2007 Share Posted November 16, 2007 I have the following Oracle SQL statement which takes quite a while to execute. SELECT * FROM ( SELECT TRANS_CODE, Sum(TRANS_CASH_IN) AS SumOfTRANS_CASH_IN FROM TRANSACT WHERE TO_CHAR(TRANS_DATE,'MM')= TO_CHAR(sysdate,'MM') AND ((TRANS_COMMENT) LIKE 'Dacom%') AND ((TRANS_MACHINE_NO) NOT LIKE '7%') GROUP BY TRANS_CODE ORDER BY Sum(TRANS_CASH_IN) DESC; ) WHERE rownum <= 250; Please make suggestions on how it could be made quicker. Quote Link to comment Share on other sites More sharing options...
gizmola Posted November 20, 2007 Share Posted November 20, 2007 Did you do an explain plan and look at that first? Quote Link to comment Share on other sites More sharing options...
Y.O. Posted January 4, 2008 Share Posted January 4, 2008 A simple way to speed it up is using hint: add hint comment /*+ALL_ROWS*/ after each SELECT Quote Link to comment Share on other sites More sharing options...
phporaclehosting Posted January 7, 2008 Share Posted January 7, 2008 i agree about the explain plan, and look at where you could stick an index, or two. remember you can have binary or even three way indexes, but these add complexity and size. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.