• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regarding Database Index

 
Ranch Hand
Posts: 58
Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does creating a table automatically creates index on the column.
I mean if I will create a table
create table.....(id, name)
Will this automatically be indexed on id and name ?
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. Nor should it be. Indices incur a decrease in insert/update/delete performance so you wouldn't want them added by default.

Some database s (such as SQL Server) will automatically create indices on columns that are foreign keys. Other than that by and large its up to you to choose what to index.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Priyakant,
Many databases automatically create an index on the primary key (likely id in your example.)

There would be no point in creating an index on all the columns in the table - automatically or manually. The reason is that such an index would be just as large as the source table. Which means it would take just as long to scan as the table.
 
Priyakant Charokar
Ranch Hand
Posts: 58
Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot for the promt replies
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic