SQL query to select million records quickly

后端 未结 4 1027
[愿得一人]
[愿得一人] 2021-02-04 22:03

I want to select million records from a table and I am using select query for this.

Currently it is taking a few minutes to get data. Can I get it quickly?<

相关标签:
4条回答
  • 2021-02-04 22:23

    Best way Fast Performance Tips for SQL Usiing SELECT Statements

       1:- Check Indexes. 
       2:- There should be indexes on all fields used in the WHERE and JOIN portions of the SQL statement
       3:-  Limit Size of Your Working Data Set.
       4:-  Only Select Fields You select as Need.
       5:- Remove Unnecessary Table and index 
       6:- Remove OUTER JOINS. 
       7:-  Remove Calculated Fields in JOIN and WHERE Clauses.
    
    0 讨论(0)
  • 2021-02-04 22:26

    Use Indexing for your table fields for fetching data fast.

    Reference:

    http://www.tutorialspoint.com/sql/sql-indexes.htm

    0 讨论(0)
  • 2021-02-04 22:29

    The speed of the query depends on the number of rows but if you do appropriate optimizations taking the performance factors such as:

    1. Indexing Clustered/Non clustered
    2. Data Caching
    3. Table Partitioning
    4. Execution Plan caching
    5. Data Distribution

    the query will execute faster.

    0 讨论(0)
  • 2021-02-04 22:36

    There's a few factors that would go into this. A quick list of things to look at:

    1. The speed of your server. CPU, memory, network connection would all be factors
    2. If you are doing a SELECT statement with conditions (ie. using a WHERE) or one with JOINS, having indexes will improve your performance, especially on a table with millions of rows. Hash tables will do a huge net positive on a large table.
    3. Writing clean queries. For example, if you have a large list of items you need to exclude from a query, perform a LEFT JOIN instead of using a NOT IN condition.

    This is really just the tip of the iceberg, but some of the easiest things to implement will also provide you with some of the biggest performance boosts.

    0 讨论(0)
提交回复
热议问题