Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

max. time of execution of SQL query

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
orderid, customerid are PK.
SELECT order.orderid, customer.customerid, customer.name, customer.address1, customer.address2, customer.city, customer.state, customer.city, customer.pincode, customer.totalsales
FROM customer, order
WHERE order.customerid = customer.customerid
AND customer.customerid > 10 and customer.customerid < 20000
AND order.status = 'CLOSED'
ORDER BY customer.name DESC;
which part of the query / which operation takes max time of execution?
- prat.
 
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doing an explain plan will give you the best answer to your question as you will get actual numbers to compare. However not knowing more than just the query and the two PKs, I'd say the two places that take the longest are:
AND order.status = 'CLOSED'
ORDER BY customer.name DESC;
1. If status does not have an index, then this will cause a table scan.
2. Order by always takes time, an index on Name will help.
Hope that helps.
Mark
 
Don't listen to Steve. Just read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!