开发者

Query performance tuning

I have been asked to implement a technique to achieve better query performance, which is very much new to me.

The technique is:

SELECT tab1.col1
FROM tab1, tab2
WHERE tab1.col1 = tab2.col2
AND tab2.col3 = 'X'
AND tab1.col4 = 'Y';

In the above query,

  1. I need to create two tables as references tables for the ones used above say tab3 for tab1 and tab4 for tab2.
  2. Insert the PK values of tab1 and tab2 respectively into tab3 and tab4.
  3. Add a column in both tab3 and tab4 say 'condition1' and update it with the PK values of the records fetched by the above query.
  4. Use tab3 and tab4 in the queries with a check on column 'condition1' IS NOT NULL.
  5. Write trigger to update this column on any DML on the original tables.

This might seem simple at a glance, but if the same tables are used in N queries with differe开发者_如何学Pythonnt predicates, I need to add N number of columns in the new tables and corresponding triggers.

I believe, this is a duplication of data and a huge burden on the database. And this won't contribute to performance improvement.

It will be great if you can help me come out of the dilemma of implementing this.

Thanks in Advance, Savitha


Have you made sure that you are using indexes properly?


This kind of performance tuning looks like a bad idea. It looks like a silly way of recreating an index system. I would advise against it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜