Hello I have a DB Query like following
select amount, date, denominations, user, time, branch from deposits;
Now i see my database started growing up 500k +. Now if i add indexes to these columns in select query will the select becomes faster ?
All help i see in internet says if the column is part of where filter then there will be performance improvement. My Question is does select query (without where) becomes faster because of indexing fields ?
2
Answers
As you do not have a WHERE clause or JOIN clause, the query in question will do a full table scan. In some cases, myDBR can use an index-only query, but as you are fetching all rows, that would not help.
If you have 500k+ rows, ask yourself if you need all the rows. If you do, the result will be a full table scan.
"… does select query (without where) become faster because of indexing fields"
Short answer: No.
Long answer: If you are fetching only a few of the columns and you have a composite index with all those columns, it may be faster. This would be because that "covering" index would be smaller than the entire table.