Primary Key and Unique key

  • Hi Guys

    i have a table which have 16 lac records

    i want to retrieves the records in 4 seconds

    current it is taking 25 seconds for me to retrieve the data.

    i have a primary key on that table.

    can u please help me

  • Please start your own thread for a question, post table DDL and query code.

  • Ian Yates (1/31/2008)


    Certainly linking your foreign keys to primary keys only helps with understanding and self-documenting of the database. You should at least have a primary key on the table always.

    Here are two very interesting statements.

    1- Do you really think referential integrity "only helps with understanding and self-documenting the database"?

    2- Are you really saying "you should at least have a PK on a table?

    If I got right your two statements please refrain to publish posts that would do nothing but confuse people out there.

    _____________________________________
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at Amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
  • Hmmm, I haven't had the time to post on here for months (this thread's had some activity again?). I used to write a lot of my posts fairly late at night (Australian time) so I apologise for the confusion if any was caused.

    "Only" should be read as "even if you think you get nothing from it (FK relationships) you're at least getting documentation".

    Of course you should at least have a primary key on a table. I tried to give a short answer to a short question which then spawned queries about the meaning of a clustered index and how it relates to primary keys (there's no relation, as explained by others, apart from what you get if you accept the defaults of the GUI tools 🙂 ).

    In hindsight I probably should have written a bit more or at least have done what I usually tried to do which was to find a couple of article references and post links to them instead. This question was done to death in the forums and a little searching before posting would save a lot of questions being asked in the first place.

    Whilst I appreciate the clarification of my original brief reply, I don't see the necessity for the extra jibe at the end, but if you can't throw a comment in now in then, what good are forums 😛

Viewing 4 posts - 16 through 18 (of 18 total)

You must be logged in to reply to this topic. Login to reply