I now have a table with no primary key. there is only one union unique (date, user_id, count_name,) Table record example: date: 20160808user_id: 556count_name: a1date indicates the date, user_id indicates the user id, and count_name indicates a statistical value. C...
I have a table with no primary key and only one union is unique (date, user_id, count_name ,)
Table record example: date: 20160808 user_id: 556 count_name: a1
Date indicates the date, user_id indicates the user id, and count_name indicates a statistical value.
Count_name can be set to a1, a2, a3,..., a12, b1, b2, b3,..., b12 );
Tens of thousands of records are generated every day.
The maximum number of records retrieved by the database is 10 thousand.
Now I need to count 12 values. The mysql statement can be used as follows:
select count(distinct(`shop_id`)) from count_table where date = '20160808' and count_name in ('a1','b1'); select count(distinct(`shop_id`)) from count_table where date = '20160808' and count_name in ('a2','b2'); ···
In this way, the database can be retrieved for 12 times, but the efficiency is not high.
Is there a way to retrieve the desired data at a time? (This is an old database with a large data volume. let's make the final consideration of modifying the database !)
Methods tried:
In case of paging statistics, the table does not have a primary key, and the paging is not easy to process.
One-time data extraction is being processed, because mysql can only retrieve about 10 thousand pieces of data at a time, and may crash even more.
Reply content:
I have a table with no primary key and only one union is unique (date, user_id, count_name ,)
Table record example: date: 20160808 user_id: 556 count_name: a1
Date indicates the date, user_id indicates the user id, and count_name indicates a statistical value.
Count_name can be set to a1, a2, a3,..., a12, b1, b2, b3,..., b12 );
Tens of thousands of records are generated every day.
The maximum number of records retrieved by the database is 10 thousand.
Now I need to count 12 values. The mysql statement can be used as follows:
select count(distinct(`shop_id`)) from count_table where date = '20160808' and count_name in ('a1','b1'); select count(distinct(`shop_id`)) from count_table where date = '20160808' and count_name in ('a2','b2'); ···
In this way, the database can be retrieved for 12 times, but the efficiency is not high.
Is there a way to retrieve the desired data at a time? (This is an old database with a large data volume. let's make the final consideration of modifying the database !)
Methods tried:
In case of paging statistics, the table does not have a primary key, and the paging is not easy to process.
One-time data extraction is being processed, because mysql can only retrieve about 10 thousand pieces of data at a time, and may crash even more.