Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

mysql - fetch time is taking time

I am running below simple query,execution time is 1sec but fetch time is 30 sec. It contains totally 100 000 records

SELECT id, referrer, timestamp  
FROM masterstats_innodb 
WHERE video = 1869 AND timestamp between '2011-10-01' and '2021-01-21';

Index is created on video and timestamp column and even range partition has been created on timestamp table. Can anything be done to fetch result faster?

question from:https://stackoverflow.com/questions/65840643/fetch-time-is-taking-time

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Please provide SHOW CREATE TABLE.

Plan A: INDEX(video, timestamp)

Plan B - slightly better because of being "covering":

INDEX(video, timestamp, referrer, id)

PARTITIONing will not help the performance of this query any more than indexing.

You say "it" contains 100K rows -- are you referring to the table? Or the just the number of rows returned. If 'table', then the index will help. If the 'resultset', then you are constrained by having to send so many rows. What will the client do with 100K rows?? Can the server condense the data (eg summarize it in some way)?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...