I'm currently a junior developer working on a web application with a Java/DB2 backend and I have some SQL queries that run quite slowly. The database right now is not optimized so there's definitely room for improvement. Only problem is that I have no experience with this and no one can help me.
SomeTableName
MyPkey
ColOne
ColTwo
ColThree
ColFour
ColFive
I was trying to figure out how to optimize the database for queries like these:
SELECT * FROM SomeTableName WHERE ColOne = 'some value'
SELECT * FROM SomeTableName WHERE ColOne = 'some value' AND ColTwo = 'another'
SELECT * FROM SomeTableName WHERE ColFive = 11 AND ColThree = 'hello world'
SELECT * FROM SomeTableName WHERE ColOne = 'hi' AND ColTwo = 'val1' AND ColThree = 'val2' AND ColFour = 'val3' AND ColFive = 'val4'
What I'm trying to portray is, the SELECT
statements have WHERE
conditions that have different column combinations and values and I'm not sure how to optimize queries like this.
Any advice?
EDIT: I'm not sure if DB2 adds its own optimizations but for sure there are NO indices setup on any of the columns.