الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

long running query

Featured Replies

بتاريخ:

I have problem with the execution of below SQL command; it take a lot of time; when I checked the execution plan show me that it make the full table scan because I am using (NOT IN)
Please advice me if you have idea regarding this issue.

==============

select  t1.aa 
from   t1
where  t1.c  not in ( select  t2.c
      ( from t2
note that there is index on the FK


==============

بتاريخ:

NOT IN و IN

من احد اعداء optimizer ولن تجعله يقوم باستخدام index وعوض عنها بامكانك استخدام !=

لاحظ من المثال التي كيف الفرق وخاصه في Cost و الوقت



select id from .t1
where id not in (select id from .t2);


---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |  1379K|  9429K|  2255K  (1)| 07:31:06 |
|*  1 |  FILTER            |      |       |       |            |          |
|   2 |   TABLE ACCESS FULL| T1   |  1379K|  9430K|  4374   (2)| 00:00:53 |
|*  3 |   TABLE ACCESS FULL| T2   |     1 |     7 |     2   (0)| 00:00:01 |
---------------------------------------------------------------------------


select id from t1
where id !=(select id from t2);

----------------------------------------------------------------------------------
| Id  | Operation            | Name      | Rows  | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------
|  0 | SELECT STATEMENT     |           | 68974 |   471K|   653   (4)| 00:00:08 |
|* 1 |  INDEX FAST FULL SCAN| T1_ID_IDX | 68974 |   471K|   651   (4)| 00:00:08 |
|  2 |   TABLE ACCESS FULL  | T2     |     1 |     7 |     2   (0)| 00:00:01 |
----------------------------------------------------------------------------------


بتاريخ:
  • كاتب الموضوع

اشكرك يا ابوصالح على استجابتك السريعة ، ولكن المشكلة انه لا يمكن استخدام != لأن subquery يرجع اكثر من قيمة single-row subquery returns more than one row

بتاريخ:
  • كاتب الموضوع

لقد قمت باستخدام NOT EXISTS عوضاً عن NOT IN وهو نوعاً ما افضل

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.