Help with optimizing SQL queries...?
-
Hi, I am struggling a bit with optimizing some of my SQL queries....any help would be appreciated. Some of my queries are: select srcip,count(*) from ((select srcip from packets,tcp where tcp.id=packets.id and tcp.destport!=445) UNION ALL (select srcip from packets where packettype IN (1,17))) as list group by list.srcip order by count desc (SELECT srcip,count(*) as count FROM packets WHERE packettype=6 GROUP BY srcip ORDER BY count desc LIMIT 20) INTERSECT (SELECT srcip,count(*) as count FROM packets WHERE packettype=17 GROUP BY srcip ORDER BY count desc LIMIT 20) select srcip,count(*), LOG(256,abs(srcip - inet '192.4.2.128')) from packets,tcp WHERE packettype=6 AND packets.id=tcp.id AND tcp.destport=22 group by srcip order by count desc Limit 20 Thanks...
-
Answer:
For the first one you could replace the UNION ALL with an outer join but there's no way that I can tell whether or not that will be any better. But general help: ensure join columns are indexed, try to do everything in 1 query rather than combining results with UNION ALL or INTERSECT, sorting is expensive try to avoid it if possible. For some Oracle SQL tuning tips see http://www.asktheoracle.net/oracle-sql-tutorial.html
spiderpi... at Yahoo! Answers Visit the source
Related Q & A:
- How To Repair Sql Database?Best solution by Ask.com old
- Are SQL Injection vulnerabilities in a PHP application acceptable if mod_security is enabled?Best solution by Programmers
- How can I optimize this dynamic SQL query in oracle with PL/SQL?Best solution by docs.oracle.com
- Why won't my @media queries work?Best solution by stackoverflow.com
- How to solve different queries?Best solution by infoworld.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.