Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>1) op asks: <code>Is it true that by every index a copy of table created?</code> it is not true. an index will store the indexed columns and the pointer back (like the the clustered PK, etc.) to the row. it will also store any INCLUDE columns, but that is another topic.</p> <p>2) it is hard to guess on the timings not knowing the hardware, the tables, or the indexes in question. I'm sure that SQL Server is good at optimizing the maintenance of indexes. You should test this by inserting the same rows with only a PK and then try again with 40 indexes and then again with 80. I'm sure the bulk of the time is just the inserts.</p> <p><strong>EDIT</strong> </p> <p>3) op asks <code>when we have a Foreign key on a column SQL Server automatically create non-cluster index on it.this Index useful for quering or Joins?</code> SQL Server does NOT automatically create an index for foreign keys. However, adding an index on FK columns may be useful. If you write a query that joins two tables on the FK, then the index MAY be used. Consider the following:</p> <pre><code>tableA RowID int PK RowDate datetime OtherID int tableB OtherID int PK someValue varchar(5) </code></pre> <p>if you add a FK for tableA.OtherID to tbaleB.OtherID and use this query:</p> <pre><code>select * from tableA a INNER JOIN tableB b ON a.OtherID=b.OtherID WHERE a.RowDate&lt;'2011/1/1' </code></pre> <p>then an index on tableA.OtherID won't be used, an index on tableA.RowDate will be used and the PK index on tableB.OtherID will be used.</p> <pre><code>select * from tableA a INNER JOIN tableB b ON a.OtherID=b.OtherID WHERE b.someValue='AA' could also be written as: select * from tableb b INNER JOIN tableA b ON b.OtherID=a.OtherID WHERE b.someValue='AA' </code></pre> <p>then an index on tableA.OtherID may be used, and any index on tableb.someValue will be used.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload