Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7758979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:30:35+00:00 2026-06-01T13:30:35+00:00

I have been working with databases recently and before that I was developing standalone

  • 0

I have been working with databases recently and before that I was developing standalone components that do not use databases.
With all the DB work I have a few questions that sprang up.
Why is a database query faster than a programming language data retrieval from a file.

To elaborate my question further –

Assume I have a table called Employee, with fields Name, ID, DOB, Email and Sex. For reasons of simplicity we will also assume they are all strings of fixed length and they do not have any indexes or primary keys or any other constraints.

Imagine we have 1 million rows of data in the table. At the end of the day this table is going to be stored somewhere on the disk. When I write a query Select Name,ID from Employee where DOB=”12/12/1985″, the DBMS picks up the data from the file, processes it, filters it and gives me a result which is a subset of the 1 million rows of data.

Now, assume I store the same 1 million rows in a flat file, each field similarly being fixed length string for simplicity. The data is available on a file in the disk.
When I write a program in C++ or C or C# or Java and do the same task of finding the Name and ID where DOB=”12/12/1985″, I will read the file record by record and check for each row of data if the DOB=”12/12/1985″, if it matches then I store present the row to the user.

This way of doing it by a program is too slow when compared to the speed at which a SQL query returns the results.

I assume the DBMS is also written in some programming language and there is also an additional overhead of parsing the query and what not.

So what happens in a DBMS that makes it faster to retrieve data than through a programming language?

If this question is inappropriate on this forum, please delete but do provide me some pointers where I may find an answer.

I use SQL Server if that is of any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:30:37+00:00Added an answer on June 1, 2026 at 1:30 pm

    There are lots of techniques to speed up various kinds of access. As @Oded says, indexing is the big solution to your specific example: if the database has been set up to maintain an index by date, it can go directly to the entries for that date, instead of reading through the entire file. (Note that maintaining an index does take up space and time, though — it’s not free!)

    On the other hand, if such an index has not been set up, and the database has not been stored in date order, then a query by date will need to go through the entire database, just like your flat-file program.

    Of course, you can write your own programs to maintain and use a date index for your file, which will speed up date queries just like a database. And, you might find that you want to add other indices, to speed up other kinds of queries — or remove an index that turns out to use more resources than it is worth.

    Eventually, managing all the features you’ve added to your file manager may become a complex task; you may want to store this kind of configuration in its own file, rather than hard-coding it into your program. At the minimum, you’ll need features to make sure that changing your configuration will not corrupt your file…

    In other words, you will have written your own database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have recently been working with a COM+ component that processes an input XML
I have been working with relational databases for sometime, but it only recently occurred
I have been working on optimizing my Postgres databases recently, and traditionally, I've only
I have been working on Eclipse recently. I am fairly new to java programming,
Recently I've been working a little with MongoDB and I have to say I
I've been working on optimizing my site and databases, and I have been using
I've been working with databases for the last few years and I'd like to
I am currently building an ecommerce site with PHP/MySQL. Recently, I have been working
I've been a long time user of R and have recently started working with
Recently I have been working on a project where, among other things, we want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.