Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

google cloud storage mySql query reads only a few hundred lines per second

I have set up a database with a table of approximately 100GB. I use 4cpu and 15GB ram on the gcs. When I make a query I can see from the read/write operations dashboards that only a few hundred lines are read per second which will take forever to complete.

the query is done on DBeaver, it is not a complicated query as can be seen from the picture attached. I simply do not understand why it is so slow??

the query is simply this:

"""INSERT INTO analytics_agg ( hash, product, interface, click_time_0, click_time_5, click_time_10, click_time_30, click_time_60) SELECT hash, product, interface, count(case when click_time=0 then 1 else 0 end) , count(case when click_time=5 then 1 else 0 end) , count(case when click_time=10 then 1 else 0 end) , count(case when click_time=30 then 1 else 0 end) , count(case when click_time=60 then 1 else 0 end) FROM analytics group by hash,product,interface """ enter image description here

question from:https://stackoverflow.com/questions/65894917/google-cloud-storage-mysql-query-reads-only-a-few-hundred-lines-per-second

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

1 Reply

0 votes
by (71.8m points)

As you're selecting from one table and inserting in another, the selection from the first table has a large impact on the final insertion rate and performance.

Try to create the following index, which should optimize the selection query and improve the overall performance of the insertion:

ALTER TABLE `analytics` ADD INDEX `analytics_idx_hash_product_interface` (`hash`,`product`,`interface`);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...