Query optimization on a Table with 1 Million rows

Richard Diogo

I'm doing a query over 1 million customers in SQL. Can this query be further optimized?

I'm trying to optimize the search criteria.

In the WHERE-clause:

SELECT * 
   FROM  [TB_AGENDA-VENDEDOR_VENDEDORES] AS Vend
   INNER JOIN [TB_AGENDA-VENDEDOR_CLIENTES] AS Cli
      ON Cli.EQUIPE_VENDA = Vend.EQUIPE_VENDA  
   WHERE Vend.EMAiL = '[email protected]' ORDER BY PROXIMA_LIGACAO ASC, CATEGORIA ASC

And in the ON-clause:

 SELECT * 
    FROM  [TB_AGENDA-VENDEDOR_VENDEDORES] AS Vend
    INNER JOIN [TB_AGENDA-VENDEDOR_CLIENTES] AS Cli
      ON Cli.EQUIPE_VENDA = Vend.EQUIPE_VENDA  AND Vend.EMAiL = '[email protected]'
ORDER BY PROXIMA_LIGACAO ASC, CATEGORIA ASC

or if you have other ideas or reference?

Ionic

Well due to the fact that both should be interpreted the same, there isn't a real difference between them.

I would personally suggest to add an index to your column Vend.EMAiL. But only if your query runs more often than you add new rows to it. This really depends on the usage.

One example could be this index:

CREATE NONCLUSTERED INDEX NCI_TB_AGENDA_VENDEDOR_VENDEDORES_EMAIL 
    ON [TB_AGENDA-VENDEDOR_VENDEDORES] (EMAiL)

But as already said, it really depends on your usage and if you really want to retrieve all columns from both rows or only from one table or only some specific columns from each table.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Slow Query on Medium MySQL Table (1 Million Rows)

From Dev

Slow Query on Medium MySQL Table (1 Million Rows)

From Dev

Query large table with 50 million rows

From Dev

Optimizing SQL query on table of 10 million rows: neverending query

From Dev

Optimal MYSQL query for longest prefix matching in a table with 5 million rows

From Dev

Optimal MYSQL query for longest prefix matching in a table with 5 million rows

From Dev

Very slow SELECT query in MySQL in a 10 Million rows table (single table)

From Dev

Java SQL 1 million rows

From Dev

Java SQL 1 million rows

From Dev

Doctrine native query(createNativeQuery) select query for 1 million rows high memory usage

From Dev

How to query against 18million rows?

From Dev

Rebuild Index on table with 128 million rows

From Dev

Sort table with million rows , LinQ connection

From Dev

Mysql database design: table with half a million rows

From Dev

MS Access: How to add multiple rows to table within 1 query

From Dev

MySQL query to select rows from table 2 if *all* rows from table 1 are not present

From Dev

update query with 1.5 million rows taking long time to execute mysql

From Dev

SQL - Delete table with 372 million rows starting from first row

From Dev

How to quickly delete a column from a table containing 600 million rows?

From Dev

Key press autocomplete queries to a 3 million rows table

From Dev

Django pagination. What if I have 1 million of rows?

From Dev

python postgres can I fetchall() 1 million rows?

From Dev

Fastest way to insert 1 million rows in SQL Server

From Dev

Excel : Need to delete about 1 million blank rows

From Dev

Heroku destroy_all 1/2 million rows seems to hang

From Dev

Mysql group by won't use index after 1 million rows

From Dev

SQL - Poor Performance SELECT Query on 377 million table

From Dev

MySQL writing a query with 2 million records to a new table

From Dev

Brighthouse optimization in table structure for SELECT query

Related Related

  1. 1

    Slow Query on Medium MySQL Table (1 Million Rows)

  2. 2

    Slow Query on Medium MySQL Table (1 Million Rows)

  3. 3

    Query large table with 50 million rows

  4. 4

    Optimizing SQL query on table of 10 million rows: neverending query

  5. 5

    Optimal MYSQL query for longest prefix matching in a table with 5 million rows

  6. 6

    Optimal MYSQL query for longest prefix matching in a table with 5 million rows

  7. 7

    Very slow SELECT query in MySQL in a 10 Million rows table (single table)

  8. 8

    Java SQL 1 million rows

  9. 9

    Java SQL 1 million rows

  10. 10

    Doctrine native query(createNativeQuery) select query for 1 million rows high memory usage

  11. 11

    How to query against 18million rows?

  12. 12

    Rebuild Index on table with 128 million rows

  13. 13

    Sort table with million rows , LinQ connection

  14. 14

    Mysql database design: table with half a million rows

  15. 15

    MS Access: How to add multiple rows to table within 1 query

  16. 16

    MySQL query to select rows from table 2 if *all* rows from table 1 are not present

  17. 17

    update query with 1.5 million rows taking long time to execute mysql

  18. 18

    SQL - Delete table with 372 million rows starting from first row

  19. 19

    How to quickly delete a column from a table containing 600 million rows?

  20. 20

    Key press autocomplete queries to a 3 million rows table

  21. 21

    Django pagination. What if I have 1 million of rows?

  22. 22

    python postgres can I fetchall() 1 million rows?

  23. 23

    Fastest way to insert 1 million rows in SQL Server

  24. 24

    Excel : Need to delete about 1 million blank rows

  25. 25

    Heroku destroy_all 1/2 million rows seems to hang

  26. 26

    Mysql group by won't use index after 1 million rows

  27. 27

    SQL - Poor Performance SELECT Query on 377 million table

  28. 28

    MySQL writing a query with 2 million records to a new table

  29. 29

    Brighthouse optimization in table structure for SELECT query

HotTag

Archive