| |

VerySource

 Forgot password?
 Register
Search
View: 1083|Reply: 7

anxious! !! !! Very strange, please give me some advice about the speed of retrieving data ...

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-17 08:30:01
| Show all posts |Read mode
There is such a table in the database: A (a total of 40 fields, all fields are varchar type, more than 9,000 data)

TheID Date Number Heavy TheGoods ...
HH00001 2016-01-01 10 1000 Wood ......
HH00002 2016-05-01 50 6000 Steel ...

...
HH01111 2017-01-01 30 800 cloth ...
...

I used Sql statements to query the data, and a strange situation occurred:
select * from A where Date between '2016-01-01' and '2016-11-01'

If the date in the above statement should be 2017, then the data query becomes very slow (the data is about one hundred). "Other cases" speed is normal!

What is the cause of this? Is there any way to fix it? Please give pointers ...

Learn, pay attention to ...
Reply

Use magic Report

0

Threads

28

Posts

25.00

Credits

Newbie

Rank: 1

Credits
25.00

 China

Post time: 2020-6-18 15:00:01
| Show all posts
Is it possible that many people are accessing the server?
Reply

Use magic Report

0

Threads

88

Posts

55.00

Credits

Newbie

Rank: 1

Credits
55.00

 China

Post time: 2020-6-18 23:00:01
| Show all posts
Index by Date column to see how fast~
Reply

Use magic Report

0

Threads

40

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-6-20 14:15:01
| Show all posts
Remove * and change to the corresponding column name
Although troublesome, the efficiency will be higher
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-7-9 16:45:02
| Show all posts
Description of the landlord:
1. No more than 10 people access the server

2. I removed * and used only a few column names. After trying it, the effect is basically the same!

3. Index the Date column? The little brother is a rookie, this will not, can you teach me? ?
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-7-9 19:45:01
| Show all posts
1. If the query often uses Date, you can consider building an index
2. Update table statistics
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-7-9 21:00:01
| Show all posts
CREATE INDEX IdDate ON A(date);

UPDATE STATISTICS A
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-7-10 17:45:01
| Show all posts
Description of the landlord:

CREATE INDEX IdDate ON A(date);

UPDATE STATISTICS A

Where should these sentences be written? ? ? ?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list