Created a compount column index on columns temp_jp(col1,col2,col3). Do I need to use all these three columns in my compound column index for better performance? What will be the impact if I use the columns col1 only OR col1 and col3, in my queries' where condition? To answer these questions, I ran the following queries A-D on my table and the resultant values for each of the tests were tabulated hereunder: Between each query's execution, the db was restarted. TEST TEST TEST TEST
A) select count(1) from temp_jp where col1=890343; B) select count(1) from temp_jp where col1=890343 and col3='VEEKSHA'; C) select count(1) from temp_jp where col1=890343 and col2 is not null and col3='VEEKSHA'; D) select count(1) from (select col3 from temp_jp where col1=890343) where col3='VEEKSHA';
LATCH.AQ deq hash table latch LATCH.ASM db client latch LATCH.ASM map operation hash table LATCH.ASM network state latch LATCH.Change Notification Hash table latch LATCH.Consistent RBA LATCH.DML lock allocation LATCH.Event Group Locks LATCH.FOB s.o list latch LATCH.File State Object Pool Parent Latch LATCH.I/O Staticstics latch LATCH.IPC stats buffer allocation latch LATCH.In memory undo latch LATCH.JS Sh mem access LATCH.JS queue access latch LATCH.JS queue state obj latch LATCH.JS slv state obj latch
1 40 1 1 20 9 25 1 3 1 1 1 44 1 1 432 -3
LATCH.KFC FX Hash Latch LATCH.KFC Hash Latch LATCH.KFCL LE Freelist LATCH.KGNFS-NFS:SHM structure LATCH.KGNFS-NFS:SVR LIST LATCH.KJC message pool free list LATCH.KJCT flow control latch LATCH.KMG MMAN ready and startup request latch LATCH.Locator state objects pool parent latch LATCH.Lsod array latch LATCH.Memory Management Latch LATCH.Memory Queue LATCH.Memory Queue Message Subscriber #1 LATCH.Memory Queue Message Subscriber #2 LATCH.Memory Queue Message Subscriber #3 LATCH.Memory Queue Message Subscriber #4 LATCH.Memory Queue Subscriber LATCH.Mutex LATCH.Mutex Stats LATCH.OS process
1 1 1 1 1 1 1 20 1 1 1 1 1 1 1 1 1 1 1 7
1 1 1 1 1 1 1 64 1 1 1 1 1 1 1 1 1 1 1 19
1 1 1 1 1 1 1 25 1 1 1 1 1 1 1 1 1 1 1 19
1 1 1 1 1 1 1 1231 1 1 1 1 1 1 1 1 1 1 1 442
114
2 6 1 1 1 1 1 1 1 2 1348 4 1 1 1 1 1 1 1 1 60 123 1 1 1 8662 137
372
4 9 1 1 1 1 1 1 1 6 4298 8 1 1 1 1 1 1 1 1 194 405 1 1 1 55143 140
151
3 10 1 1 11 1 1 1 1 2 1632 4 1 1 1 1 1 1 1 1 163 184 4 1 1 951450 1050
7177
121 313 1 1 384 1 1 1 1 123 80432 133 1 1 1 1 1 1 1 1 117630 7773 28 1 1 34597796 50414
35
34
35
41
17
26
108502
1464
LATCH.cas latch LATCH.change notification client cache latch LATCH.channel handle pool latch LATCH.channel operations parent latch LATCH.checkpoint queue latch LATCH.client/application info LATCH.cp cmon/server latch LATCH.cp pool latch LATCH.cp server hash latch LATCH.cp sga latch LATCH.cvmap freelist lock LATCH.deferred cleanup latch LATCH.dml lock allocation LATCH.done queue latch LATCH.dummy allocation LATCH.enqueue hash chains LATCH.enqueues LATCH.fifth spare latch LATCH.file cache latch LATCH.flashback copy LATCH.fourth Audit Vault latch LATCH.gc element LATCH.gcs commit scn state LATCH.gcs partitioned table hash LATCH.gcs pcm hashed value bucket hash LATCH.gcs resource freelist LATCH.gcs resource hash LATCH.gcs resource scan list LATCH.gcs shadows freelist LATCH.ges domain table LATCH.ges enqueue table freelist LATCH.ges group table LATCH.ges process hash list LATCH.ges process parent latch LATCH.ges resource hash list LATCH.ges resource scan list LATCH.ges resource table freelist LATCH.ges value block free list LATCH.global tx hash mapping LATCH.granule operation LATCH.hash table modification latch LATCH.heartbeat check LATCH.internal temp table object number allocation latch LATCH.intra txn parallel recovery LATCH.io pool granule metadata list LATCH.job workq parent latch LATCH.job_queue_processes parameter latch LATCH.k2q lock allocation LATCH.kdlx hb parent latch LATCH.kgb parent
1 1 153 23326 1898635 303 1 1 1 62 1 62 215 1 152 1895576 277943 1 396 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 102 1 1 1 1 16 825 1 1 1
LATCH.kgnfs mount latch LATCH.kokc descriptor allocation latch LATCH.ksfv messages LATCH.ksim group membership cache LATCH.kss move lock LATCH.ksuosstats global area LATCH.ksv allocation latch LATCH.ksv class latch LATCH.ksv msg queue latch LATCH.ksz_so allocation latch LATCH.ktm global data LATCH.kwqbsn:qsga LATCH.lgwr LWN SCN LATCH.loader state object freelist LATCH.lob segment dispenser latch LATCH.lob segment hash table latch LATCH.lob segment query latch LATCH.lock DBA buffer during media recovery LATCH.logical standby cache LATCH.logminer context allocation LATCH.logminer work area LATCH.longop free list parent LATCH.mapped buffers lru chain LATCH.message pool operations parent latch LATCH.messages LATCH.mostly latch-free SCN LATCH.msg queue latch LATCH.multiblock read objects LATCH.name-service namespace bucket LATCH.ncodef allocation latch LATCH.object queue header heap LATCH.object queue header operation LATCH.object stats modification LATCH.parallel query alloc buffer LATCH.parallel query stats LATCH.parameter table management LATCH.peshm LATCH.pesom_free_list LATCH.pesom_hash_node LATCH.post/wait queue LATCH.process allocation LATCH.process group creation LATCH.process queue LATCH.process queue reference LATCH.qmn task queue latch LATCH.query server freelists LATCH.queuing load statistics LATCH.recovery domain hash list LATCH.redo allocation LATCH.redo copy
1 6 1 1 37 204 133 71 1 121 103 132 189936 1039 1 13 1 1 1 1 1 250 1 748 740584 190168 1 459131 1 62 933625 7722488 1189 477 1 440 1 1 1 329356 164 121 1 1 538 1 1 1 1674926 1
LATCH.redo writing LATCH.resmgr:active threads LATCH.resmgr:actses change group LATCH.resmgr:actses change state LATCH.resmgr:free threads list LATCH.resmgr:plan CPU method LATCH.resmgr:resource group CPU method LATCH.resmgr:schema config LATCH.resmgr:session queuing LATCH.rm cas latch
128 14 1 1 2 1 7 12 1 1
431 47 2 1 6 1 17 41 1 1
28883 22 3 5 5 1 268 17 1 1
3943
1 1 10 30 160 1 3 12 20
4227
1 1 14 263 2022 1 13 14 65
4068
1 1 19 9819 88509 1 15 3 25
124569
1 1 182 264852 2384426 1 229 368 1234
LATCH.shared pool
LATCH.shared pool sim alloc LATCH.shared pool simulator LATCH.sim partition latch LATCH.simulator hash latch LATCH.simulator lru latch LATCH.sort extent pool LATCH.space background task latch LATCH.tablespace key chain LATCH.temp lob duration state obj allocation LATCH.temporary table state object allocation LATCH.test excl. parent l0 LATCH.test excl. parent2 l0 LATCH.third spare latch LATCH.threshold alerts latch LATCH.transaction allocation LATCH.undo global data LATCH.virtual circuit buffers LATCH.virtual circuit holder LATCH.virtual circuit queues STAT..CPU used by this session STAT..CPU used when call started STAT..DB time
3255
3 149 1 240 1 18 44 2 1 1 1 1 1 2 7 43 1 1 1 25 39 65
3452
1 145 1 1694 1 20 307 2 1 1 1 1 1 5 14 226 1 1 1 21 41 62
2645
1 148 1 14582 1 763 127 2 1 1 1 1 1 1 17 51456 1 1 1 21 21 88
65795
22 2635 1 1254014 1 37833 4133 401 1 1 1 1 1 122 616 1543184 1 1 1 23 31 586
STAT..Elapsed Time
STAT..HSC Heap Segment Block Changes STAT..Heap Segment Array Updates STAT..IMU Flushes STAT..IMU ktichg flush STAT..IMU undo allocation size STAT..SQL*Net roundtrips to/from client
5991
15 2 1 1 52 17
19381
14 2 1 1 52 17
7393
14 2 1 1 52 16
370518
14 2 2 1 52 16
STAT..buffer is not pinned count STAT..buffer is pinned count STAT..bytes received via SQL*Net from client STAT..bytes sent via SQL*Net to client STAT..calls to get snapshot scn: kcmgss STAT..calls to kcmgas STAT..calls to kcmgcs
3710976 3579904 63 62
37 1 1 1 17 16 1 1 29 36 1 1 1 18 17 1 1 29
933888 14
14 1 1 1 20 19 1 1 29
3072000 62
36 1 1 1 38 37 1 1 29
STAT..consistent gets STAT..consistent gets - examination STAT..consistent gets from cache STAT..consistent gets from cache (fastpath)
STAT..cursor authentications STAT..db block changes STAT..db block gets STAT..db block gets direct STAT..db block gets from cache STAT..db block gets from cache (fastpath) STAT..deferred (CURRENT) block cleanout applications STAT..enqueue releases STAT..enqueue requests STAT..execute count
171607
465 566 448 47 2 2 6
147610
450 562 429 47 2 2 5
734766
126 305 349 47 2 2 6
1835882
386 562 428 47 2 2 5
1895
234 18
1846
216 17
1461
123 75
1715
366 185
342
2
333
2
244
1
330
2
37 263
38 249
28 204
37 247
STAT..parse time cpu STAT..parse time elapsed STAT..physical read IO requests STAT..physical read bytes STAT..physical read total IO requests STAT..physical read total bytes STAT..physical reads STAT..physical reads cache STAT..physical reads cache prefetch
STAT..physical write IO requests STAT..physical write bytes STAT..physical write total IO requests STAT..physical write total bytes STAT..physical writes STAT..physical writes direct STAT..physical writes non checkpoint STAT..pinned cursors current
8 4 12 12 210 194 3653632 3522560 210 194 3653632 3522560 446 430 446 430 236 236
1 57344 1 57344 7 7 7 2 1 57344 1 57344 7 7 7 2
STAT..recursive calls
STAT..recursive cpu usage STAT..redo entries STAT..redo size STAT..redo size for direct writes STAT..redo synch time (usec) STAT..redo synch writes STAT..rows fetched via callback
2733
25 68 16420 96 2761 2 510
2591
27 68 16408 96 1394 2 507
2148
18 79 17856 96 1491 2 278
2583
29 133 28560 96 10945 2 507
295 4182
4849664 4915200 851656 1025240 29 169 455 3 1325 33
282 4114
4849664 4915200 851656 1025240 27 159 443 3 1292 33
209 2892
5111808 5636096 851656 1090752 19 128 244 3 968 28
273 4039
5242880 5242880 917168 1025240 132 159 443 3 1294 33
197 54458
13 4194304 5636 18 28 2 62 122
197 54458
13 4194304 5680 17 28 2 58 104
65 10748
13 4194304 5968 75 27 2 47 157
65 10748
13 4194304 9360 184 27 2 58 117
References: http://www.scribd.com/doc/134805528/UNSELECTIVE-INDEXES