Click here to Skip to main content
11,410,750 members (62,633 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL
My table contains more than 10lacs records, i need to fetch a single record from the same within a second.

Please help me

thanks in advance
Posted 6-Feb-13 1:49am
Comments
Irbaz Haider Hashmi at 6-Feb-13 7:17am
   
Can you send the details of the query and indexes on the table?
Indexes can really help you here.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

apply index on columns you are mostly using to search records from table.
Database performance optimization part 1 (Indexing strategies)[^]
Happy Coding!
Smile | :)
  Permalink  
Comments
MaheshPandian at 6-Feb-13 8:36am
   
thanks a lot
Aarti Meswania at 6-Feb-13 9:21am
   
welcome! :)
Glad to help you! :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

If you need to retrieve a record quickly from a table with a large number of rows, then you are going to have to think about indexes. Basically, if you perform a search that uses a field that has an index on it, then the database engine could search through the index to perform the search, which should result in a quick retrieval.

Some points to note about indexes however.

First of all, they aren't a magic bullet. If you apply indexes to every field in a table just in case you search on that field, then you are going to make updating that table more time consuming because indexes do take a period of time to rebuild.

Secondly, it's pointless indexing a field that has a low distribution of data. What does this mean? Well, imagine that your database table contains a field holds one of two values, say Male or Female, then indexing this is absolutely pointless. (Note - this table would, of course, violate database normalisation and I wouldn't recommend this practice, but this should help you understand the issue).
  Permalink  
Comments
MaheshPandian at 6-Feb-13 8:36am
   
thanks a lot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 239
1 Sascha Lefévre 85
2 Dave Kreskowiak 80
3 Maciej Los 68
4 RyanDev 50
0 Sergey Alexandrovich Kryukov 8,885
1 OriginalGriff 6,915
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web02 | 2.8.150414.5 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100