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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

max. time of execution of SQL query

Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
orderid, customerid are PK.
SELECT order.orderid, customer.customerid,, customer.address1, customer.address2,, customer.state,, customer.pincode, customer.totalsales
FROM customer, order
WHERE order.customerid = customer.customerid
AND customer.customerid > 10 and customer.customerid < 20000
AND order.status = 'CLOSED'
which part of the query / which operation takes max time of execution?
- prat.
Posts: 17344
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'
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.
Don't listen to Steve. Just read this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!