Million data records in Table A and hundreds of data records in database B. query all data in Table A with B conditions.

Source: Internet
Author: User
Problem: the problem is: Table A140 contains 350 million pieces of data, and table B temporary table contains pieces of data. Now I use such a query statement: select * fromAwhereexists (select1fromBwhereB. batchnoA. batchno) Table A and table B are associated by the batchno field. The field type is varchar (50). In table A, the batchno creates an index database.

Problem: the problem is: Table A has 1.4 million data records, and table B has 350 temporary data records. Now I use this query statement, select * from A where exists (select 1 from B where B. batchno =. batchno) Table A and table B are associated by the batchno field. The field type is varchar (50). In table A, the batchno creates an index database.

Problem:

The problem is: Table A contains 1.4 millionData, Table B temporary table 350Data,
I am using thisQueryStatement, select * from A where exists (select 1 from B where B. batchno = A. batchno)
Table A and table B are associated with the batchno field. The field type is varchar (50). The batchno field in Table A is indexed.
DataThe database is SQL server 2000,QueryIs there any way to optimize the time between 23 and 30?


Solution:

Do not connect two tables
First, set batchno in Table B
Use select batchno from B
Detected
String (batchno1, batchno2, batchno3, bat4 ,......)
Then select * from A where batchno int (batchno1, batchno2, batchno3, batc4 ,......)

I recently worked on a project to process millions of log records.QueryHalf a day
Later, we split the tables one by one and checked the restrictions.ConditionSave it first.




Original address: http://topic.csdn.net/u/20090523/16/9e891fda-72dc-4417-b554-22edfde7e437.html? 52778

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.