The following articles mainly focus on Oracle Table query optimization. This article uses three related tables, namely, Table A, table B, and Table C, for demonstration, you can use the following articles to learn about its practical application and functions. The following is a detailed introduction of the article.
There are more than 2000 rows in Table
Table B, 15 million rows
Table C, rows
The database is Oracle9I.
Currently, Table A connects to table B and table B connects to Table C for query. However, after analysis, Oracle always plans to generate MERGE JOIN for tables A and C, you must know that table A is not associated with Table C and can only generate Cartesian sets. In this way, 2000*180000 records will be generated, resulting in a significant reduction in query performance and a huge temporary table.
Is there any good way to enable Table A to connect table B first and then to Table C, or B to connect to Table C first and then to Table.
Note: All connected fields have independent indexes.
The statement is as follows:
- SELECT A.*
- FROM A ,B,C
- WHERE A.COL_A = B.COL_B1 AND B.COL_B2 = C.COL_C
- SELECT A.*
- FROM A JOIN (B JOIN C ON (B.COL_B2 = C.COL_C)) ON (A.COL_A = B.COL_B1)
- SELECT A.*
- FROM (A JOIN B ON A.COL_A = B.COL_B1) JOIN C ON B.COL_B2 = C.COL_C
The above content is a description of the Oracle Table query optimization problem. I hope it will help you in this regard.