0

Resource 128 GB RAM, 6 TB space, Sql server 2014 enterprise.

Problem: Our DB has few tables including 5 'read only tables' of 200GB(approx) each. Each of these 5 tables have 5 columns (all columns(varchar 100)). Each col have repeated strings or values. Two columns (col3 and col4) have approx 3500 unique strings or values that are repeating.

Our only query is 'select col1......(all columns) from table x where col1 like 'searchstring%' or col2 like 'searchstring%' (only two col are queried for OR clause) as these are the only match criteria.

Presently query is taking 1hour to 1.5hrs to return results with present index. I am wondering if there is an efficient way to get result within 5 to 10 minutes. Thanks

prashant
  • 2,181
  • 2
  • 22
  • 37

2 Answers2

1

Go in SQL Server Managment Studio and look at the execution plan for the query. This will show you any recommended index(s) as well as the rate limiting steps (say io). Make sure you have no cardinality mismatching and on large tables make sure that you are keeping your statistics up to date.

bumble_bee_tuna
  • 3,533
  • 7
  • 43
  • 83
0

It all rather depends on your database but I suggest trying splitting the query in 2 to remove the OR.

I also recommend investigating functional indexes, you might be able to index on the first 10 character for instance and then the query may be faster.

Try everything, you never know what will work.