Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is length of SQL query important?  RSS feed

 
Miri Yusifli
Ranch Hand
Posts: 42
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I write code in java , i can write sql query in 2 conditions , but short sql query is very diffucult for java . what is the difference between short sql query and long sql query ? they print same results. Which code Should i use ?
 
Claude Moore
Ranch Hand
Posts: 911
9
IBM DB2 Java Netbeans IDE
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch! As far as I know, length of a sql statement doesn't affect query performance by itself. Performance depends upon factors like proper indexing of tables, quality of this query optimizer and so on.
 
Dave Tolls
Ranch Foreman
Posts: 2996
37
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not too sure what you mean by "short sql query is very difficult for java".

The way to compare the efficiency of two queries is to use the database tools (eg EXPLAIN PLAN in Oracle) which allow you to see the plan that has been generated for the query.
This takes some experience, though.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!