none
which index is used when a table is joined more than one tables? RRS feed

  • Soru

  •     If we join two table we can guess which index is used  for the query.

        But when a table is joined more than two tables based on different columns, which indexes are used?

    According to the  example below;

    Assume that 3 indexes are defined on table A.

    index_1 is defined on column1,

    index_2 is defined on column2

    and  index_3 is defined on both column1 and column2 as composite index.

    Which  index is used by query optimizer for joining table A?

    select * from 
    
    A inner join B
    
    on A.column1=B.column1
    
    inner join C
    
    on B.column2=C.column1 and A.column2=C.column2

    21 Ekim 2013 Pazartesi 17:41

Yanıtlar

  • Which  index is used by query optimizer for joining table A?

    Answer: Which is shown on the query execution plan.

    SET STATISTICS XML ON;
    GO
    
    -- Your query goes here
    
    SET STATISTICS XML OFF;
    GO

    Clearly seeing is better than guessing..



    • Düzenleyen Usanmaz 21 Ekim 2013 Pazartesi 18:52
    • Yanıt Olarak İşaretleyen Burak ORDU 25 Ekim 2013 Cuma 06:22
    21 Ekim 2013 Pazartesi 18:45

Tüm Yanıtlar