Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: select from a huge table
J.K. ¼¶¼g©ó¤å³¹ <74hev1$7dr$1_at_news.res.ray.com>...
>PLEASE HELP !!!!!
>I have a table about 7,000,000 records.
>I get 12 records if I use "select * from mytable where f1 = 'ref1'";
>but, my question is I need to use the following statement:
>select c1.f1, c1.f2,c1.f3 from mytable c1, mytable c2
^^^^^^^^^^^^^^^^^^^^^
It seems that you miss a criterion " c1.f1=c2.f1 ".
If so, you may create a index on the column f1, the running time will less
than 1 second.
If not, go on.
Notice the "FROM" clause:
In your original SQL statement, it will take 7000000*7000000 steps using
nested loop to find the result. You know, the " c1.f1='ref1' " criterion
distills 12 row from 7000000 rows. If you change the table order in
FROM clause, (i.e., rewrite to "from mytable c2, mytable c1"),
it will take 7000000+12*7000000 steps to find out the result.
Just doing this can significantlly reduce the running time.
Hope this helps. Received on Tue Dec 08 1998 - 07:16:03 CST
![]() |
![]() |